Skip to content

Instantly share code, notes, and snippets.

@jasonblanchard
Last active July 27, 2021 19:33
Show Gist options
  • Save jasonblanchard/e45952d96d4f55e6f37828b05a8911f9 to your computer and use it in GitHub Desktop.
Save jasonblanchard/e45952d96d4f55e6f37828b05a8911f9 to your computer and use it in GitHub Desktop.

App Structure

root
├── core - core application logic. Things in here have no knowledge of stores nor interaction ingress/egress
│   ├── entities.ts -- domain entities shared throughout the core logic
│   └── someFn.ts -- some (probably pure) function that does some business logic.
├── store
│   ├── SqlStore.ts -- given a DB connection, issues queries and returns plain 'old objects. You could also go nuts and define these as interfaces alongside concrete instances to allow for mocked instances in tests or pre-prod envs.
│   └── ObjectStore.ts -- given object store client, issues requests to CRUD files, returns plain 'old objects
├── app.ts - this is all the stuff that your app can do. Wires together `core` and `store`, gets used
└── cmd - all interaction ingress/egress. It's how your app gets used.
    ├── cli
    │    └── index.ts -- do all the CLI flag parsing in here, calls functions on App
    ├── http
         └── index.ts -- do all the HTTP req/res flag parsing in here, calls functions on App

root may be the actual src/ root of the project. Your project may also contain multiple of these that encapsulate different application "domains" in a single project. In that case, you may move cmd up a level and wire together multiple apps.

Inspiration

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