Skip to main content

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:

AppSchemaDatabase
Statux Pagesstatuspagesstatux
Statux Alertsalertsstatux
Statux Syntheticssyntheticsstatux
Statux Insightsinsightsstatux
Statux Platformcorestatux

Shared entities (Organization, Subscription, OrgProductRole) use the core schema.

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.