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. Each component kept its position in beta because alpha testing produced concrete evidence that the current choice is correct — not merely adequate — and that the load, latency, and correctness characteristics of the system hold inside acceptable bounds. Specifically:

  • The dual-LLM analysis pipeline (Gemini + Groq with cross-checking) produced agreement between providers on the vast majority of conversations analyzed during alpha. The cases where providers disagreed were the cases most worth surfacing to an analyst, which validated the design intent of running both in "Both" mode rather than collapsing to a single provider for cost savings.
  • Vercel serverless functions completed every alpha analysis — including "Both" mode on the largest permitted input (5 MB JSON) running Gemini and Groq sequentially across all three categories — inside the 120-second function timeout with headroom. This ruled out the need to migrate analysis to a long-running worker or queue architecture for beta.
  • Neon connection pooling via the Prisma adapter absorbed concurrent uploads from multiple analysts during alpha testing without connection exhaustion or cold-start pool starvation, validating the pooled-adapter approach over a self-managed pool.
  • Live chat monitoring kept per-message Groq round-trip latency low enough that the customer-facing chatbot remained responsive with monitoring on the request path. This is important: if latency had been unacceptable, monitoring would have had to move off the request path into a background job, which would have delayed violation detection and broken the automatic-escalation flow. Alpha showed we can keep monitoring synchronous.
  • Resend + NextAuth + Vercel Blob each carried their expected traffic during alpha without operational issues or per-service limits being approached, confirming no need to self-host or replace any of the hosted dependencies for beta.

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

Taken together, the alpha evidence — latency inside the serverless budget, pool saturation not reached, synchronous monitoring viable, dual-provider disagreement concentrated on the cases worth surfacing, and zero Critical/High bugs remaining open — is what gave us confidence to ship the same topology into beta rather than re-architect. The next architectural decision points (queue-based analysis, provider fallback routing, self-hosted email) are deferred to GA, where the traffic profile will determine whether they are actually needed.