System Architecture

Decoupled Architecture

The application is built using a modern, scalable, and decoupled architecture. The frontend is fully isolated from the heavy AI orchestration, communicating gracefully via a REST API.

Frontend

  • Next.js 14 (App Router)
  • React Server Components
  • Tailwind CSS & Lucide Icons
  • Vercel Edge Deployment

API Gateway

  • Python 3 & FastAPI
  • Uvicorn ASGI Server
  • Hybrid RAG Orchestrator
  • Serverless Execution ready

Infrastructure Layer (Dual Database)

Supabase elegantly fulfills the requirement of having both a Relational PostgreSQL Database and a Vector Database within the same unified engine via the pgvector extension.

Relational PostgreSQL (3NF)

Architectural Note: While the current MVP securely ingests the raw CSV directly as a flat table for rapid prototyping, the target Production Schema (below) normalizes the structured data into the 3rd Normal Form (3NF) to eliminate data redundancy (e.g., Sector and Country mappings).

sectors
PK idINT
nameVARCHAR
countries
PK idINT
nameVARCHAR
equities
PK idINT
tickerVARCHAR
FK sector_idINT
FK country_idINT
stock_priceNUMERIC

Vector Database (pgvector)

Unstructured PDF knowledge is chunked and stored in a mathematical vector space alongside the relational data.

documents (Vector Store)
PK idBIGINT
contentTEXT
embeddingVECTOR(1536)

OpenAI Models

  • gpt-4o-mini (Orchestration & Synthesis)
  • text-embedding-3-small (Vectorization)