API Architecture
The statux-api/ repository is a NestJS monorepo containing two applications and a set of shared libraries.
Monorepo Structure
statux-api/
├── apps/
│ ├── divinux/ # Port 3003, divinux-api.statux.io.
│ │ # Alerting + synthetics + statuspages + insights surfaces.
│ │ # Formerly apps/insights/ (renamed in Phase C).
│ └── platform/ # Port 3004, platform-api.statux.io. Orgs, members, situations.
├── libs/
│ ├── common/ # @app/common — pagination, responses, filters, crypto, Sentry, config
│ ├── auth/ # @app/auth — JWT strategy, guards, decorators, cookie auth
│ ├── database/ # @app/database — BaseEntity, shared entities
│ ├── email/ # @app/email — AWS SES email service
│ └── billing/ # @app/billing — Stripe integration
├── package.json # Root dependencies
└── nest-cli.json # Monorepo config
Folded apps
The former per-product apps — apps/statuspages/ (3000), apps/alerting/ (3001), apps/synthetics/ (3002) — were folded into apps/divinux/ (Phases C5/D5/E5, May 2026) and deleted from the repo on 2026-06-11. Their API hosts are NXDOMAIN; the capabilities live on inside Divinux as feature modules.
Database Schemas
The two apps use these PostgreSQL schemas in the shared statux database:
| App | Schema | Notes |
|---|---|---|
| Divinux | divinux | Absorbed the statuspages, alerts, and synthetics schemas in Phase D.5 (April 2026). Some legacy alerts.* tables persist. Also performs cross-schema reads. |
| Platform | core / situations | Organizations, members, subscriptions, product roles, SCIM tokens, analytics (core); incident coordination (situations). |
Shared entities (Organization, Subscription, OrganizationMember) use the core schema and live in @app/database.
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.