API Architecture
The statux-api/ repository is a NestJS monorepo containing five applications and four shared libraries.
Monorepo Structure
statux-api/
├── apps/
│ ├── statuspages/ # Port 3000, statuspage-api.statux.io
│ ├── alerting/ # Port 3001, alerts-api.statux.io
│ ├── synthetics/ # Port 3002, synthetics-api.statux.io
│ ├── insights/ # Port 3003, insights-api.statux.io
│ └── platform/ # Port 3004, platform-api.statux.io
├── libs/
│ ├── common/ # @app/common
│ ├── auth/ # @app/auth
│ ├── database/ # @app/database
│ ├── email/ # @app/email
│ └── billing/ # @app/billing
├── package.json # Root dependencies
└── nest-cli.json # Monorepo config
Database Schemas
Each application uses a separate PostgreSQL schema:
| App | Schema | Database |
|---|---|---|
| Statux Pages | statuspages | statux |
| Statux Alerts | alerts | statux |
| Statux Synthetics | synthetics | statux |
| Statux Insights | insights | statux |
| Statux Platform | core | statux |
Shared entities (Organization, Subscription, OrgProductRole) use the core schema.
Shared Libraries
@app/common
ApiResponseinterface andResponseInterceptorPaginationQueryDtofor list endpointsHttpExceptionFilterfor error handling (reports 500+ errors to Sentry)EncryptionServicefor AES-256-GCM encryptioninitSentry()/captureException()for error trackingloadSecretsConfig()config loader (AWS Secrets Manager)
@app/auth
JwtStrategyfor Cognito JWT validation (cookie-first, Bearer fallback)JwtAuthGuard,OrgAccessGuard,OrgRolesGuard,OrgProductAccessGuard,ScimAuthGuardCookieAuthService/AuthCookieControllerfor httpOnly cookie auth@CurrentUser(),@CurrentOrg(),@Public(),@ProductAccess()decorators
@app/database
BaseEntitywith id, createdAt, updatedAt- Shared entities: Organization, OrganizationMember, OrgProductRole, OrgProductSubscription, User, Subscription, ScimToken, AnalyticsEvent, UserActivity
Productenum (standaloneproduct.enum.ts)DatabaseModule.forRoot()configuration
@app/email
EmailServicewithsendText()andsendHtml()via AWS SES (SESv2)escapeHtml()for XSS prevention in HTML templatessanitizeFromName()for email From header sanitization
@app/billing
BillingServicefor Stripe integration (checkout, portal, webhooks)CreateCheckoutDtofor checkout session creation
See Shared Libraries for detailed usage.