How soumya9679/codeflow2026-neural-nexus-cortex-finance works
1. Repository shape
- This is a monorepo with three client surfaces and one shared backend: a React web app, a React Native/Expo mobile app, and a FastAPI Python backend.
- The backend is the system-of-record for statement ingestion, analytics, and AI responses.
2. Backend entrypoint and API boundary
- app/main.py is the FastAPI bootstrap point.
- The backend is organized by route boundaries: auth, upload, dashboard, insights, and chat.
- These routes expose the domain API that both web and mobile clients consume.
3. Statement ingestion pipeline
- Uploaded bank statements enter through the upload route.
- Parsing is split by file type in app/services/csv_parser.py and app/services/pdf_parser.py.
- Raw records are normalized and cleaned in cleaner.py, then classified/mapped into finance categories via category_mapper.py.
4. Analytics and transaction intelligence
- Once transactions are normalized, analytics.py computes the user-facing metrics.
- recurring_detector.py identifies repeated payments such as subscriptions or EMIs.
- anomaly_detector.py flags unusual spending patterns, likely using the isolation-forest approach described in the README.
5. AI generation layer
- The app/ai package contains the LLM-facing generators: summary_generator.py, insight_generator.py, and gemini_classifier.py.
- This layer turns transaction aggregates and detected patterns into narrative summaries and financial insights.
- app/utils/ollama_client.py indicates there is also an abstraction for local/model-server access, separate from the Gemini-backed flows.
6. RAG chatbot subsystem
- app/rag/chatbot.py, retriever.py, and vector_store.py form a standalone conversational financial assistant.
- A prebuilt FAISS index lives under app/rag/faiss_index/, showing the RAG corpus is persisted locally rather than computed on every request.
- The chatbot route likely queries this retrieval layer with transaction context and then uses Gemini to generate the final answer.
7. Persistence and shared data model
- app/database/db.py centralizes database access for the backend.
- app/models/schemas.py defines the request/response contracts shared across endpoints.
- The repo README references SQLite, while the presence of a Neon test suggests the database layer is abstracted enough to support a managed SQL backend as well.
8. Authentication and security boundary
- Auth is separated into app/routes/auth.py and utility helpers in app/utils/auth.py.
- The backend likely issues or validates tokens before allowing access to chat, upload, and analytics endpoints.
- Tests such as test_auth_backend.py and test_chat_endpoint_auth.py indicate auth is a first-class boundary, not an afterthought.
9. Web frontend architecture
- cortex-finance-frontend is a React SPA with page-level views in src/pages and reusable UI pieces in src/components.
- It includes dashboard, upload, login/signup, settings, landing, and chatbot screens, mirroring the backend domain areas.
- src/api/mockService.js suggests the UI can run against mocked data, which helps decouple UI development from backend availability.
10. Mobile app architecture
- cortex-finance-mobile is an Expo/React Native app using the app/ router structure plus shared components in src/components.
- It has its own auth context, storage utilities, and API service layer in src/services.
- This client is a separate presentation layer, but it depends on the same backend concepts: authentication, transactions, dashboard views, and chat.
11. End-to-end data flow
- The main flow is: upload statement → parse/clean/categorize → persist transactions → compute analytics → generate insights/summaries → answer chat questions via RAG.
- Dashboard and insight pages consume computed aggregates, while the chatbot consumes both the transaction corpus and the FAISS retrieval index.
- Web and mobile are thin clients over this backend pipeline.
12. Operational notes
- The backend is container-ready via Dockerfile.
- Tests are present for auth, chat auth, database connectivity, classifier behavior, and indexing, which reflects the major subsystem boundaries.
- The repo is optimized for a hackathon-style AI finance product: relatively small service surface, explicit AI/RAG components, and precomputed retrieval assets.
Main entry points: main.py API app · App.js Web app · chat.py Chat API · analytics.py Analytics
Components 31
Backend
FastAPI system-of-record for ingestion, analytics, auth, and AI responses.
- API app · Backend entrypoint that wires routes and application startup.
cortex-finance-backend/app/main.py - Auth API · Authentication boundary for login and token validation.
cortex-finance-backend/app/routes/auth.py - Upload API · Accepts statement uploads and starts ingestion.
cortex-finance-backend/app/routes/upload.py - Dashboard API · Serves aggregated metrics for the dashboard views.
cortex-finance-backend/app/routes/dashboard.py - Insights API · Exposes narrative insights and summaries.
cortex-finance-backend/app/routes/insights.py - Chat API · Conversation endpoint backed by retrieval and AI generation.
cortex-finance-backend/app/routes/chat.py - Parsers · File-type specific statement parsing for uploads.
- CSV parser · Parses CSV statements into raw transaction records.
cortex-finance-backend/app/services/csv_parser.py - PDF parser · Extracts statement data from PDF uploads.
cortex-finance-backend/app/services/pdf_parser.py - Cleaner · Cleans and normalizes raw transactions.
cortex-finance-backend/app/services/cleaner.py - Category mapper · Maps cleaned transactions to finance categories.
cortex-finance-backend/app/services/category_mapper.py - Analytics · Computes user-facing spending and account metrics.
cortex-finance-backend/app/services/analytics.py - Recurring detector · Finds subscriptions, EMIs, and repeated payments.
cortex-finance-backend/app/services/recurring_detector.py - Anomaly detector · Flags unusual spending patterns.
cortex-finance-backend/app/services/anomaly_detector.py - AI layer · Generates summaries, insights, and transaction classifications.
- Summary gen · Turns aggregates into financial summaries.
cortex-finance-backend/app/ai/summary_generator.py - Insight gen · Produces narrative insights from detected patterns.
cortex-finance-backend/app/ai/insight_generator.py - Gemini classifier · LLM-backed categorization and classification helper.
cortex-finance-backend/app/ai/gemini_classifier.py - RAG chatbot · Standalone conversational finance assistant for questions over indexed corpus.
cortex-finance-backend/app/rag/chatbot.py - Retriever · Fetches relevant context for chat answers.
cortex-finance-backend/app/rag/retriever.py - Vector store · Manages the persisted FAISS-backed retrieval index.
cortex-finance-backend/app/rag/vector_store.py - Database · Central database access layer for backend state.
cortex-finance-backend/app/database/db.py - Schemas · Shared request and response models.
cortex-finance-backend/app/models/schemas.py
Web App
React SPA for dashboard, upload, and chat experiences.
- Web app · Primary browser client for finance dashboard and chat.
cortex-finance-frontend/src/App.js - Pages · Page-level views for dashboard, auth, upload, and settings.
cortex-finance-frontend/src/pages/Dashboard.js - UI components · Reusable dashboard and interaction components.
cortex-finance-frontend/src/components/Charts.js - Mock service · Frontend-local API/data stub for decoupled UI development.
cortex-finance-frontend/src/api/mockService.js
Mobile App
Expo/React Native client with auth, tabs, and API access.
- Mobile app · React Native presentation layer for the same finance domain.
cortex-finance-mobile/App.tsx - App routes · Expo router screens and navigation groups.
cortex-finance-mobile/app/_layout.tsx - Auth context · Client auth state and session handling.
cortex-finance-mobile/src/context/AuthContext.tsx - API service · Backend API access layer for the mobile app.
cortex-finance-mobile/src/services/api.ts
Connections 41
- API app → Auth API: mounts · Bootstraps the authentication route.
- API app → Upload API: mounts · Bootstraps the upload route.
- API app → Dashboard API: mounts · Bootstraps the dashboard route.
- API app → Insights API: mounts · Bootstraps the insights route.
- API app → Chat API: mounts · Bootstraps the chat route.
- Upload API → Parsers: starts · Triggers ingestion for uploaded statements.
- Parsers → CSV parser: uses · Handles CSV statement files.
- Parsers → PDF parser: uses · Handles PDF statement files.
- CSV parser → Cleaner: feeds · Parsed rows are normalized next.
- PDF parser → Cleaner: feeds · Extracted records are normalized next.
- Cleaner → Category mapper: feeds · Cleaned transactions are categorized.
- Category mapper → Analytics: outputs · Categorized transactions feed analytics.
- Analytics → Recurring detector: invokes · Detects repeated payments from normalized data.
- Analytics → Anomaly detector: invokes · Detects unusual spending patterns.
- Analytics → AI layer: feeds · Aggregates are passed to generation layer.
- AI layer → Summary gen: includes · Produces statement summaries.
- AI layer → Insight gen: includes · Produces financial insights.
- AI layer → Gemini classifier: includes · Supports LLM-based classification.
- Chat API → RAG chatbot: delegates · Chat requests are handled by the RAG assistant.
- RAG chatbot → Retriever: uses · Retrieves relevant contextual passages.
- Retriever → Vector store: reads · Queries the persisted FAISS index.
- Chat API → AI layer: uses · Final answers are generated through AI services.
- Dashboard API → Analytics: serves · Dashboard reads computed metrics.
- Insights API → AI layer: serves · Insights are generated from the AI layer.
- Auth API → Database: uses · Auth state is validated or stored via database access.
- Dashboard API → Database: uses · Reads persisted finance data.
- Chat API → Database: uses · Chat may use stored user context.
- API app → Schemas: shares · API contracts are shared across routes.
- Web app → Pages: navigates · Main SPA composes page-level views.
- Pages → UI components: renders · Pages reuse shared UI components.
- Web app → Mock service: falls back · Supports mocked data during frontend development.
- Web app → Dashboard API: consumes · Dashboard requests backend metrics.
- Web app → Upload API: consumes · Upload flow sends statements to backend.
- Web app → Chat API: consumes · Chat screen queries the assistant API.
- Web app → Auth API: consumes · Login and signup use auth endpoints.
- Mobile app → App routes: navigates · App shell is organized by router screens.
- Mobile app → Auth context: uses · Shares authentication state across screens.
- Mobile app → API service: consumes · Mobile screens call the backend through a service layer.
- API service → Auth API: calls · Mobile auth flow uses the backend auth API.
- API service → Dashboard API: calls · Dashboard data is fetched from backend.
- API service → Chat API: calls · Mobile chat uses the assistant API.