gentlemans-stack

A SaaS starting point you can change safely, with or without an AI assistant.

Web, mobile and APIs in one Nx monorepo. You clone it and build on top. Only a small Todo example ships, to generate from and diff against.

quick start
git clone https://github.com/ersanyamarya/gentlemans-stack.gitcd gentlemans-stack && pnpm installcp .env.example .envpnpm infra:up# then, one terminal each:pnpm nx serve iam-servicepnpm nx serve todo-servicepnpm nx dev todo-ui

What you get

Four layers, and dependencies point one way

A change lands in the layer it belongs to, so an assistant or a new teammate knows where to look and what to leave alone.

  1. models/

    Models

    Zod schemas for the data that crosses a boundary. They carry no UI hints, so a server, a browser and Flutter can all use them.

    models/
    • todo-model
    • workspace-model
    • audit-model
    • app-error-model

    Imports nothing else in the repo.

  2. libs/ connectors/

    Libs and connectors

    The machinery every service shares, and one isolated adapter per piece of infrastructure.

    libs/ connectors/
    • contract-kit
    • rate-limit
    • observability
    • auth
    • mongodb-connector
    • redis-connector

    Imports models and other foundation packages, never a service or an app.

  3. contracts/ domains/

    Contracts and domains

    A contract is a service's public API. A domain is a Mongoose schema plus a repository, with no knowledge of HTTP.

    contracts/ domains/
    • todo-contracts
    • workspace-contracts
    • todo-domain
    • workspace-domain
    • audit-domain

    Contracts import models and contract-kit. Domains import models and foundation libs.

  4. services/ apps/

    Services and apps

    The composition roots. They wire contracts, domains and connectors into something that runs.

    services/ apps/
    • iam-service
    • todo-service
    • todo-ui
    • todo-mobile

    Wires the layers below it together. Nothing imports it.

Edit one file. Web, Flutter and email follow.

tokens.json generates the web theme, every Flutter app's theme and the email colors. Pick a palette to see one change land in all three. The frames are simplified sketches, not screenshots.

tokens.json
Palette

ui-libs/design-tokens/src/tokens.json

  "color": {    "light": {      "accent": "#0A7A3C",      "background": "#F3F7F4",      "border": "#D8D4CC",      ...

pnpm nx run design-tokens:generate

  • wrote ui-libs/design-system/src/styles/tokens.css
  • wrote docs/design-tokens.md
  • wrote apps/email-templates/src/email-tokens.g.ts
  • wrote apps/todo-mobile/lib/core/theme/app_tokens.g.dart
Web, from todo-ui
TodosNew todo
  • Write the contract
  • Add the repository method
  • Wire the handler
Email, the welcome template

Welcome aboard

Your workspace is ready.

Open workspace
Flutter, todo-mobile
Todos
+

Opinions, written down

One answer per choice, with the reason next to it. If you disagree, the reason tells you what to change.

principles
contracts-first
A service's public API is a contract before it is a handler.
one-job-per-package
Small packages are cheap for a person or an assistant to read.
generate-dont-copy
New models, services and apps come from Nx generators.
build-the-minimum
Every change starts with the question: does this need to exist?
boundaries-are-checked
Only the IAM service reads the auth collections, and a script fails the build otherwise.
factories-not-classes
createX(deps) returns the methods. Dependencies are passed in as one named object.

The docs are the assistant's rulebook

AGENTS.md is the file every AI coding tool reads, and these pages are the same Markdown files. Repo skills cover the recurring jobs: an endpoint, a form, repository tests, a Flutter page.

what an assistant reads
  • AGENTS.md
  • CLAUDE.md
  • .claude/skills/
  • api-endpoints/
  • form-builder/
  • domain-repository-tests/
  • add-flutter-page/
  • docs/README.md
the checks an assistant runs
pnpm nx g @gentlemans-stack/nx-plugin:<generator> --dry-runpnpm verifynode scripts/docs-lint.mjs

What it is not

status
package
not published yet
You clone it.
cloud
none required
Google Cloud Run is an optional add-on.
production
not finished
Email delivery, background jobs and billing are on the roadmap.
Read the roadmap

Clone it, run it, then change it.