Skip to main content

Architecture

This page describes the system topology for the Oversight beta release, including all major components, data flows, and external dependencies.

Architecture Diagram

System Topology


System Overview

Oversight is a full-stack Next.js application deployed on Vercel. The application uses the App Router for both the frontend pages and API routes, communicates with external LLM providers for analysis, and stores data in a PostgreSQL database hosted on Neon.

Core Components

ComponentTechnologyPurpose
FrontendNext.js 16 App Router, React 19, Tailwind CSS 4All user-facing pages (upload, dashboard, chat, monitor, trends, settings)
API LayerNext.js API Routes (serverless)18 API endpoints handling auth, uploads, chat, analysis, monitoring, settings
Core LogicTypeScript modules in lib/Analysis pipeline, live monitoring, chat reply generation, email alerts, rate limiting
DatabasePostgreSQL via NeonAll persistent data (users, uploads, analyses, chat sessions, settings)
ORMPrisma 7 with Neon adapterDatabase access with connection pooling
AuthenticationNextAuth.js v5 (beta)Email/password auth, JWT sessions, bcrypt password hashing
File StorageVercel BlobUploaded JSON conversation files
EmailResendAnalyst alert notifications

External LLM Providers

ProviderModelsUsed For
Google Geminigemini-2.5-flash, gemini-3.1-flash-lite (fallback)Hallucination, bias, and toxicity analysis in Gemini and Both modes
Groqopenai/gpt-oss-120b, Kimi K2 variants (fallback)Analysis in Groq and Both modes, live monitoring, chatbot reply generation

Data Flow

  1. File Upload Flow: User → Upload Page → POST /api/upload → Vercel Blob (file storage) → lib/run-analysis.ts → Gemini/Groq API → Analysis results → PostgreSQL
  2. Chat Flow: Customer → Chat Page → POST /api/chat → Groq (bot reply) → lib/live-monitor.ts → Groq (monitoring) → PostgreSQL (message + monitoring data)
  3. Alert Flow: Chat session completes → lib/run-analysis.ts (full analysis) → lib/send-alert-email.ts → Resend API → Analyst inbox

Database Schema

The database consists of 9 models:

ModelPurposeKey Relations
UserAnalyst accounts (email, password hash, name)Has many: Uploads, Feedbacks, GroundTruths; Has one: UserPreferences
UserPreferencesPer-user settings (default mode, alert email, bias threshold, T&C acceptance)Belongs to: User
UploadA conversation file upload or chat-sourced analysisBelongs to: User (optional), GroundTruth (optional); Has many: Analyses; Has one: ChatSession
AnalysisA single analysis result (e.g., hallucination-gemini)Belongs to: Upload
ChatSessionA live chatbot conversation sessionHas many: ChatMessages; Has one: Upload
ChatMessageA single message in a chat session (with optional monitoring data)Belongs to: ChatSession
GroundTruthA reference document for factual verificationBelongs to: User (optional); Has many: Uploads
FeedbackIn-app user feedback (bug/feature/general)Belongs to: User
RateLimitPer-user/IP rate limiting countersUnique on: (identifier, type)

Architecture Rationale

The system topology is unchanged since the alpha release. The same components — Next.js, Neon PostgreSQL, Vercel Blob, Google Gemini, Groq Llama, Resend, and NextAuth — remain in the same architectural positions. No components were added, removed, or re-positioned, and no new external services were introduced.

The alpha release served as a validation milestone for the full architecture. Through alpha testing, we confirmed that:

  • The dual-LLM analysis pipeline (Gemini + Groq with cross-checking) produces reliable detection results across all three categories
  • Vercel serverless functions handle the analysis workload within the 120-second timeout, including "Both" mode which runs providers sequentially
  • Neon connection pooling via the Prisma adapter handles concurrent database access without connection exhaustion
  • Live chat monitoring delivers real-time per-message checks with acceptable latency for the customer-facing chatbot

Alpha testing also helped us identify and document known issues. A formal bug severity audit classified all discovered bugs by severity (Critical, High, Medium, Low). The key finding was that zero Critical or High severity bugs remained open — all were either resolved or classified as Medium/Low with documented mitigations:

Bug IDSeverityDescriptionStatus
BUG-001MediumSimulated progress bar does not reflect actual backend progressDocumented; deferred to GA
BUG-002HighNo rate limiting on public chat APIResolved — enforces 5/min, 40/day per IP
BUG-003MediumSession completion endpoint lacks ownership checkMitigated by CUID non-enumerability
BUG-004LowChat-originated uploads have null userIdAccepted trade-off for internal analyst scope
BUG-005LowVercel Blob URLs are publicly accessible if knownAccepted; non-enumerable filenames

This validation gave us confidence that the architecture is sound for beta release without structural changes.