Modular architecture

From infra-geo-ouverte/igo2-lib · View interactive version

Modular architecture is an AI agent skill from the GitHub repository infra-geo-ouverte/igo2-lib. Enforces modular domain architecture and clean code standards. Use when creating or refactoring packages, domains, components, services, models, and tests in packages/*.

How to use this skill

Skill file

Modular Domain Architecture Standards

This skill defines enforceable architecture and coding rules for Angular libraries to keep the codebase maintainable, scalable, and predictable.

1. Scope

Apply this skill to changes in:

Do not apply this skill to generated artifacts, coverage output, or unrelated tooling files.

2. Rule Priority and Conflict Resolution

When rules conflict, apply this order:

  1. Correctness and build/test stability
  2. Public API compatibility (unless migration is explicitly requested)
  3. Architecture boundaries (layer responsibilities and dependency direction)
  4. Naming and folder conventions
  5. Style preferences

If a lower-priority rule conflicts with a higher-priority rule, follow the higher-priority rule and note the exception in your response.

3. Mandatory Rules

3.1 Layer Responsibilities

Components must not contain complex business logic if that logic can live in a service.

3.2 Dependency Direction

3.3 Type Safety

3.4 Naming and Searchability

Use singular domain-prefixed filenames:

Keep names intent-revealing and consistent with existing package terminology.

4. Preferred Patterns

5. Decision Rules (If-Then)

  1. If creating a new UI feature in a domain, use a standalone component by default.
  2. If feature logic spans multiple components, create or extend a domain service.
  3. If shared logic is domain-agnostic and pure, move it to a utility in a shared package.
  4. If an interface exceeds one responsibility, split it into smaller focused interfaces.
  5. If a change risks breaking public exports, preserve the existing API or provide a migration path.

6. Exceptions Policy

Allowed exceptions:

For every exception, document briefly:

  1. Which rule was bypassed
  2. Why it was necessary
  3. Recommended follow-up action

7. Anti-Patterns to Avoid

8. Minimal Domain Layout

packages/[package]/
  src/
    lib/
      [domain]/
        [domain].component.ts
        [domain].service.ts
        [domain].model.ts
        [domain].interface.ts
        [domain].spec.ts

Adjust file set per feature needs, but preserve domain-prefix naming and layer boundaries.

9. Pre-Response Self-Checklist

Before finalizing a change, verify:

  1. Are responsibilities split correctly between component/service/model?
  2. Are dependency directions valid and non-circular?
  3. Was any avoided in new code?
  4. Do new files follow domain-prefix naming?
  5. Is duplicated logic extracted where practical?
  6. Are tests added or updated for behavior changes?
  7. Were exceptions documented when standards could not be followed?
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.