How dhruv2541/credit_compass works
Purpose and Runtime Entry Points
Credit Compass is a local, educational FinTech SPA for alternative credit scoring and guided micro-investment advice. The React/Vite client starts at frontend/src/main.jsx and composes the application in frontend/src/App.jsx. The FastAPI API starts through backend/app/main.py (uvicorn app.main:app) and exposes interactive OpenAPI docs.
Client Application and Navigation
The browser client owns presentation, route-level workflows, and chart/simulation interaction. Core screens are login/signup, the credit dashboard, and investment advisor:
• frontend/src/pages/Login.jsx
• frontend/src/pages/Dashboard.jsx
• frontend/src/pages/Advisor.jsx
frontend/src/context/AuthContext.jsx provides session/authentication state across the SPA. frontend/src/hooks/useAxios.js is the API-client boundary, expected to attach/use JWT-backed requests rather than embedding backend access in pages.
Authentication and Request Protection
The backend separates auth endpoints, token/password security, and dependency-based authorization:
• backend/app/api/auth.py
• backend/app/core/security.py
• backend/app/api/deps.py
The intended flow is signup/login → bcrypt password handling → JWT issuance → frontend auth context and Axios client → protected API requests resolved through FastAPI dependencies. This is the primary security boundary between public access and user-specific credit/investment operations.
API Composition Layer
FastAPI route modules expose the product capabilities and delegate business/ML work to services:
• backend/app/main.py
• backend/app/api/credit.py
• backend/app/api/invest.py
Credit APIs supply scoring and explainability-oriented output for the dashboard. Investment APIs accept the conversational risk-profile inputs and return advisory/projection-oriented results. backend/app/api/deps.py centralizes shared request concerns such as authenticated-user/database dependency resolution.
Domain Persistence and Contracts
SQLAlchemy models and sessions form the persistent boundary; Pydantic schemas define API input/output contracts:
• backend/app/models/models.py
• backend/app/db/session.py
• backend/app/schemas/schemas.py
SQLite is the declared datastore. Route handlers should exchange schema objects at the API boundary and use ORM models only inside backend persistence/service flows, limiting database representation leakage to the frontend.
Credit ML and Explainability Pipeline
Offline scripts produce the deployed ML artifact:
• scripts/generate_data.py
• scripts/train_model.py
• backend/models/model.pkl
Training uses synthetic credit signals and a scikit-learn LogisticRegression pipeline. At runtime, backend/app/services/credit_service.py loads/applies the persisted model to calculate credit likelihood/score and localized SHAP-equivalent feature contributions. The service boundary keeps model mechanics out of HTTP routing and lets the dashboard render both score and positive/negative explanations.
Investment Advisory and Presentation Effects
backend/app/services/invest_service.py encapsulates risk-profile interpretation and investment-growth calculations consumed by the advisor screen. The client renders the guided interaction and projections, while the backend remains the decision/calculation boundary. Separately, the one-session visual entrance is isolated from financial workflows:
• frontend/src/components/IntroAnimation/IntroAnimation.jsx
• frontend/src/components/IntroAnimation/useIntroSession.js
Infrastructure and External Dependencies
The system is a two-process local deployment: Node.js 18+ runs Vite; Python 3.10+ runs FastAPI/Uvicorn. Material libraries include React, Axios, Tailwind, Recharts, FastAPI, SQLAlchemy, SQLite, bcrypt, PyJWT, scikit-learn, pandas/numpy, and SHAP-related explainability support. No remote financial data provider or third-party AI service is identified; data and predictions are synthetic.
Main entry points: useAxios.js API client · App.jsx SPA composition · auth.py Auth endpoints · credit.py Credit API
Components 22
React/Vite Client
- Vite entry
frontend/src/main.jsx - SPA composition
frontend/src/App.jsx - Auth state · Shares JWT-backed session state across the SPA.
frontend/src/context/AuthContext.jsx - API client · Client boundary for authenticated API requests.
frontend/src/hooks/useAxios.js - Credit dashboard · Renders credit score and feature explanations.
frontend/src/pages/Dashboard.jsx - Investment advisor · Guides risk inputs and displays projections.
frontend/src/pages/Advisor.jsx - Intro animation · One-session visual entrance isolated from financial flows.
frontend/src/components/IntroAnimation/IntroAnimation.jsx
FastAPI Backend
- FastAPI app · Uvicorn entry point and route composition.
backend/app/main.py - Auth endpoints · Signup and login endpoints.
backend/app/api/auth.py - JWT and passwords · Hashes passwords and issues or verifies JWTs.
backend/app/core/security.py - Request dependencies · Resolves authenticated users and database access.
backend/app/api/deps.py - Credit API · Exposes scoring and explainability results.
backend/app/api/credit.py - Investment API · Exposes risk-profile advisory and projections.
backend/app/api/invest.py - API contracts · Defines request and response representations.
backend/app/schemas/schemas.py - Credit scoring service · Calculates score and localized feature contributions.
backend/app/services/credit_service.py - Investment service · Interprets risk profiles and calculates growth.
backend/app/services/invest_service.py
Persistence
- Domain models
backend/app/models/models.py - Database session
backend/app/db/session.py - SQLite datastore · Local persistent store for user-domain data.
Credit ML Pipeline
- Synthetic data generator
scripts/generate_data.py - Model training · Trains the LogisticRegression credit pipeline.
scripts/train_model.py - Deployed credit model
backend/models/model.pkl
Connections 30
- Vite entry → SPA composition: mounts
- SPA composition → Auth state: uses
- SPA composition → Credit dashboard: routes to
- SPA composition → Investment advisor: routes to
- SPA composition → Intro animation: shows
- Auth state → API client: provides JWT
- Credit dashboard → API client: calls
- Investment advisor → API client: calls
- API client → Auth endpoints: signup/login
- API client → Credit API: protected requests
- API client → Investment API: protected requests
- FastAPI app → Auth endpoints: registers
- FastAPI app → Credit API: registers
- FastAPI app → Investment API: registers
- Auth endpoints → JWT and passwords: hashes and issues tokens
- Auth endpoints → API contracts: uses
- Credit API → Request dependencies: authorizes
- Investment API → Request dependencies: authorizes
- Request dependencies → JWT and passwords: verifies JWT
- Request dependencies → Database session: resolves session
- Credit API → API contracts: uses
- Credit API → Credit scoring service: delegates scoring
- Investment API → API contracts: uses
- Investment API → Investment service: delegates advice
- Credit scoring service → Deployed credit model: loads
- Database session → SQLite datastore: connects
- Domain models → Database session: persisted through
- Auth endpoints → Domain models: creates users
- Synthetic data generator → Model training: produces training data
- Model training → Deployed credit model: writes artifact