agentleFS
KhaledSaeed18KhaledSaeed18/node-express-boilerplate/.cursor/rules/architecture.mdc

node-express-boilerplate / rules

Cursor rule36 starsChanged 4 months agoMITView on GitHub

Architecture overview and file-structure rules for every new resource

We split this architecture.mdc into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every new resource requires exactly these five files, in this order:

    line 11
  2. Distinctive:

    After creating those files:

    line 21

≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
architecture.mdc
---
description: Architecture overview and file-structure rules for every new resource
globs: ["src/**/*.ts"]
alwaysApply: true
---

# Layered Architecture

Routes → Controllers → Services → Repositories → Prisma (PostgreSQL).

Every new resource requires exactly these five files, in this order:

| File | Purpose |
|------|---------|
| `src/validations/<name>.validation.ts` | Zod v4 schemas + `RequestHandler` exports |
| `src/repository/<name>.repository.ts` | `I<Name>Repository` interface + class extending `BaseRepository` |
| `src/services/<name>.service.ts` | `I<Name>Service` interface + class |
| `src/controllers/<name>.controller.ts` | `I<Name>Controller` interface + class extending `BaseController` |
| `src/routes/<name>.route.ts` | class extending `BaseRoute`, exports router instance |

After creating those files:
1. Register repository, service, and controller in `src/container/index.ts` following the existing init pattern.
2. Mount the route in `src/app.ts` at `/api/v1/<name>`.
3. Export all interfaces and classes from the barrel files (`src/repository/index.ts`, `src/services/index.ts`, `src/controllers/index.ts`).

# DI Container

`Container` (singleton in `src/container/index.ts`) is the only place where `new Repository/Service/Controller()` is called. Access instances in routes via `this.container.get<Name>Controller()`.

# Entry Points

- `src/index.ts` — binds the port only (import `app` in tests without binding)
- `src/app.ts` — all middleware and route mounting

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.