DocumentationAPI Reference
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

LayerTechnologyDetails
Frontend UINext.js 16.4 / React 19App Router, Server Components, Tailwind CSS, Framer Motion
API ServerNode.js 20+ / Next.jsTypeScript REST API, Zod schema validation
Contracts EnginePython FastAPIDocument text parsing, semantic chunking
AI ProcessingGoogle Gemini 2.5-flashContract summary, risk extraction, solution generation
DatabasePostgreSQL 15+Relational data + pgvector for vector embeddings
Object StorageDigitalOcean Spaces / S3Encrypted PDF document binary storage

Security Architecture

  1. Transport Layer: All connections require TLS 1.3 encryption.
  2. Data Encryption at Rest: PDF files are encrypted with AES-256 before storage.
  3. Database Security: Tenant isolation enforced at the query level via userId scoping.
  4. API Key Safeguards: Only SHA-256 hashes of API key secrets are saved in the database.

Next Steps

On this page