Video summary
Build a Full-Stack GenAI Project in 4 Hours (FastAPI, React, Supabase)
Main summary
Key takeaways
Overview
This video is an end-to-end “speedrun” (claimed ~4–5 hours) to build a full-stack GenAI document copilot for a hypothetical investment research firm (“Driftwood Capital”). The app lets authenticated analysts ask plain-English questions over a corpus of SEC filings and returns grounded, source-cited answers (with citations tied back to specific documents/pages/chunks). The UI can also show sources in a side panel.
What the project builds (product + core GenAI behavior)
Goal / client brief
- Create an internal browser-based chatbot (“document co-pilot”).
- Answers must be trustworthy:
- no hallucinations
- responses require citations
- responses should be fact-checkable back to stored filing content
- No trading recommendations: only use data ingested into the system.
- Scope excludes multi-tenant billing/paywalls/mobile apps.
- “Definition of done”:
- a pilot group of analysts can use it
- it saves ~3 hours/week
Data domain
- Download and ingest SEC filings (from the SEC via API tooling) for:
- Apple
- Microsoft
- Nvidia
- Amazon
- Downloads cover multiple years (targeting the last five years).
Grounded QA pipeline (RAG + orchestration + trust enforcement)
- Uses RAG with:
- Vector retrieval (embeddings stored in Postgres via PGVector/PGF in Supabase)
- Keyword / full-text retrieval (Postgres full-text search)
- Hybrid fusion using Reciprocal Rank Fusion (RRF)
- Retrieves top chunks and can hydrate with neighboring chunks (agentic “read around” behavior).
- An LLM agent orchestrates tool use in a loop until it decides it has enough evidence.
- A validator / “trust contract” enforces citation correctness:
- rejects claims/chunks not actually retrieved
- requires citations to match retrieved passages
Technologies / stack described
Codebase organization
- Monorepo: backend + frontend in one Git repository
- helps coding agents reason across the full context.
Backend
- Python + FastAPI (API layer)
- Pydantic settings for environment variable configuration/validation
- SQLAlchemy for defining data models
- Alembic for migrations
- Postgres via Supabase
- OpenAI for:
- embedding generation
- LLM reasoning/agent steps
Retrieval + RAG tooling
- Retrieval pipeline built with PydanticAI (agent framework + tool orchestration)
- Embeddings stored as vector columns in Supabase/PG
- Hybrid retrieval includes:
- semantic search (vector)
- keyword search (full-text)
- fusion (RRF)
Document parsing / ingestion
- Initial HTML/HTM ingestion converted to Markdown using Docling
- Later improvement:
- added an HTML table extractor
- because Docling table formatting was “fragile”/messy
Frontend
- React + TypeScript
- Styling with Tailwind CSS
- UI components via shadcn/ui
- Chat UI component approach:
- mentions adopting PromptKit/AI SDK components
- adds richer UX: “chat + citations + loading state”
Deployment
- Database stays on Supabase
- App deployed with Railway (Docker-based deployment for backend + frontend)
- Railway guide + deployment diffs were iterated after failures.
Key “tutorial” / build-guide elements emphasized
-
Repo branching strategy
- Start with an “almost empty” main branch.
- Use development branch for the completed target result.
-
Architecture documentation-first
- Includes an architecture diagram/doc and agents.md injected into prompts.
- Used to keep the agent aligned with system rules and engineering decisions.
-
High-level project phases with checklists
- Repeated use of:
to-dos.mdphase plans- incremental scaffolding, testing, and checkpointing
- Repeated use of:
-
Backend scaffolding before AI features
- Phase 0/1:
- create config
- FastAPI entrypoint
- health endpoint
- database models and migrations
- Uses Alembic migrations to “sync schema from code.”
- Phase 0/1:
-
Authentication via Supabase
- Uses Supabase authentication:
- browser login
- secure row-level security policies
- For early development:
- disables confirmation / new user signups
- manually creates a user for testing
- Uses Supabase authentication:
-
Document ingestion pipeline
- Batch conversion:
- HTM → Markdown via docling
- preserves a folder structure by year + a manifest.json
- Upload to database:
- load markdown into a
source documentstable
- load markdown into a
- Chunking + embeddings:
- hierarchical/hybrid chunking strategy
- chunk records include text + embeddings + metadata
- Cost control:
- embeddings are expensive
- tests with one chunk/file before full runs
- Batch conversion:
-
Retrieval pipeline
- Phase 5 retrieval:
- hybrid retrieval (semantic + full-text)
- rank fusion with RRF
- top-K selection
- hydration with metadata + neighbor chunks
- Phase 6 grounding agent:
- agentic tool loop:
- search → retrieve chunks → possibly read neighbors → synthesize → validate citations
- agentic tool loop:
- Phase 5 retrieval:
-
Full-text search keyword extraction problem
- Naive full-text search using the entire user query performs poorly.
- Plans to add an LLM step to extract 3–5 keyword terms for better matching.
- Mentions possible filler-word removal (considers NLTK stopwords).
-
Trustworthiness / citation formatting
- “Trust contract” validator ensures citations correspond to retrieved chunks.
- Frontend improvements:
- render Markdown tables correctly
- show sources in a side panel
- allow clicking citations
-
Deployment troubleshooting
- Uses Railway Docker setup:
- frontend Dockerfile + backend Dockerfile + Caddy exposure
- Notes an issue:
- docling added accidentally as a heavy dependency
- should be in dev/optional dependencies to avoid resource issues
- Uses Railway Docker setup:
Specific engineering decisions & improvements highlighted
- Monorepo for better coding-agent context.
- agents.md guides:
- repository-level behavior
- per-folder backend/frontend rules
- Dependency hardening
- uses “minimum release age” guardrails (avoid very new npm packages).
- Database modeling
- includes:
- users (conceptually mapped to auth users)
- source documents
- document chunks
- chat threads + messages
- message citations table (to enforce grounding)
- includes:
- Table extraction fix (important)
- Dockling table parsing was messy
- replaced/enhanced with a dedicated HTML table extractor
- chunks were re-ingested
- UI later shows properly rendered Markdown tables based on extracted JSON/table data
Main speakers / sources (as inferred from subtitles)
- Primary speaker: “Dave”
- creator/host; Glido link uses
get.glido.com/dave
- creator/host; Glido link uses
- Tool/library systems referenced (as technologies):
- Supabase, FastAPI, PydanticAI, Docling, Railway, OpenAI, SQLAlchemy, Alembic, Tailwind CSS, shadcn/ui