TL;DR: what's a good folder structure to use for a Typescript backend app?
Working on a larger monolithic app, I'm curious about best practices on structuring the project:
- What should the folder hierarchy look like in 2025?
- What are the abstractions or categories? (services, handlers, models, ...)
- What dependency rules (optionally be enforced by dependency-cruiser) should be adopted? E.g. "api/*.ts can refer to db/*ts, but not vice versa"
What problems am I trying to solve?
- Gaining a clearer understanding of where new bits of logic should go (e.g. request handlers go to
xxx/
, model checks goyyy/
) - Errecting module boundaries so that you can reason about (and test) a smaller module in isolation
The project is using Express.js, Drizzle and Typebox, but I'm interested in any kind of resources or advice, including those taken from other backend languages.