# rmr193/super-intel architecture

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

- Interactive diagram: https://gitdiagram.com/rmr193/super-intel
- Repository: https://github.com/rmr193/super-intel

## Overview

1. **System purpose**
   - This repo is a three-tier decision-support platform for MFS agent liquidity and risk monitoring in Bangladesh.
   - It combines operational state, anomaly detection, forecasting, and human triage for **bKash, Nagad, and Rocket**.

2. **Top-level architecture**
   - The system is split into:
     - **Frontend**: interactive operator dashboard
     - **Backend**: API and persistence layer
     - **ML service**: separate inference service for anomaly/risk signals
   - These services are designed to run locally in parallel and communicate over HTTP.

3. **Frontend boundary**
   - The `/frontend` app is a **React + Vite + TypeScript** single-page dashboard.
   - Its main job is presentation and operator interaction: charts, agent details, alert center, stakeholder queue, simulator panel, and dashboard views.
   - The frontend also hosts the **scenario controller** used to trigger demo states and observe system behavior.

4. **Frontend data responsibilities**
   - It appears to consume operational data from the backend and render:
     - wallet/cash liquidity state
     - alert status
     - case/audit workflow
     - forecast confidence and fallback states
   - The frontend is the user-facing boundary for triage roles such as retail agent, field officer, central ops, and risk analyst.

5. **Backend boundary**
   - The `/backend` service is the API layer, built with **Node.js, Express, TypeScript**, and **Prisma ORM**.
   - It owns application logic and persistence access, and likely exposes endpoints consumed by the dashboard.
   - The presence of `src/app.ts`, `src/server.ts`, and `backend/api/index.ts` suggests a standard Express app plus a deployment entrypoint.

6. **Persistence layer**
   - The backend uses **SQLite** locally through Prisma, matching the README’s “stable execution without complex database dependencies” goal.
   - `prisma/schema.prisma` defines the data model, and `seed.ts` initializes the system with sample agents and historical records.
   - This makes the database the source of truth for agent state, case data, and historical operational signals.

7. **ML inference boundary**
   - `/ml-service` is a separate **Python FastAPI** service.
   - It provides analytics and inference rather than core app state.
   - The repo includes trained artifacts such as `anomaly_model.pkl` and `supervised_classifier.pkl`, indicating the service performs offline-trained inference at runtime.

8. **ML service role in the flow**
   - The ML service is used for:
     - transaction anomaly detection
     - velocity/risk scoring
     - fallback-aware prediction support
   - The README describes blended behavior: isolation-forest-style anomaly detection, z-score logic, and a rules-based fallback when feeds are delayed or unreliable.

9. **Primary data flow**
   - User action begins in the **frontend**.
   - The frontend requests current operational data from the **backend**.
   - The backend reads/writes **SQLite** via Prisma.
   - For risk/anomaly insights, the backend or frontend integrates with the **ML service** over HTTP.
   - The resulting alerts, forecasts, and case states flow back to the dashboard for rendering and triage.

10. **Scenario-driven simulation path**
    - The simulator is a core architectural feature, not just a UI demo.
    - It injects controlled conditions such as:
      - provider-specific cash shortage
      - physical cash pressure plus suspicious transactions
      - delayed provider data with fallback mode
      - escalation and audit workflow
    - This means the frontend is both a visualization layer and a scenario driver for the rest of the stack.

11. **Alerting and triage workflow**
    - The system is organized around an alert lifecycle:
      - detection
      - display in the alert center
      - queueing for stakeholder review
      - acknowledgement or escalation
      - audit trail persistence
    - This creates a clear separation between automated detection and human decision-making.

12. **Operational boundaries**
    - The platform distinguishes among:
      - **physical cash drawer liquidity**
      - **provider wallet balances**
      - **transaction behavior/anomaly signals**
      - **case management / auditability**
    - That separation is important for an architecture diagram because it shows multiple correlated but distinct data domains.

