Architecture for TypeScript backend with multiple entry points or apps [closed]

I suspect this is a solved problem because I'm not doing anything very unusual, and yet I'm struggling to work out a sensible structure for my TypeScript/Node.js backend. Briefly, the project consists of: a database (Postgres) a data access layer encapsulating database queries a service layer encapsulating business logic several executable entry points: an API server some scheduled jobs some Lambda functions We're a small team and we don't want to manage a herd of microservices. But at the same time I want to avoid a tightly coupled monolithic architecture that's hard to reason about and makes CI pipelines slow. Ideally I would like to separate the data access and service layers into packages which the apps then consume (all in a monorepo). But where I'm falling over is how to manage shared configs. I'm looking for a solution that: Ensures each app has the config that it needs, type checked at build time and validated at runtime Allows the packages to make use of shared services which themselves need config. e.g. a database connection or a logger object The project is deployed to AWS but I'd like to avoid vendor-specific solutions if possible.

Apr 23, 2025 - 21:48
 0
Architecture for TypeScript backend with multiple entry points or apps [closed]

I suspect this is a solved problem because I'm not doing anything very unusual, and yet I'm struggling to work out a sensible structure for my TypeScript/Node.js backend.

Briefly, the project consists of:

  • a database (Postgres)
  • a data access layer encapsulating database queries
  • a service layer encapsulating business logic
  • several executable entry points:
    • an API server
    • some scheduled jobs
    • some Lambda functions

We're a small team and we don't want to manage a herd of microservices. But at the same time I want to avoid a tightly coupled monolithic architecture that's hard to reason about and makes CI pipelines slow.

Ideally I would like to separate the data access and service layers into packages which the apps then consume (all in a monorepo). But where I'm falling over is how to manage shared configs.

I'm looking for a solution that:

  1. Ensures each app has the config that it needs, type checked at build time and validated at runtime
  2. Allows the packages to make use of shared services which themselves need config. e.g. a database connection or a logger object

The project is deployed to AWS but I'd like to avoid vendor-specific solutions if possible.