# krishnaofficl/fraud-risk-scoring-api architecture

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

- Interactive diagram: https://gitdiagram.com/krishnaofficl/fraud-risk-scoring-api
- Repository: https://github.com/krishnaofficl/fraud-risk-scoring-api

## Overview

FraudScope is an asynchronous API and browser portal for authenticated vehicle-loan risk evaluation. The main workflow validates an applicant, runs the loaded ML pipeline, classifies the probability, and persists a user-scoped audit record; users can query or soft-delete history and inspect model metadata. Separate branches cover account authentication, health probes, and request observability. The README documents these capabilities; unsampled route and health implementations are represented at their tree paths, with relationships included only where the README or excerpts establish them.

Main entry points: [`app/main.py`](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/main.py) (FastAPI application), [`app/routers/scoring.py`](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/routers/scoring.py) (Scoring and audit routes), [`app/routers/auth.py`](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/routers/auth.py) (Authentication routes), [`app/db/session.py`](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/db/session.py) (Async database sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and portal"]
  node_application["FastAPI application<br/>[main.py]"]
  node_portal["Web portal assets<br/>[app.js]"]
end

subgraph group_identity["Identity"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_auth_schemas["Auth payload schemas<br/>[auth.py]"]
  node_security["Password and JWT security<br/>[security.py]"]
  node_user_routes["User profile routes<br/>[users.py]"]
end

subgraph group_risk["Risk evaluation"]
  node_scoring_routes["Scoring and audit routes<br/>[scoring.py]"]
  node_scoring_schemas["Applicant and result schemas<br/>[scoring.py]"]
  node_pipeline["Loaded ML pipeline<br/>[main.py]"]
  node_model_artifact["Serialized model artifact"]
end

subgraph group_operations["Persistence and operations"]
  node_users[("User records<br/>[user.py]")]
  node_score_records[("Scoring audit records<br/>[scoring.py]")]
  node_model_versions[("Model version records<br/>[model_version.py]")]
  node_health["Health probes<br/>[health.py]"]
  node_db_session["Async database sessions<br/>[session.py]"]
  node_logging["Request logging and correlation<br/>[logging.py]"]
  node_errors["Error handling<br/>[error_handlers.py]"]
  node_config["Runtime settings<br/>[config.py]"]
  node_postgres[("PostgreSQL")]
end

node_client(("Browser or API client"))

node_client -->|"sends requests"| node_application
node_application -->|"serves assets"| node_portal
node_application -->|"mounts routes"| node_auth_routes
node_application -->|"mounts routes"| node_user_routes
node_application -->|"mounts routes"| node_scoring_routes
node_application -->|"mounts routes"| node_health
node_auth_routes -->|"validates payloads"| node_auth_schemas
node_auth_routes -->|"hashes and issues tokens"| node_security
node_auth_routes -->|"reads and creates"| node_users
node_user_routes -->|"authenticates user"| node_security
node_security -->|"loads user"| node_users
node_auth_routes -->|"gets session"| node_db_session
node_scoring_routes -->|"validates and shapes"| node_scoring_schemas
node_scoring_routes -->|"requires user"| node_security
node_scoring_routes -->|"runs inference"| node_pipeline
node_application -->|"loads at startup"| node_pipeline
node_application -->|"loads artifact"| node_model_artifact
node_scoring_routes -->|"writes and queries"| node_score_records
node_scoring_routes -->|"queries version"| node_model_versions
node_application -->|"seeds version"| node_model_versions
node_scoring_routes -->|"gets session"| node_db_session
node_health -->|"checks database"| node_db_session
node_health -->|"checks loaded model"| node_pipeline
node_db_session -->|"connects"| node_postgres
node_application -->|"configures middleware"| node_logging
node_application -->|"registers handlers"| node_errors
node_application -->|"uses startup session"| node_db_session
node_application -->|"reads settings"| node_config

click node_application "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/main.py"
click node_portal "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/static/app.js"
click node_auth_routes "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/routers/auth.py"
click node_auth_schemas "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/schemas/auth.py"
click node_security "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/core/security.py"
click node_user_routes "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/routers/users.py"
click node_users "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/models/user.py"
click node_scoring_routes "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/routers/scoring.py"
click node_scoring_schemas "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/schemas/scoring.py"
click node_pipeline "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/main.py"
click node_score_records "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/models/scoring.py"
click node_model_versions "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/models/model_version.py"
click node_health "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/routers/health.py"
click node_db_session "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/db/session.py"
click node_logging "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/core/logging.py"
click node_errors "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/core/error_handlers.py"
click node_config "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/core/config.py"
click node_model_artifact "https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/artifacts/model_pipeline.joblib"

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_application,node_portal,node_client toneBlue
class node_auth_routes,node_auth_schemas,node_security,node_user_routes toneAmber
class node_scoring_routes,node_scoring_schemas,node_pipeline,node_model_artifact toneMint
class node_users,node_score_records,node_model_versions,node_health,node_db_session,node_logging,node_errors,node_config,node_postgres toneRose
```

## Components

### API and portal

- [FastAPI application](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/main.py): `app/main.py`
- [Web portal assets](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/static/app.js): `app/static/app.js`

### Identity

- [Authentication routes](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/routers/auth.py): `app/routers/auth.py`
- [Auth payload schemas](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/schemas/auth.py): `app/schemas/auth.py`
- [Password and JWT security](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/core/security.py): `app/core/security.py`
- [User profile routes](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/routers/users.py): `app/routers/users.py`

### Risk evaluation

- [Scoring and audit routes](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/routers/scoring.py): `app/routers/scoring.py`
- [Applicant and result schemas](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/schemas/scoring.py): `app/schemas/scoring.py`
- [Loaded ML pipeline](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/main.py): `app/main.py`
- [Serialized model artifact](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/artifacts/model_pipeline.joblib): `artifacts/model_pipeline.joblib`

### Persistence and operations

- [User records](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/models/user.py): `app/models/user.py`
- [Scoring audit records](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/models/scoring.py): `app/models/scoring.py`
- [Model version records](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/models/model_version.py): `app/models/model_version.py`
- [Health probes](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/routers/health.py): `app/routers/health.py`
- [Async database sessions](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/db/session.py): `app/db/session.py`
- [Request logging and correlation](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/core/logging.py): `app/core/logging.py`
- [Error handling](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/core/error_handlers.py): `app/core/error_handlers.py`
- [Runtime settings](https://github.com/krishnaofficl/fraud-risk-scoring-api/blob/main/app/core/config.py): `app/core/config.py`
- **PostgreSQL**

### Other components

- **Browser or API client**

## Connections

- Browser or API client → FastAPI application: sends requests (evidence: `README.md`)
- FastAPI application → Web portal assets: serves assets (evidence: `app/main.py`)
- FastAPI application → Authentication routes: mounts routes (evidence: `app/main.py`)
- FastAPI application → User profile routes: mounts routes (evidence: `app/main.py`)
- FastAPI application → Scoring and audit routes: mounts routes (evidence: `app/main.py`)
- FastAPI application → Health probes: mounts routes (evidence: `app/main.py`)
- Authentication routes → Auth payload schemas: validates payloads (evidence: `app/routers/auth.py`)
- Authentication routes → Password and JWT security: hashes and issues tokens (evidence: `app/routers/auth.py`)
- Authentication routes → User records: reads and creates (evidence: `app/routers/auth.py`)
- User profile routes → Password and JWT security: authenticates user (evidence: `app/routers/users.py`)
- Password and JWT security → User records: loads user (evidence: `app/core/security.py`)
- Authentication routes → Async database sessions: gets session (evidence: `app/routers/auth.py`)
- Scoring and audit routes → Applicant and result schemas: validates and shapes (evidence: `app/routers/scoring.py`)
- Scoring and audit routes → Password and JWT security: requires user (evidence: `app/routers/scoring.py`)
- Scoring and audit routes → Loaded ML pipeline: runs inference (evidence: `app/routers/scoring.py`)
- FastAPI application → Loaded ML pipeline: loads at startup (evidence: `app/main.py`)
- FastAPI application → Serialized model artifact: loads artifact (evidence: `app/main.py`)
- Scoring and audit routes → Scoring audit records: writes and queries (evidence: `app/routers/scoring.py`)
- Scoring and audit routes → Model version records: queries version (evidence: `app/routers/scoring.py`)
- FastAPI application → Model version records: seeds version (evidence: `app/main.py`)
- Scoring and audit routes → Async database sessions: gets session (evidence: `app/routers/scoring.py`)
- Health probes → Async database sessions: checks database (evidence: `README.md`)
- Health probes → Loaded ML pipeline: checks loaded model (evidence: `README.md`)
- Async database sessions → PostgreSQL: connects (evidence: `app/db/session.py`)
- FastAPI application → Request logging and correlation: configures middleware (evidence: `app/main.py`)
- FastAPI application → Error handling: registers handlers (evidence: `app/main.py`)
- FastAPI application → Async database sessions: uses startup session (evidence: `app/main.py`)
- FastAPI application → Runtime settings: reads settings (evidence: `app/main.py`)
