System Architecture
Inspect Africa Pro is a multi-tenant SaaS platform built for EASA-compliant aviation MRO operations. Every layer enforces tenant isolation via company_id.
Technology Stack
| Layer | Technology | Notes |
|---|---|---|
| Frontend | Next.js App Router + React 19 | Server Components by default; Client Components where interactivity is required |
| Styling | Tailwind CSS + TypeScript | Strict mode, no implicit returns |
| API | Next.js Route Handlers | All under /api/aviation/ and /api/auth/ |
| Database | Supabase (PostgreSQL 15) | Row-Level Security on every table; service-role key server-side only |
| Auth | Supabase Auth | Email + password with Turnstile CAPTCHA; Google OAuth; 30-min OTP expiry |
| AI | Claude (Anthropic) | Via @/lib/ai/gateway; tier-gated -- rule-based fallback on free plan |
| Billing | Paddle | Stripe planned as secondary provider |
| Deployment | Vercel (Edge + Serverless) | Rate limiting is Supabase-backed to handle stateless instances |
| Observability | OpenTelemetry | Traces for all Route Handler calls |
Multi-Tenancy Model
Every database table has a company_id column with a Row-Level Security policy that restricts reads and writes to the authenticated tenant. API routes call requireTenant() or requirePermission(scope) before touching the database. The service-role key (which bypasses RLS) is only used server-side and is never exposed to the client.
// Every API route follows this pattern:
const tenant = await requirePermission('aviation:read')
const db = createSupabaseAdmin()
db.from('aircraft').select('...').eq('company_id', tenant.companyId)
Aviation Domain Modules
Reliability Programme
FH/cycle tracking, dispatch reliability, IATA delay codes, ATA trend analysis -- EASA Part-M.A.302
MEL/CDL Management
Deferral tracking with CAT A/B/C expiry, dispatch gate enforcement
Predictive AOG Avoidance
Weighted probability model: defect history, engine life, MEL status, FDM events, parts stock
AI Anomaly Detection
Recurring ATA pattern detection, CAT A MEL alerts, delay rate spikes -- Claude AI on paid tier
Work Order Management
Full lifecycle with task card steps, technician sign-off, labour hour tracking
AMP Workflow
Aircraft Maintenance Programme: draft → review → approved → superseded with audit trail
Approval Engine
Multi-stage sign-offs for NCR, CA, WO, dispatch, AMP with EASA Part-145.A.65 compliance
Stores & Spares
Real-time inventory, AOG-stock flags, demand forecasting, movement ledger
Airspace Authorisations
RVSM, RNP-AR, ETOPS-120/180, LVO CAT II/III tracking with expiry alerts
Request Lifecycle
- Browser sends request with Supabase JWT in
Authorizationheader rateLimitDB(ip, scope)checks Supabase-backed rate limit table -- fails closed on outage for auth-scoped routesrequirePermission(scope)validates JWT, extractscompanyId, checks RBAC role- Route Handler queries Supabase via service-role client with explicit
.eq('company_id', tenant.companyId) - RLS on Supabase provides a second layer of tenant isolation
- All mutations emit an
audit_logsrow with actor, action, and before/after metadata