Architecture
Architecture Overview
Technical architecture, Next.js 16 stack, PostgreSQL pgvector setup, and microservices design in OutRiskAI.
OutRiskAI is engineered as a high-performance web platform combining Next.js 16 (App Router), React 19, FastAPI microservices, and PostgreSQL with vector search capabilities.
OutRiskAI separates web rendering, background queue processing, and AI clause extraction into decoupled layers for maximum stability and scaling.
System Architecture Diagram
┌─────────────────────────────────────────────────────────────┐
│ Client Layer │
│ Web App (Next.js 16) • Public REST API Client │
└──────────────────────────────┬──────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Application Server │
│ • Next.js App Router API Routes │
│ • NextAuth.js v5 Auth Engine │
│ • Public API Middleware & Rate Limiter │
└──────────────┬───────────────────────────────┬──────────────┘
│ │
▼ ▼
┌──────────────────────────────┐┌─────────────────────────────┐
│ FastAPI Microservice ││ Data & Storage Layer │
│ • Text Extractor ││ • PostgreSQL 15 (pgvector) │
│ • Gemini 2.5-flash AI ││ • Prisma ORM │
│ • Clause Parsing Pipeline ││ • Object Storage (S3 / DO) │
└──────────────────────────────┘└─────────────────────────────┘Technology Stack
| Layer | Technology | Details |
|---|---|---|
| Frontend UI | Next.js 16.4 / React 19 | App Router, Server Components, Tailwind CSS, Framer Motion |
| API Server | Node.js 20+ / Next.js | TypeScript REST API, Zod schema validation |
| Contracts Engine | Python FastAPI | Document text parsing, semantic chunking |
| AI Processing | Google Gemini 2.5-flash | Contract summary, risk extraction, solution generation |
| Database | PostgreSQL 15+ | Relational data + pgvector for vector embeddings |
| Object Storage | DigitalOcean Spaces / S3 | Encrypted PDF document binary storage |
Security Architecture
- Transport Layer: All connections require TLS 1.3 encryption.
- Data Encryption at Rest: PDF files are encrypted with AES-256 before storage.
- Database Security: Tenant isolation enforced at the query level via
userIdscoping. - API Key Safeguards: Only SHA-256 hashes of API key secrets are saved in the database.