Vishal.dev
Back
auth · db · deploy
Full-Stack

Aptiq — Production-Ready SaaS API Starter

A clean SaaS starter template with Express + TypeScript + Prisma backend, React + Vite + TanStack Query frontend, JWT auth with refresh tokens, and deployment configs for Docker, Render, Railway, and Fly.io.

ExpressTypeScriptPrismaPostgreSQLReactViteTanStack QueryReact RouterJWTDockerGitHub Actions
2
Apps
4
Deploy targets
3
Shared packages

Domain Knowledge

What problem this project solves

Every SaaS product repeats the same bootstrap: auth, health checks, a database, and a deploy path. Aptiq packages these decisions into a single template so a new product starts from a tested foundation instead of a blank repo — the auth flow, schema, and deployment topology are all wired before the first feature is written.

Architecture

How the system is structured

A pnpm monorepo with a backend app (Express REST API), a frontend app (React SPA), and shared packages for ESLint config, TypeScript config, and UI components. Docker Compose provisions PostgreSQL; the backend runs Prisma migrations and serves a versioned API under /api/v1.

Data Model

Schema design and data flow

Prisma schema for users and sessions supporting the JWT auth flow — registration, login, current-user, and refresh token rotation with bcrypt password hashing.

Key Challenges

Hardest problems encountered

The main challenge was keeping the template general enough to be useful yet concrete enough to be a real starting point — health/readiness endpoints, versioned API paths, and multiple deployment targets without coupling to a specific vendor.

Scaling Strategy

How the system grows

Stateless backend with PostgreSQL allows horizontal scaling from day one. Deployment configs for Render, Railway, and Fly.io each describe API + database topology, and Docker Compose provides a local production-equivalent environment.

Security

Defense-in-depth approach

JWT access tokens with refresh-token rotation, bcrypt hashing, and environment-scoped secrets. Health and readiness endpoints are separated from protected routes.

Failure Handling

Resilience and recovery

Graceful shutdown handling and readiness checks let orchestrators restart or drain the service without dropping traffic.

Observability

Monitoring and debugging

Health and readiness endpoints for load balancers and orchestrators, plus structured logging wired through the shared config package.

Trade-offs

Engineering decisions and alternatives

Express over Fastify for ubiquity and familiarity. React + Vite over Next.js for a lighter frontend that stays decoupled from the API. pnpm workspaces over a single package for clean separation.

Architecture Decisions

Key choices and what was rejected

Decision
Chosen
Rejected
Frontend
React + Vite SPA
Next.js (heavier for starter)
Monorepo
pnpm workspaces
Single package
Auth
JWT + refresh tokens
Session cookies

Senior-Level Topics

Concepts this project explores

SaaS Bootstrap ArchitectureJWT Refresh Token FlowMonorepo ToolingMulti-Target DeploymentHealth/Readiness Probes