How virattt/ai-financial-agent works
Main Components
a) Frontend Layer:
• Client-side Components (under /components)
• Authentication UI (/app/(auth))
• Chat Interface (/app/(chat))
• Theme and UI Components (/components/ui)
b) Backend Layer:
• API Routes (/app/api)
• Authentication System
• Database Layer (using Drizzle ORM)
• AI Integration Layer (/lib/ai)
c) External Services:
• OpenAI API Integration
• Financial Datasets API
• Authentication Provider
• Database (PostgreSQL)
┌─ Client Layer ─────────────────────┐
• ┌─ UI Components ─┐ ┌─ Pages ────┐ │
• Chat │ │ - Login │ │
• Editor │ │ - Register │ │
• Documents │ │ - Chat │ │
• ┘ └────────────┘ │
• ┬────────────────────┘
┌──────────────▼────────────────────┐
• API Layer (/app/api) │
• ┌─────────────┐ ┌───────────────┐ │
• Auth Routes │ │ Chat Routes │ │
• Files API │ │ History API │ │
• ┘ └───────────────┘ │
• ┬────────────────────┘
┌──────────────▼────────────────────┐
• Service Layer │
• ┌─────────────┐ ┌───────────────┐ │
• AI SDK │ │ DB Queries │ │
• Middleware │ │ Auth Service │ │
• ┘ └───────────────┘ │
• ┬────────────────────┘
┌──────────────▼────────────────────┐
• External Services │
• ┌─────────────┐ ┌───────────────┐ │
• OpenAI API │ │ Financial │ │
• Auth Provider│ │ Datasets API │ │
• ┘ └───────────────┘ │
• ┘
Important Relationships to Highlight
• Data flow from Financial Datasets API through the backend to the frontend
• Authentication flow across all layers
• Database interactions for chat history and user data
Additional Elements
• Version information
• Notes about scalability points
• Potential future integration points
Technical Stack Indicators
• Next.js 13+ (App Router)
• Vercel AI SDK
• DrizzleORM
• PostgreSQL
• Tailwind CSS
• shadcn/ui components