AI-powered full-stack application that analyzes financial PDF documents and produces structured, evidence-based financial, investment, and risk insights.
- Frontend: React + Vite (
client/) - Backend: FastAPI + CrewAI + Groq LLM (
server/) - Input: financial PDF + user query
- Output: consolidated analysis report from a multi-agent workflow
client/ Frontend app and API client
server/ FastAPI API, CrewAI agents/tasks/tools
README.md Main documentation
- API routing mismatch between dev/prod
- Symptom: frontend calls failed depending on environment.
- Cause: API URL construction was not robust for proxy and deployed backends.
- Fix: improved
client/src/services/api.jsto:- use
VITE_API_BASE_URLwhen provided, - use same-origin
/analyzein Vite dev, - fallback to local backend for production preview.
- use
- CORS failures when frontend/backend ran on different hosts
- Symptom: browser blocked
/analyzerequests. - Cause: strict origin handling.
- Fix: backend CORS now supports configured
ALLOWED_ORIGINSand regex-based local origins.
- CrewAI/Groq rate-limit failures
- Symptom:
RateLimitErrorand unstable pipeline runs. - Cause: multi-step calls and repeated document reads increased RPM/TPM pressure.
- Fix:
- centralized crew limiter (
max_rpm), - retry-after parsing + delayed retry,
- compact PDF extraction with
PDF_CHAR_LIMIT, - reduced redundant tool usage in downstream tasks.
- centralized crew limiter (
- File-processing instability (
Stream ended unexpectedly)
- Symptom: intermittent backend errors after upload.
- Cause: aggressive file cleanup timing.
- Fix: removed immediate delete-on-finally behavior and stabilized processing flow.
- UX quality issues during long runs
- Symptom: generic loading feedback and inconsistent form visuals.
- Fix:
- process-aware loader with active agent + stage status,
- elapsed timer during analysis,
- consistent input styling for disabled/readonly state.
- Python 3.10+
- Node.js 18+ (Node 20 recommended)
- Groq API key
cd server
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txtCreate server/.env from server/.env.example:
GROQ_API_KEY=your_groq_api_key
SERPER_API_KEY=
DEFAULT_QUERY=Analyze this financial document for investment insights
DATA_DIR=data
API_RELOAD=true
ALLOWED_ORIGINS=http://localhost:5173,http://127.0.0.1:5173
ALLOWED_ORIGIN_REGEX=^https?://(localhost|127\.0\.0\.1)(:\\d+)?$
PDF_CHAR_LIMIT=9000Run backend:
uvicorn main:app --host 127.0.0.1 --port 8000 --reloadcd ..\client
npm installCreate client/.env from client/.env.example:
VITE_API_BASE_URL=
VITE_API_ANALYZE_PATH=/analyzeRun frontend:
npm run devOpen http://localhost:5173.
- Open the app in browser.
- Upload a financial PDF.
- Enter or keep the default analysis query.
- Click the run button.
- Monitor active agent and stage progress.
- Review structured analysis output.
Base URL (local): http://127.0.0.1:8000
Health endpoint.
Response:
{"message":"Financial Document Analyzer API is running"}Analyzes an uploaded PDF using CrewAI workflow.
Request type:
multipart/form-data
Form fields:
file(required): PDF filequery(optional): analysis instruction string
Success response (200):
{
"status": "success",
"query": "Analyze this financial document for investment insights",
"analysis": "...agent output...",
"file_processed": "your_file.pdf"
}Error response (500):
{
"detail": "Error processing document: <message>"
}$filePath = "C:\path\to\document.pdf"
$query = "Analyze growth, profitability, risks, and investment implications"
Invoke-RestMethod -Uri "http://127.0.0.1:8000/analyze" `
-Method Post `
-Form @{ file = Get-Item $filePath; query = $query }- Backend can be hosted on Render.
- Frontend can be hosted on Netlify.
- Current live frontend: https://financial-document-analyser.netlify.app/
- For production frontend, set:
VITE_API_BASE_URL=https://<your-backend>.onrender.comVITE_API_ANALYZE_PATH=/analyze
- Update backend
ALLOWED_ORIGINSto include deployed frontend URL.
- Never commit real API keys to git.
- Keep
.envfiles local and use platform environment variables in production. - Rotate exposed keys immediately if leaked.