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.

Revisions

  1. pesterhazy created this gist May 16, 2025.
    14 changes: 14 additions & 0 deletions typescript-folder-structure.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    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.