Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
Created May 16, 2025 12:17
Show Gist options
  • Save pesterhazy/09d92b34bcbdc6964299ff279b0a3214 to your computer and use it in GitHub Desktop.
Save pesterhazy/09d92b34bcbdc6964299ff279b0a3214 to your computer and use it in GitHub Desktop.
What's a good folder structure to use for a Typescript backend app?

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 go yyy/)
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment