Production Roadmap
Phased NestJS backend spine and product build plan.
Purpose: This document defines how we build Starter from the clean
apps/nest-apiNestJS app onward. It summarizes the universal starter kit vision, product philosophy, backend/frontend/AI architecture, and the production roadmap for multi-tenant applications.
1. Project Vision
Starter is not another generic CRUD scaffold, digital form, or empty dashboard.
Starter is an AI-native, policy-native, workflow-native platform and starter kit for modern multi-tenant applications.
Traditional boilerplate software usually does this:
User enters data
System stores data
User checks dashboard manually
User takes action manuallyStarter does this:
System understands workspace and tenant state
System detects anomalies, pending tasks, and policy violations
System creates guided tasks and reminders
AI drafts or assists the next action
Policy engine verifies allowed operations and quotas
Human approval is required for sensitive operations
System executes approved workflow
Audit log records everythingThe long-term vision is a universal baseline for any SaaS or platform project—empowering developers to launch secure, compliant, multi-tenant products without reinventing the spine.
Build focus:
Start with Starter.
Build cleanly.
One production-quality vertical slice at a time.2. Current Starting Point
The monorepo already exists and uses:
Bun workspaces
Turborepo
Next.js web app (apps/web)
Expo mobile app (apps/mobile)
NestJS API app (apps/nest-api)
Rust service (apps/rust)
Docs app (apps/docs)
Shared packages (@starter/ui, @starter/logger, @starter/typescript-config)
CI/CD, Docker, security workflows, dev container, git hooksThe backend production spine centers on:
apps/nest-apiWe start the NestJS backend clean, modular, and strictly typed.
3. Technical Decisions
Runtime and Tooling
Package manager: Bun
Workspace orchestration: Turborepo
Main backend framework: NestJS
Production backend runtime: Node-compatible Nest build
Database: PostgreSQL
ORM/query layer: Drizzle ORM
Validation: Zod
API style first: REST
Frontend: Next.js
Mobile: Expo / React Native
Performance service: Rust (apps/rust)
Docs: FumadocsBun handles fast local development and monorepo tasks. NestJS provides the enterprise spine: dependency injection, guards, interceptors, queues, WebSockets, auth, testing, and modular separation.
Drizzle is TypeScript-first, lightweight, SQL-friendly, and optimal for PostgreSQL multi-tenancy.
4. Core Product Philosophy
Everything we build follows this principle:
Do not make operators, users, or admins do repetitive manual work.
Use software to automate routine operations, guide decisions, and execute safe workflows.Starter must be:
AI-native
workflow-native
policy-native
task-first
privacy-first
audit-heavy
operator-first
tenant-safe
integration-ready5. What Makes Starter Different
A standard CRUD app stores records:
users
workspaces
memberships
resources
invoices
reportsStarter adds operational intelligence:
policies
workflows
tasks
approvals
AI assistance
anomaly detection
audit logs
notifications
webhooksOne-line positioning:
Starter turns product operations from manual data entry into guided, automated, policy-safe workflows.6. Main Engines
These engines form the foundation of Starter. Feature modules plug directly into these engines.
6.1 Workflow Engine
Manages multi-step processes across workspaces.
Examples:
user onboarding workflow
access escalation workflow
resource provisioning workflow
billing downgrade remediation workflow
data export and cleanup workflowA workflow has:
definition
run
steps
owner
status
deadline
approval
escalation
audit events6.2 Policy Engine
Turns business and security rules into executable logic.
Examples:
If workspace quota exceeds 90% → create upgrade task
If member inactive for 90 days → trigger security review
If two-factor auth disabled on admin role → block access to production
If sensitive export requested → require second admin approval6.3 Task Engine
Every actionable item becomes a trackable task.
Examples:
Review pending invite
Verify account credentials
Rotate API credentials
Resolve billing dispute
Review elevated access request6.4 Notification Engine
Handles communication across channels:
in-app notifications
transactional email (Resend)
webhook dispatches
push notifications (Expo)6.5 AI Orchestration Engine
AI assists human decisions rather than acting autonomously on sensitive state:
AI reads allowed context
AI proposes action or draft
Policy engine checks proposal
Permission engine checks authorization
Human approval occurs if required
Backend executes command
Audit log records everything6.6 Document and Data Intelligence Engine
Used for data intake and ingestion:
file parsing and extraction
schema validation
document classification
form prefill
human verification6.7 Integration Engine
Handles external services cleanly:
email provider (Resend)
payment gateways (Stripe / Razorpay)
object storage (S3 / Cloudflare R2)
webhook deliveries
OAuth providers (Google, GitHub)6.8 Audit and Governance Engine
Every state-changing action is traceable:
who performed it (actor ID, role, session)
when (ISO timestamp)
which organization / workspace
what changed (structured diff)
why (reason, task ID, or policy)
from which IP / device / user-agent
whether AI was involved
whether human approval was given7. Product Modules
Core Records
Organizations
Workspaces
Users
Profiles
Memberships
Roles
Permissions
Invitations
API KeysPlatform Operations
Tasks
Workflows
Policies
Audit Logs
Webhooks
Subscriptions & Invoices
NotificationsIntelligence
Usage anomaly detection
Quota and capacity forecasting
Operator cockpit
AI summaries
AI action draftsGovernance
Immutable audit logs
Data retention policies
Tenant isolation
Security policies
Passkeys / WebAuthn
MFA / TOTP factors8. Backend Architecture Direction
The backend lives in:
apps/nest-apiDirectory structure:
apps/nest-api/src/
main.ts
app.module.ts
app.setup.ts
common/
filters/
interceptors/
middleware/
pipes/
types/
config/
app-config.service.ts
app.config.ts
config.module.ts
env.schema.ts
database/
database.module.ts
database.service.ts
migrate.ts
schema/
index.ts
users.schema.ts
user-profiles.schema.ts
sessions.schema.ts
subscriptions.schema.ts
passkeys.schema.ts
totp-factors.schema.ts
auth-identities.schema.ts
modules/
health/
auth/
users/
profiles/
billing/
mfa/
passkeys/
social-auth/
email/
ai/
organizations/ # next phase
workspaces/ # next phase
tasks/ # next phase
policies/ # next phase
workflows/ # next phase9. Backend Engineering Rules
- Explicit Module Boundaries: Controllers handle HTTP routing; services handle business logic; repositories handle data access.
- Strict Zod Validation: All DTOs are validated with Zod via
ZodValidationPipe. - Tenant Isolation: Every query involving tenant data must filter by
organizationIdandworkspaceId. - No Direct Secret Exposure: Secrets never leak in API responses, logs, or client configs.
- Idempotency: Webhook handlers and critical mutations accept idempotency keys.
10. Phased Roadmap
Phase 0 — Clean Base Architecture & Health Checks (Completed)
- Clean NestJS baseline with structured modules
- Request ID middleware and global HTTP exception filter
- Health check endpoints (
/api/v1/health)
Phase 1 — Database Connection and Migrations (Completed)
- PostgreSQL database module with connection pooling
- Drizzle ORM schema and migration tooling
- Auth, users, profiles, and sessions schemas
Phase 2 — Organization and Workspace Slice
OrganizationsModuleandWorkspacesModule- CRUD for organizations and workspaces
- Workspace slug uniqueness and status lifecycle
Phase 3 — Auth, Sessions, and Security (Completed)
- Password hashing (Argon2id)
- JWT access tokens and secure HTTP-only refresh cookies
- Multi-factor authentication (TOTP) and Passkeys (WebAuthn)
- Social auth (OAuth) and magic link login
Phase 4 — Roles, Memberships, and Permissions
- RBAC and ABAC guardrails
- Role assignments per workspace
- Fine-grained permission decorators
Phase 5 — Team Members & Invitations
- Workspace member invitation flows
- Accept/reject invite with token verification
- Member status lifecycle (active, pending, suspended)
Phase 6 — Billing & Subscriptions (Completed)
- Stripe and Razorpay payment provider integrations
- Subscription checkout sessions and portal redirects
- Webhook signature verification and entitlement updates
Phase 7 — Audit Logs & Security Trails
- Immutable audit log table and service
- Interceptor for automatic audit recording on mutating endpoints
- Structured diff logging and IP/user-agent capture
Phase 8 — Task & Remediation Engine
- Task creation, assignment, and status transitions
- Due dates, priority levels, and notification triggers
- Automated task creation from system events
Phase 9 — Policy & Guardrails Engine
- Policy definitions stored as structured rules
- Policy evaluation middleware on critical actions
- Human-in-the-loop approval triggers
Phase 10 — Workflow Engine
- Multi-step state machine runner
- Step execution with timeout and retry capabilities
- Execution history with full audit trail
Phase 11 — AI Assist Integration (Removed)
- The NestJS AI proxy was removed together with the separate AI service it called
- Prompt orchestration with role, context, and guardrails is open for a future implementation
Phase 12 — Web Admin Console Integration (Completed)
- Modern Next.js admin dashboard
- Operational pulse strip, growth metrics, and member management
- Responsive sidebar, command search, and profile settings
Phase 13 — Mobile App Integration (Completed)
- Expo Router mobile app with Uniwind styling
- Shared auth, profile, and navigation patterns
- Safe area compliance and mobile-first ergonomics
Phase 14 — Observability & Production Hardening
- Docker Compose local stack and multi-stage container builds
- Render / Vercel deployment blueprints
- Rate limiting, CSRF protection, and security headers