Skip to main content

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:

AppSchemaNotes
DivinuxdivinuxAbsorbed the statuspages, alerts, and synthetics schemas in Phase D.5 (April 2026). Some legacy alerts.* tables persist. Also performs cross-schema reads.
Platformcore / situationsOrganizations, 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

  • ApiResponse interface and ResponseInterceptor
  • PaginationQueryDto for list endpoints
  • HttpExceptionFilter for error handling (reports 500+ errors to Sentry)
  • EncryptionService for AES-256-GCM encryption
  • initSentry() / captureException() for error tracking
  • loadSecretsConfig() config loader (AWS Secrets Manager)

@app/auth

  • JwtStrategy for Cognito JWT validation (cookie-first, Bearer fallback)
  • JwtAuthGuard, OrgAccessGuard, OrgRolesGuard, OrgProductAccessGuard, ScimAuthGuard
  • CookieAuthService / AuthCookieController for httpOnly cookie auth
  • @CurrentUser(), @CurrentOrg(), @Public(), @ProductAccess() decorators

@app/database

  • BaseEntity with id, createdAt, updatedAt
  • Shared entities: Organization, OrganizationMember, OrgProductRole, OrgProductSubscription, User, Subscription, ScimToken, AnalyticsEvent, UserActivity
  • Product enum (standalone product.enum.ts)
  • DatabaseModule.forRoot() configuration

@app/email

  • EmailService with sendText() and sendHtml() via AWS SES (SESv2)
  • escapeHtml() for XSS prevention in HTML templates
  • sanitizeFromName() for email From header sanitization

@app/billing

  • BillingService for Stripe integration (checkout, portal, webhooks)
  • CreateCheckoutDto for checkout session creation

See Shared Libraries for detailed usage.