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.
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-uiWhat you get
- backendContract-first Hono and oRPC services over MongoDB, a generated OpenAPI spec, Redis cache, per-procedure rate limits.
- identityOne IAM service on Better Auth: sessions, two-factor, passkeys, GitHub and Discord linking, account deletion.
- multi-tenancyWorkspaces, members, invitations, intent-based roles and an audit log with an Activity view.
- webA TanStack Start app on a shadcn/ui design system, with forms rendered from one Zod schema.
- mobileFlutter apps themed from the same design tokens as the web app.
- observabilityOpenTelemetry from the browser to Mongo, through a Collector into local Grafana.
- generatorsNx generators for models, contracts, domains, services and apps, so new code is generated, not copied.
- ai-nativeAn AGENTS.md rulebook, repo skills for recurring tasks and a docs map.
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.
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.
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.
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.
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.
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
- Write the contract
- Add the repository method
- Wire the handler
Welcome aboard
Your workspace is ready.
Open workspaceOpinions, written down
One answer per choice, with the reason next to it. If you disagree, the reason tells you what to change.
- 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.
- AGENTS.mdrules and recipes
- CLAUDE.mdimports AGENTS.md
- .claude/skills/recurring jobs
- api-endpoints/an endpoint
- form-builder/a form
- domain-repository-tests/repository tests
- add-flutter-page/a Flutter page
- docs/README.mdthe docs map
pnpm nx g @gentlemans-stack/nx-plugin:<generator> --dry-runpnpm verifynode scripts/docs-lint.mjsWhat it is not
- 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.