Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.

Project structure · Backend

Express with TypeScript project structure

Opens with credits

For students who know a bit of JavaScript and want a backend that looks like the ones teams actually run. Express gives you almost no structure, so this layout supplies it: one folder per feature under src/modules, each split into routes, controller, service and repository, with Zod at the edge and Vitest plus Supertest for tests.

Curated by Tauseef FayyazIntermediate187 files and foldersExpress 5.2, TypeScript 7.0, Node.js 24 LTSChecked October 2026
Explore the filesPick any file to see what it is, why it exists and when you add it.

How it grows

Each stage opens the explorer there

  1. 1Day 1What the scaffold and your first hour give you11 files and folders
  2. 2GrowingWhat a real app with features and tests adds+90 files and folders
  3. ProductionWhat running it for real users adds+31 files and foldersOpens with credits
  4. ExpertWhat a team needs to keep it healthy for years+55 files and foldersOpens with credits

How it is organised

  • Group by feature, not by file type: everything about orders lives in src/modules/orders, so a change touches one folder instead of five. The trade-off is a little repetition between modules, which is cheaper than hunting across controllers/, services/ and models/ folders.
  • Each layer has one job: routes map URLs, controllers speak HTTP, services hold business rules, repositories talk to the database. Services never see req or res, so you can test them without a server.
  • Validate at the edge with Zod, then trust the types inside. Config is validated the same way at startup, so a missing variable crashes on boot, not at 2am.
  • Build the app in app.ts and listen in server.ts, so tests import the app and hit it with Supertest without opening a port.
  • Express 5 forwards rejected promises to your error handler, so async handlers need no try/catch wrapper: throw a typed AppError and let one error middleware shape every response.
  • Slow work leaves the request: sending emails or calling third parties goes on a BullMQ queue and a separate worker process picks it up, so a slow mail server never slows checkout.
  • Test in layers: unit tests next to the code at Growing, API tests through Supertest, then a real PostgreSQL in Testcontainers at Production, and contract, load and mutation tests only when a team and its clients are big enough to need them.
  • Grow structure only when pain appears. A single package with modules is right for most teams; workspaces, enforced boundaries, Terraform and SLO files in the Expert stage pay off when several people or services share the code.

At the top of the project

Open one in the explorer for the full story

Learn more on Sefism

Roadmaps, cheat sheets and projects that go with Express with TypeScript.

See 9 more
Checked against 9 official sources, October 2026. If something has changed, the docs win.Show sources

Picked from the other libraries by shared topics.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.

  • 1:1 Mentorship
  • Fresh Graduate Mentorship
  • Career Guidance

Brand deals, promos and partnerships: tauseeffayyaz@gmail.com