13. **Local runtime and packaging**
    - Each service has its own runtime and packaging:
      - frontend: Vite dev server and static build
      - backend: Node/Express process
      - ML service: Uvicorn-hosted FastAPI app
    - Dockerfiles exist for each component, and there is a `docker-compose.yml`, but the README emphasizes local multi-terminal execution with SQLite as the simplest stable path.

14. **Deployment hints**
    - `vercel.json` files at the root and backend level suggest the project may have been prepared for serverless or hosted deployment, but the repository’s operational design is clearly service-based and local-first.
    - For diagramming, treat deployment as optional packaging around the three core services rather than the main architectural driver.

15. **What to show in an architecture diagram**
    - The diagram should emphasize:
      - a React dashboard at the edge
      - an Express/Prisma/SQLite application backend in the middle
      - a separate Python ML inference service
      - bidirectional flows for alerts, forecasts, and case updates
      - an audit/triage loop that keeps human operators in control

Main entry points: [`frontend/src/App.tsx`](https://github.com/rmr193/super-intel/blob/main/frontend/src/App.tsx) (Dashboard), [`backend/src/app.ts`](https://github.com/rmr193/super-intel/blob/main/backend/src/app.ts) (API App), [`ml-service/main.py`](https://github.com/rmr193/super-intel/blob/main/ml-service/main.py) (Inference API), [`docker-compose.yml`](https://github.com/rmr193/super-intel/blob/main/docker-compose.yml) (Compose)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_frontend["Frontend"]
  node_frontend_app["Dashboard<br/>React/Vite SPA<br/>[App.tsx]"]
  node_frontend_main["Entry<br/>Vite bootstrap<br/>[main.tsx]"]
  node_dashboard_view["Overview<br/>UI view<br/>[DashboardView.tsx]"]
  node_agent_details["Agents<br/>UI view"]
  node_alerts_center["Alerts<br/>UI view"]
  node_stakeholder_queue["Queue<br/>UI view"]
  node_simulator_panel["Simulator<br/>scenario driver<br/>[SimulatorPanel.tsx]"]
end

subgraph group_group_backend["Backend"]
  node_backend_app["API App<br/>Express app<br/>[app.ts]"]
  node_backend_server["Server<br/>Node process<br/>[server.ts]"]
  node_backend_api["API Entry<br/>deployment entry<br/>[index.ts]"]
  node_prisma_schema["Schema<br/>Prisma model<br/>[schema.prisma]"]
  node_seed_data["Seed<br/>bootstrap data<br/>[seed.ts]"]
  node_sqlite_db[("SQLite<br/>local database")]
end

subgraph group_group_ml["ML Service"]
  node_ml_main["Inference API<br/>FastAPI service<br/>[main.py]"]
  node_anomaly_model["Anomaly Model<br/>trained artifact<br/>[anomaly_model.pkl]"]
  node_classifier_model["Classifier<br/>trained artifact"]
end

subgraph group_group_runtime["Local Runtime"]
  node_docker_compose["Compose<br/>orchestration<br/>[docker-compose.yml]"]
  node_root_vercel["Vercel<br/>deployment config<br/>[vercel.json]"]
end

node_frontend_main -->|"mounts"| node_frontend_app
node_frontend_app -->|"renders"| node_dashboard_view
node_frontend_app -->|"renders"| node_agent_details
node_frontend_app -->|"renders"| node_alerts_center
node_frontend_app -->|"renders"| node_stakeholder_queue
node_frontend_app -->|"drives"| node_simulator_panel
node_frontend_app -->|"http"| node_backend_app
node_backend_server -->|"starts"| node_backend_app
node_backend_api -.->|"entry"| node_backend_app
node_backend_app -->|"uses"| node_prisma_schema
node_backend_app -->|"reads/writes"| node_sqlite_db
node_seed_data -->|"initializes"| node_sqlite_db
node_backend_app -->|"http"| node_ml_main
node_ml_main -->|"loads"| node_anomaly_model
node_ml_main -->|"loads"| node_classifier_model
node_simulator_panel -->|"scenario api"| node_backend_app
node_docker_compose -.->|"runs"| node_frontend_app
node_docker_compose -.->|"runs"| node_backend_app
node_docker_compose -.->|"runs"| node_ml_main
node_root_vercel -.->|"hosts"| node_backend_api

click node_frontend_app "https://github.com/rmr193/super-intel/blob/main/frontend/src/App.tsx"
click node_frontend_main "https://github.com/rmr193/super-intel/blob/main/frontend/src/main.tsx"
click node_dashboard_view "https://github.com/rmr193/super-intel/blob/main/frontend/src/components/DashboardView.tsx"
click node_agent_details "https://github.com/rmr193/super-intel/blob/main/frontend/src/components/AgentDetailsView.tsx"
click node_alerts_center "https://github.com/rmr193/super-intel/blob/main/frontend/src/components/AlertsCenterView.tsx"
click node_stakeholder_queue "https://github.com/rmr193/super-intel/blob/main/frontend/src/components/StakeholderQueueView.tsx"
click node_simulator_panel "https://github.com/rmr193/super-intel/blob/main/frontend/src/components/SimulatorPanel.tsx"
click node_backend_app "https://github.com/rmr193/super-intel/blob/main/backend/src/app.ts"
click node_backend_server "https://github.com/rmr193/super-intel/blob/main/backend/src/server.ts"
click node_backend_api "https://github.com/rmr193/super-intel/blob/main/backend/api/index.ts"
click node_prisma_schema "https://github.com/rmr193/super-intel/blob/main/backend/prisma/schema.prisma"
click node_seed_data "https://github.com/rmr193/super-intel/blob/main/backend/prisma/seed.ts"
click node_ml_main "https://github.com/rmr193/super-intel/blob/main/ml-service/main.py"
click node_anomaly_model "https://github.com/rmr193/super-intel/blob/main/ml-service/anomaly_model.pkl"
click node_classifier_model "https://github.com/rmr193/super-intel/blob/main/ml-service/supervised_classifier.pkl"
click node_docker_compose "https://github.com/rmr193/super-intel/blob/main/docker-compose.yml"
click node_root_vercel "https://github.com/rmr193/super-intel/blob/main/vercel.json"

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_frontend_app,node_frontend_main,node_dashboard_view,node_agent_details,node_alerts_center,node_stakeholder_queue,node_simulator_panel toneBlue
class node_backend_app,node_backend_server,node_backend_api,node_prisma_schema,node_seed_data,node_sqlite_db toneAmber
class node_ml_main,node_anomaly_model,node_classifier_model toneMint
class node_docker_compose,node_root_vercel toneRose
```

## Components

### Frontend

React operator dashboard and scenario driver

- [Dashboard](https://github.com/rmr193/super-intel/blob/main/frontend/src/App.tsx): React/Vite SPA · Operator-facing interface for monitoring, triage, and simulation · `frontend/src/App.tsx`
- [Entry](https://github.com/rmr193/super-intel/blob/main/frontend/src/main.tsx): Vite bootstrap · Frontend application bootstrap and mount point · `frontend/src/main.tsx`
- [Overview](https://github.com/rmr193/super-intel/blob/main/frontend/src/components/DashboardView.tsx): UI view · Main operational dashboard and summary panels · `frontend/src/components/DashboardView.tsx`
- [Agents](https://github.com/rmr193/super-intel/blob/main/frontend/src/components/AgentDetailsView.tsx): UI view · Agent liquidity and detail inspection panel · `frontend/src/components/AgentDetailsView.tsx`
- [Alerts](https://github.com/rmr193/super-intel/blob/main/frontend/src/components/AlertsCenterView.tsx): UI view · Alert display and triage center · `frontend/src/components/AlertsCenterView.tsx`
- [Queue](https://github.com/rmr193/super-intel/blob/main/frontend/src/components/StakeholderQueueView.tsx): UI view · Stakeholder review and escalation queue · `frontend/src/components/StakeholderQueueView.tsx`
- [Simulator](https://github.com/rmr193/super-intel/blob/main/frontend/src/components/SimulatorPanel.tsx): scenario driver · Controls for injecting demo states and operational stress · `frontend/src/components/SimulatorPanel.tsx`

### Backend

Express API and persistence layer

- [API App](https://github.com/rmr193/super-intel/blob/main/backend/src/app.ts): Express app · HTTP application layer and business logic · `backend/src/app.ts`
- [Server](https://github.com/rmr193/super-intel/blob/main/backend/src/server.ts): Node process · Backend runtime entrypoint and listener · `backend/src/server.ts`
- [API Entry](https://github.com/rmr193/super-intel/blob/main/backend/api/index.ts): deployment entry · Alternate backend entry used for hosting or routing · `backend/api/index.ts`
- [Schema](https://github.com/rmr193/super-intel/blob/main/backend/prisma/schema.prisma): Prisma model · Database schema for agents, cases, and operational state · `backend/prisma/schema.prisma`
- [Seed](https://github.com/rmr193/super-intel/blob/main/backend/prisma/seed.ts): bootstrap data · Initial sample agents and historical records · `backend/prisma/seed.ts`
- **SQLite**: local database · Source of truth for persistent operational state

### ML Service

Python inference and alert scoring service

- [Inference API](https://github.com/rmr193/super-intel/blob/main/ml-service/main.py): FastAPI service · Python service for anomaly and risk scoring · `ml-service/main.py`
- [Anomaly Model](https://github.com/rmr193/super-intel/blob/main/ml-service/anomaly_model.pkl): trained artifact · Offline-trained anomaly detector used at inference time · `ml-service/anomaly_model.pkl`
- [Classifier](https://github.com/rmr193/super-intel/blob/main/ml-service/supervised_classifier.pkl): trained artifact · Supervised scoring model for fallback-aware prediction support · `ml-service/supervised_classifier.pkl`

### Local Runtime

Packaging and orchestration for running the stack locally

- [Compose](https://github.com/rmr193/super-intel/blob/main/docker-compose.yml): orchestration · Local multi-service runtime configuration · `docker-compose.yml`
- [Vercel](https://github.com/rmr193/super-intel/blob/main/vercel.json): deployment config · Optional hosting and routing configuration · `vercel.json`

## Connections

- Entry → Dashboard: mounts · Bootstraps the dashboard UI
- Dashboard → Overview: renders · Composes the main operational overview
- Dashboard → Agents: renders · Shows per-agent liquidity and status
- Dashboard → Alerts: renders · Surfaces active alerts for triage
- Dashboard → Queue: renders · Supports escalation and review workflow
- Dashboard → Simulator: drives · Injects scenario conditions and demo states
- Dashboard → API App: http · Fetches and updates operational data
- Server → API App: starts · Runs the Express application process
- API Entry → API App: entry · Alternative hosted entrypoint
- API App → Schema: uses · Implements persistence contract through Prisma
- API App → SQLite: reads/writes · Stores agent state, cases, and history
- Seed → SQLite: initializes · Loads sample records into the database
- API App → Inference API: http · Requests anomaly and risk signals
- Inference API → Anomaly Model: loads · Uses trained detector at runtime
- Inference API → Classifier: loads · Uses supervised model for scoring support
- Simulator → API App: scenario api · Triggers controlled operational scenarios
- Compose → Dashboard: runs · Coordinates frontend service container
- Compose → API App: runs · Coordinates backend service container
- Compose → Inference API: runs · Coordinates ML service container
- Vercel → API Entry: hosts · Optional deployment routing for backend entry
