How aayush349/intelli-credit works
Purpose and Entry Points
Intelli-Credit V3 is a local-first Indian corporate credit-appraisal system. It accepts borrower documents, produces structured risk evidence and a lending decision, then generates a Credit Appraisal Memo (CAM). The backend entry point is app/main.py; the user-facing Streamlit workflow starts at streamlit_app/app.py. API boundary modules are app/api/upload.py, app/api/status.py, and app/api/analysis.py.
Application Lifecycle and Persistence
Upload creates and tracks a credit application and its documents through FastAPI, SQLAlchemy, and SQLite. ORM and API contracts reside in app/models.py, app/database.py, and app/schemas.py. Processing is dispatched through an in-process threaded queue rather than an external broker, centered on app/tasks/task_queue.py and app/tasks/pipeline.py.
Ingestion and Parsing Layer
The pipeline classifies documents and routes them to domain parsers for GST, bank statements, financials, auditor reports, and CIBIL reports. Parsing normalizes heterogeneous source formats into structured results, forming the transition from raw upload material to analytical inputs. Key paths: app/parsers/doc_classifier.py, app/parsers/base.py, app/parsers/gst_parser.py, app/parsers/bank_parser.py, app/parsers/financial_parser.py, app/parsers/auditor_parser.py, app/parsers/cibil_parser.py.
Graph and Risk-Signal Analysis
A NetworkX knowledge graph connects borrower, promoter/director, guarantor, and related-entity information; query logic derives graph features and pyvis can render the relationship view. Anomaly detectors independently evaluate circular trading, round trips, EMI stress, revenue inconsistencies, and auditor-derived flags. Core paths: app/graph/builder.py, app/graph/queries.py, app/anomaly/circular_trading.py, app/anomaly/round_trip.py, app/anomaly/emi_stress.py, app/anomaly/revenue_triangle.py, app/anomaly/auditor_bridge.py.
External Due Diligence Boundary
The research agent conditionally invokes public/regulatory research tools for company records, RBI status/defaults, courts/DRT, news, and RERA. It supports DEMO mode through filesystem-backed cached responses, avoiding live-service dependence for demonstrations. Core orchestration and boundaries: app/research/agent.py, app/research/cache_manager.py, app/research/tools/mca_lookup.py, app/research/tools/ecourt_scraper.py, app/research/tools/rbi_defaulter.py, app/research/tools/news_search.py. Live calls use HTTP services; LLM narration/adjustment uses OpenRouter/Gemini when configured.
Credit Decisioning
Scoring combines deterministic rejection gates, weighted Five-Cs assessment, optional LLM qualitative adjustment, and loan sizing. This stage consumes parsed financials, graph features, anomaly results, and research evidence to produce a decision plus explainable rationale. Core paths: app/scoring/engine.py, app/scoring/hard_rules.py, app/scoring/five_cs.py, app/scoring/llm_adjuster.py, app/scoring/loan_sizing.py, app/scoring/explanation.py.
CAM Generation and Delivery
CAM generation converts the consolidated decision context into a structured Word document, with LLM-assisted narrative where enabled. The Streamlit pages expose upload, due diligence, research, decision, and CAM download as sequential operator-facing stages. Key paths: app/cam/generator.py, app/cam/docx_builder.py, app/cam/llm_narrator.py, streamlit_app/pages/1_Upload.py, streamlit_app/pages/4_Decision.py, streamlit_app/pages/5_Download_CAM.py.
Runtime and Data Boundaries
The deployment is containerizable via Dockerfile and docker-compose.yml; render.yaml indicates a Render deployment target. Data follows bronze/silver/gold-style filesystem stages plus research cache; the present tree explicitly contains data/cache/. Material libraries include FastAPI, Streamlit, SQLAlchemy/SQLite, NetworkX/pyvis, pandas/numpy/scipy, document/OCR parsers, and python-docx/pdf tooling. Configuration and service-mode/API-key control are centralized in app/config.py.
Main entry points: engine.py Credit scoring engine · agent.py Due-diligence agent · upload.py Upload, status & analysis APIs · explanation.py Decision & rationale
Components 18
User & API
- Streamlit operator workflow · Sequential upload-to-CAM operator experience.
streamlit_app/app.py - FastAPI application
app/main.py - Upload, status & analysis APIs
app/api/upload.py
Application Workflow
- Applications & documents · Persists application lifecycle and document state.
app/database.py - In-process task queue · Dispatches processing without an external broker.
app/tasks/task_queue.py - Document processing pipeline
app/tasks/pipeline.py - Document classifier
app/parsers/doc_classifier.py - Domain parsers · Normalizes heterogeneous borrower documents into structured inputs.
app/parsers/base.py - Structured evidence · Normalized financial, transaction, audit, and credit-report evidence.
Risk Analysis
- Borrower relationship graph · Connects borrower, promoters, guarantors, and related entities.
app/graph/builder.py - Relationship features
app/graph/queries.py - Anomaly detectors · Detects circular trading, round trips, EMI stress, revenue and audit flags.
app/anomaly/circular_trading.py - Due-diligence agent · Conditionally gathers company, RBI, court, news, and RERA evidence.
app/research/agent.py - Demo research cache · Filesystem-backed responses support offline demonstrations.
app/research/cache_manager.py - Public & regulatory services · Live records, defaults, courts, news, and optional OpenRouter/Gemini calls.
app/research/tools/mca_lookup.py
Decision & Delivery
- Credit scoring engine · Combines gates, Five-Cs, qualitative adjustment, and loan sizing.
app/scoring/engine.py - Decision & rationale · Explainable approval, rejection, or conditional lending result.
app/scoring/explanation.py - CAM generator · Builds the Credit Appraisal Memo with optional LLM narrative.
app/cam/generator.py
Connections 22
- Streamlit operator workflow → FastAPI application: submits workflow actions
- FastAPI application → Upload, status & analysis APIs: serves
- Upload, status & analysis APIs → Applications & documents: creates and tracks
- Upload, status & analysis APIs → In-process task queue: enqueues processing
- In-process task queue → Document processing pipeline: runs
- Document processing pipeline → Document classifier: classifies uploads
- Document classifier → Domain parsers: routes by document type
- Domain parsers → Structured evidence: normalizes
- Structured evidence → Borrower relationship graph: builds entities and links
- Borrower relationship graph → Relationship features: derives features
- Structured evidence → Anomaly detectors: evaluates risk signals
- Structured evidence → Due-diligence agent: supplies company context
- Due-diligence agent → Demo research cache: reads cached demo evidence
- Due-diligence agent → Public & regulatory services: queries when live
- Structured evidence → Credit scoring engine: financial and credit inputs
- Relationship features → Credit scoring engine: relationship risk
- Anomaly detectors → Credit scoring engine: anomaly flags
- Due-diligence agent → Credit scoring engine: due-diligence evidence
- Credit scoring engine → Decision & rationale: produces
- Decision & rationale → CAM generator: provides decision context
- CAM generator → Streamlit operator workflow: CAM download
- Decision & rationale → Applications & documents: persists outcome