Production-ready chat-first RAG application for document Q&A.
Document Analyzer lets users:
- Sign in with Firebase social auth (Google or GitHub)
- Upload PDF documents
- Wait for indexing to complete
- Chat with grounded, document-based answers
Frontend and backend are deployed separately:
- Frontend:
https://docanalyzer.app - Backend API:
https://api.docanalyzer.app
- Firebase social login (Google + GitHub)
- Backend-owned JWT cookie sessions
- Chat-first workflow with streaming responses (SSE)
- Document upload, processing, indexing, and chat attachment flow
- RAG pipeline with retrieval safeguards and graceful fallback behavior
- Daily usage quota and infrastructure limits endpoint
- Strict CORS policy and layered rate limiting
- Frontend: Next.js, React, TypeScript, Tailwind CSS, Framer Motion, Firebase Web SDK
- Backend: Node.js, Express, Firebase Admin SDK
- Database: PostgreSQL (Supabase)
- Storage: Supabase Storage
- AI: Google Gemini
- Deploy: Vercel (frontend), Render (backend)
.
├── frontend/ # Next.js app
├── src/ # Express API
├── database/schema.sql # Database schema bootstrap
├── render.yaml # Render blueprint
├── BACKEND_DOCS.md # API contract documentation
└── ARCHITECTURE.md # System architecture and flows
Architecture visuals currently included:
- System architecture:
docs/architecture.svg - RAG flow:
docs/rag-architecture.svg
- Only Firebase social providers are supported:
- GitHub
- Backend auth exchange endpoint remains:
POST /api/v1/auth/google
- Legacy email/password/OTP auth is removed from active flows.
npm install
cd frontend && npm installIn Firebase Console:
- Create/select project
- Enable Auth providers:
- GitHub
- Create a Web App and copy client config values
- Create a Service Account for backend and copy:
- project ID
- client email
- private key
Backend:
cp .env.example .envFrontend:
cd frontend
cp .env.example .env.localDATABASE_URLSUPABASE_URLSUPABASE_SERVICE_KEYGEMINI_API_KEYJWT_SECRETFIREBASE_PROJECT_IDFIREBASE_CLIENT_EMAILFIREBASE_PRIVATE_KEY
NEXT_PUBLIC_API_URLNEXT_PUBLIC_FIREBASE_API_KEYNEXT_PUBLIC_FIREBASE_AUTH_DOMAINNEXT_PUBLIC_FIREBASE_PROJECT_IDNEXT_PUBLIC_FIREBASE_APP_ID
npm run db:schemaBackend:
npm run devFrontend:
cd frontend
npm run dev- Connect repository to Render
- Use blueprint file:
render.yaml - Set
sync: falsesecrets in Render dashboard - Confirm health endpoint:
GET https://api.docanalyzer.app/api/v1/health/live
- Import
frontend/as project root - Set production env vars (
NEXT_PUBLIC_*) - Set
NEXT_PUBLIC_API_URL=https://api.docanalyzer.app - Deploy and validate auth + chat flows
- Strict CORS allowlist for
docanalyzer.appdomains - Global rate limit + route-specific auth/chat/upload limiters
- Standard API response envelope:
- success:
{ ok: true, data: ... } - error:
{ ok: false, error: { code, message, details? } }
- success:
- Firebase Admin env validation at boot
- No JSON service account file dependency in backend runtime
npm test
npm run frontend:test
npm run frontend:lint
npm run frontend:build- Backend contract:
BACKEND_DOCS.md - System architecture:
ARCHITECTURE.md - Deployment checklist:
DEPLOYMENT_CHECKLIST.md