GenAI Capital: RAG Assistant
Senior AI Engineer Technical Assessment
A unified AI Orchestrator interfacing natively with Unstructured Macroeconomic PDFs & Structured Equity Data.
Architectural Design Patterns
We utilized a Hybrid RAG + Text-to-SQL Orchestrator built on top of a unified Supabase Dual-Database engine. Instead of provisioning separate SQL and Vector databases, we use Supabase to cleanly handle both workloads within the same PostgreSQL cluster (using pgvector).
- ■No LangChain:
The LLM orchestration, prompts, and math vectors are all written globally in native Python for maximum enterprise control.
- ■Safe Text-to-SQL:
Rather than generating arbitrary SQL string queries which are susceptible to Injection, the engine uses the LLM to strictly extract Entities and maps them via the native Supabase ORM.
Fulfillment of Core Requirements
| Requirement | Implementation Evidence |
|---|---|
| 1. Utilize Python | The entire backend parsing, embedding, and LLM Orchestration logic is built in Native Python (web/api/chat.py). |
| 2. Relational Database | Data sourced from equities.xlsx was loaded into a 3NF-compliant Supabase PostgreSQL instance. Safely queried bypassing SQL-Injection risks. |
| 3. Vector Database | Macro reports are semantically matched against user queries via Cosine Similarity powered by OpenAI and Supabase pgvector. |
| 4. NO LangChain / Wrappers | Zero orchestration libraries were used. Semantic routing, retrieval, and synthesis are executed programmatically via the raw OpenAI SDK. |
| 5. English Localization | All UI components, responses, and API System Prompts are strictly enforced in business-level English natively via systemic instruction overrides. |
| 6. User Interface (Bonus) | Elevated beyond a CLI script: Contains a Full-Stack modern Next.js 14 Application deployed via Vercel Edge Serverless Functions. |
Production & Security Roadmap
While this is a 48h MVP, it was uniquely structured on the Next.js+Supabase monolithic stack to allow immediate scale into production:
- Supabase Auth (JWT): The architecture is prepared to inject JWT Bearer Tokens from the frontend to the Python API, enabling isolated, secure user chat histories.
- Row Level Security (RLS): By migrating from Anon Keys to Authenticated Keys, Postgres RLS can govern which investor sees which equity data natively at the database layer.
Model Configuration & Hyperparameters
Vercel Serverless Build
This application strictly adheres to the Next.js Monorepo pattern. The React workspace encapsulates the Python API. When deployed to Vercel, the platform natively invokes `@vercel/python` to expose the backend logic securely over Edge functions.
Local Setup Commands
# Python Backend
python -m venv venv
pip install -r web/requirements.txt
uvicorn web.api.chat:app --reload
# Frontend React
cd web
npm install
npm run dev
Example Queries to Test
- [Vector Search] "What does the OECD report mention about global growth resilience?"
- [Relational SQL] "What is the target price and current status of Microsoft?"
- [Hybrid RAG] "What is the Target Price of Tesla and how does global inflation impact growth according to the OECD?"
- [Guardrail Fallback] "What is the target price of FakeCompany Ltd?" (Will trigger the "Data Not Available" security override).