# cyclop5/creditiq architecture

> Architecture diagram of the GitHub repository cyclop5/creditiq, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cyclop5/creditiq
- Repository: https://github.com/cyclop5/creditiq

## Overview

CreditIQ is an MSME credit-scoring platform that combines GST, UPI and e-way-bill signals to produce scores, fraud findings and human-readable explanations. Its main workflow runs from signal ingestion through feature engineering, fraud analysis and scoring, then exposes results through a role-based dashboard and API. The graph also includes the documented analyst, lender, risk and administration capabilities. Some subsystem links rely on README descriptions because their implementation was not sampled; those limits are reflected in the evidence paths.

Main entry points: [`src/api/worker.py`](https://github.com/cyclop5/creditiq/blob/main/src/api/worker.py) (Scoring Worker), [`src/api/routes.py`](https://github.com/cyclop5/creditiq/blob/main/src/api/routes.py) (Scoring API), [`config/settings.py`](https://github.com/cyclop5/creditiq/blob/main/config/settings.py) (Redis Streams), [`src/api`](https://github.com/cyclop5/creditiq/tree/main/src/api) (Role APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_signals["Signals and Features"]
  node_signal_sources["GST UPI EWB<br/>[schemas.py]"]
  node_ingestion["Signal Ingestion"]
  node_feature_engine["Feature Engineering<br/>[engine.py]"]
end

subgraph group_decision["Risk Decisions"]
  node_fraud_graph["Fraud Graph<br/>[graph_builder.py]"]
  node_cycle_detector["Cycle Detection<br/>[cycle_detector.py]"]
  node_scoring_model["Credit Scoring<br/>[model.py]"]
  node_training["Model Training<br/>[trainer.py]"]
  node_shap["Score Explainability<br/>[explainer.py]"]
  node_llm["Plain-language Reasons<br/>[translator.py]"]
end

subgraph group_service["API and Operations"]
  node_worker["Scoring Worker<br/>[worker.py]"]
  node_redis[("Redis Streams<br/>[settings.py]")]
  node_api["Scoring API<br/>[routes.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_mock_db[("Portal Data Store<br/>[mock_db.py]")]
  node_domain_api["Role APIs"]
end

subgraph group_experience["User Portals"]
  node_dashboard["Role-based Dashboard"]
  node_analyst_portal["Analyst Tools"]
  node_risk_portal["Risk Tools"]
  node_bank_portal["Lender Tools"]
  node_msme_portal["MSME Tools"]
  node_admin_portal["Admin Tools"]
end

node_business_users(("MSME Owners and Lenders"))
node_analysts(("Analysts and Risk Managers"))
node_admins(("Administrators"))
node_openrouter{{"OpenRouter LLM"}}

node_signal_sources -.->|"ingests"| node_ingestion
node_ingestion -.->|"streams signals"| node_redis
node_redis -.->|"feeds features"| node_feature_engine
node_feature_engine -->|"resolves features"| node_worker
node_worker -->|"builds graph"| node_fraud_graph
node_worker -->|"detects cycles"| node_cycle_detector
node_worker -->|"scores features"| node_scoring_model
node_worker -->|"explains score"| node_shap
node_worker -->|"translates reasons"| node_llm
node_training -->|"trains model"| node_scoring_model
node_worker -->|"consumes and writes"| node_redis
node_api -->|"reads score state"| node_redis
node_api -.->|"queues scoring task"| node_worker
node_llm -->|"requests explanations"| node_openrouter
node_api -->|"serves role routes"| node_domain_api
node_auth -->|"checks users"| node_mock_db
node_domain_api -.->|"gates access"| node_auth
node_domain_api -.->|"serves portal data"| node_mock_db
node_business_users -->|"uses"| node_dashboard
node_analysts -->|"inspects signals"| node_analyst_portal
node_analysts -->|"monitors fraud"| node_risk_portal
node_business_users -->|"reviews loan decisions"| node_bank_portal
node_business_users -->|"views score reports"| node_msme_portal
node_admins -->|"manages platform"| node_admin_portal
node_dashboard -.->|"requests results"| node_api

click node_signal_sources "https://github.com/cyclop5/creditiq/blob/main/src/features/schemas.py"
click node_ingestion "https://github.com/cyclop5/creditiq/tree/main/src/ingestion"
click node_feature_engine "https://github.com/cyclop5/creditiq/blob/main/src/features/engine.py"
click node_fraud_graph "https://github.com/cyclop5/creditiq/blob/main/src/fraud/graph_builder.py"
click node_cycle_detector "https://github.com/cyclop5/creditiq/blob/main/src/fraud/cycle_detector.py"
click node_scoring_model "https://github.com/cyclop5/creditiq/blob/main/src/scoring/model.py"
click node_training "https://github.com/cyclop5/creditiq/blob/main/src/scoring/trainer.py"
click node_shap "https://github.com/cyclop5/creditiq/blob/main/src/scoring/explainer.py"
click node_llm "https://github.com/cyclop5/creditiq/blob/main/src/llm/translator.py"
click node_worker "https://github.com/cyclop5/creditiq/blob/main/src/api/worker.py"
click node_redis "https://github.com/cyclop5/creditiq/blob/main/config/settings.py"
click node_api "https://github.com/cyclop5/creditiq/blob/main/src/api/routes.py"
click node_auth "https://github.com/cyclop5/creditiq/blob/main/src/api/auth.py"
click node_mock_db "https://github.com/cyclop5/creditiq/blob/main/src/api/mock_db.py"
click node_domain_api "https://github.com/cyclop5/creditiq/tree/main/src/api"
click node_dashboard "https://github.com/cyclop5/creditiq/tree/main/frontend/app"
click node_analyst_portal "https://github.com/cyclop5/creditiq/tree/main/frontend/app/analyst"
click node_risk_portal "https://github.com/cyclop5/creditiq/tree/main/frontend/app/risk"
click node_bank_portal "https://github.com/cyclop5/creditiq/tree/main/frontend/app/bank"
click node_msme_portal "https://github.com/cyclop5/creditiq/tree/main/frontend/app/msme"
click node_admin_portal "https://github.com/cyclop5/creditiq/tree/main/frontend/app/admin"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_signal_sources,node_ingestion,node_feature_engine toneBlue
class node_fraud_graph,node_cycle_detector,node_scoring_model,node_training,node_shap,node_llm toneAmber
class node_worker,node_redis,node_api,node_auth,node_mock_db,node_domain_api,node_openrouter toneMint
class node_dashboard,node_analyst_portal,node_risk_portal,node_bank_portal,node_msme_portal,node_admin_portal toneRose
class node_business_users,node_analysts,node_admins toneIndigo
```

## Components

### Signals and Features

- [GST UPI EWB](https://github.com/cyclop5/creditiq/blob/main/src/features/schemas.py): `src/features/schemas.py`
- [Signal Ingestion](https://github.com/cyclop5/creditiq/tree/main/src/ingestion): `src/ingestion`
- [Feature Engineering](https://github.com/cyclop5/creditiq/blob/main/src/features/engine.py): `src/features/engine.py`

### Risk Decisions

- [Fraud Graph](https://github.com/cyclop5/creditiq/blob/main/src/fraud/graph_builder.py): `src/fraud/graph_builder.py`
- [Cycle Detection](https://github.com/cyclop5/creditiq/blob/main/src/fraud/cycle_detector.py): `src/fraud/cycle_detector.py`
- [Credit Scoring](https://github.com/cyclop5/creditiq/blob/main/src/scoring/model.py): `src/scoring/model.py`
- [Model Training](https://github.com/cyclop5/creditiq/blob/main/src/scoring/trainer.py): `src/scoring/trainer.py`
- [Score Explainability](https://github.com/cyclop5/creditiq/blob/main/src/scoring/explainer.py): `src/scoring/explainer.py`
- [Plain-language Reasons](https://github.com/cyclop5/creditiq/blob/main/src/llm/translator.py): `src/llm/translator.py`

### API and Operations

- [Scoring Worker](https://github.com/cyclop5/creditiq/blob/main/src/api/worker.py): `src/api/worker.py`
- [Redis Streams](https://github.com/cyclop5/creditiq/blob/main/config/settings.py): `config/settings.py`
- [Scoring API](https://github.com/cyclop5/creditiq/blob/main/src/api/routes.py): `src/api/routes.py`
- [Authentication](https://github.com/cyclop5/creditiq/blob/main/src/api/auth.py): `src/api/auth.py`
- [Portal Data Store](https://github.com/cyclop5/creditiq/blob/main/src/api/mock_db.py): `src/api/mock_db.py`
- [Role APIs](https://github.com/cyclop5/creditiq/tree/main/src/api): `src/api`

### User Portals

- [Role-based Dashboard](https://github.com/cyclop5/creditiq/tree/main/frontend/app): `frontend/app`
- [Analyst Tools](https://github.com/cyclop5/creditiq/tree/main/frontend/app/analyst): `frontend/app/analyst`
- [Risk Tools](https://github.com/cyclop5/creditiq/tree/main/frontend/app/risk): `frontend/app/risk`
- [Lender Tools](https://github.com/cyclop5/creditiq/tree/main/frontend/app/bank): `frontend/app/bank`
- [MSME Tools](https://github.com/cyclop5/creditiq/tree/main/frontend/app/msme): `frontend/app/msme`
- [Admin Tools](https://github.com/cyclop5/creditiq/tree/main/frontend/app/admin): `frontend/app/admin`

### Other components

- **MSME Owners and Lenders**
- **Analysts and Risk Managers**
- **Administrators**
- **OpenRouter LLM**

## Connections

- GST UPI EWB → Signal Ingestion: ingests
- Signal Ingestion → Redis Streams: streams signals (evidence: `src/ingestion/generator.py`)
- Redis Streams → Feature Engineering: feeds features
- Feature Engineering → Scoring Worker: resolves features (evidence: `src/api/worker.py`)
- Scoring Worker → Fraud Graph: builds graph (evidence: `src/api/worker.py`)
- Scoring Worker → Cycle Detection: detects cycles (evidence: `src/api/worker.py`)
- Scoring Worker → Credit Scoring: scores features (evidence: `src/api/worker.py`)
- Scoring Worker → Score Explainability: explains score (evidence: `src/api/worker.py`)
- Scoring Worker → Plain-language Reasons: translates reasons (evidence: `src/api/worker.py`)
- Model Training → Credit Scoring: trains model (evidence: `src/scoring/model.py`)
- Scoring Worker → Redis Streams: consumes and writes (evidence: `src/api/worker.py`)
- Scoring API → Redis Streams: reads score state (evidence: `src/api/routes.py`)
- Scoring API → Scoring Worker: queues scoring task
- Plain-language Reasons → OpenRouter LLM: requests explanations (evidence: `src/llm/translator.py`)
- Scoring API → Role APIs: serves role routes (evidence: `src/api/main.py`)
- Authentication → Portal Data Store: checks users (evidence: `src/api/auth.py`)
- Role APIs → Authentication: gates access (evidence: `src/api/main.py`)
- Role APIs → Portal Data Store: serves portal data (evidence: `src/api/router_analyst.py`)
- MSME Owners and Lenders → Role-based Dashboard: uses
- Analysts and Risk Managers → Analyst Tools: inspects signals
- Analysts and Risk Managers → Risk Tools: monitors fraud
- MSME Owners and Lenders → Lender Tools: reviews loan decisions
- MSME Owners and Lenders → MSME Tools: views score reports
- Administrators → Admin Tools: manages platform
- Role-based Dashboard → Scoring API: requests results
