# priyankabedekar-ms/fintech-case-console architecture

> Architecture diagram of the GitHub repository priyankabedekar-ms/fintech-case-console, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/priyankabedekar-ms/fintech-case-console
- Repository: https://github.com/priyankabedekar-ms/fintech-case-console

## Overview

##### Project type and purpose
- This is a full-stack fintech case-resolution console (“Zeta Sentinel”) comprising:
- A React/TypeScript single-page UI (`web/`)
- An Express/TypeScript API (`api/`)
- A PostgreSQL relational store and Redis for rate-limiting & job queuing
- Docker Compose for local development and orchestration
- Its purpose is to ingest alerts, run multi-agent AI triage, stream recommendations via SSE to the UI, execute user-driven actions (e.g., freeze card), record audit trails, and expose Prometheus metrics.

##### File structure
- Top-level:
- `api/` – source, Prisma schema, migrations, Dockerfile
- `web/` – React app, Vite config, Dockerfile
- `docker-compose.yml` – orchestrates api, web, postgres, redis, prometheus
- `docs/` – ADRs, fixtures, Postman collections
- `api/src/`:
- `routes/` – HTTP endpoints (triage, actions, alerts, insights)
- `agents/` – orchestrator drives sub-agents (profile, riskSignals, decision)
- `middleware/` – rate limit, security, metrics
- `lib/` – Redis client, PII redactor, metrics helpers
- `eval/` – offline evaluation suite
- `web/src/`:
- `components/`, `pages/`, `hooks/` – UI layers, SSE client, API wrapper
- `styles/`, assets, entry & HTML

##### README insights
- Request flow: POST /triage → orchestrator → SSE → UI; POST /action/* → audit event
- Key architectural decisions: server-sent events, token-bucket rate limit, PII redaction at edge, event sourcing for audit, idempotency, Prisma ORM

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "🛠️ Docker Compose Network"
        direction TB

        subgraph "🎨 Frontend (Port 5173)"
            direction TB
            UIApp["React SPA"]:::ui
            Entry["Entry Point & Config"]:::ui_comp
            Layout["Layout.tsx"]:::ui_comp
            Drawer["TriageDrawer.tsx"]:::ui_comp
            AlertsPage["Alerts.tsx"]:::ui_page
            DashboardPage["Dashboard.tsx"]:::ui_page
            Styles["Styles & Assets"]:::ui_comp
            SSEHook["useTriageStream.ts"]:::ui_comp
            APIWrapper["api.ts"]:::ui_comp

            UIApp --> Entry
            UIApp --> Layout
            UIApp --> Drawer
            UIApp --> AlertsPage
            UIApp --> DashboardPage
            UIApp --> SSEHook
            UIApp --> APIWrapper
            UIApp --> Styles
        end

        subgraph "🔧 Backend (Port 3000)"
            direction TB
            API["Express API"]:::api
            Index["index.ts"]:::api_comp

            subgraph "HTTP Routes"
                direction TB
                Triage["triage.ts"]:::api_comp
                AlertsEP["alerts.ts"]:::api_comp
                Actions["actions.ts"]:::api_comp
                Insights["insights.ts"]:::api_comp
                Ingest["ingest.ts"]:::api_comp
                Customer["customer.ts"]:::api_comp
            end

            subgraph "Orchestrator & Agents"
                direction TB
                Orchestrator["orchestrator.ts"]:::api_comp
            end

            EvalRunner["runner.ts"]:::api_comp

            subgraph "Middleware"
                direction TB
                RateLimit["rateLimit.ts"]:::api_comp
                Security["security.ts"]:::api_comp
                MetricsMid["metrics.ts"]:::api_comp
            end

            subgraph "Shared Libraries"
                direction TB
                RedisLib["redis.ts"]:::api_comp
                Redactor["redactor.ts"]:::api_comp
                MetricsLib["metrics.ts"]:::api_comp
            end

            subgraph "Prisma ORM"
                direction TB
                Schema["schema.prisma"]:::api_comp
                Migrations["migrations/20251026134334_init/"]:::api_comp
                Seed["seed.ts"]:::api_comp
            end

            API --> Index
            API --> Triage
            API --> AlertsEP
            API --> Actions
            API --> Insights
            API --> Ingest
            API --> Customer
            API --> Orchestrator
            API --> EvalRunner
            API --> RateLimit
            API --> Security
            API --> MetricsMid
            API --> RedisLib
            API --> Redactor
            API --> MetricsLib
            API --> Schema
            API --> Migrations
            API --> Seed
        end

        subgraph "📦 Data Stores"
            direction TB
            Postgres[(PostgreSQL)]:::db
            Redis[(Redis)]:::db
        end

        subgraph "📊 Observability"
            direction TB
            Prometheus[(Prometheus)]:::obs
            Grafana[(Grafana)]:::obs
        end

        ExternalLLM[(External LLM Service)]:::external
    end

    UIApp -->|"POST /triage"| API
    API -->|"SSE Stream"| UIApp
    UIApp -->|"POST /action/*"| API
    API -->|"Prisma ORM"| Postgres
    API -->|"Rate Limit & Queue"| Redis
    API -->|"Metrics Endpoint"| Prometheus
    Prometheus -->|"Dashboards"| Grafana
    API -->|"LLM_ENABLED call"| ExternalLLM

    click UIApp "https://github.com/priyankabedekar-ms/fintech-case-console/tree/main/web/"
    click Entry "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/web/src/main.tsx"
    click Entry "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/web/index.html"
    click Entry "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/web/vite.config.ts"
    click Layout "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/web/src/components/Layout.tsx"
    click Drawer "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/web/src/components/TriageDrawer.tsx"
    click AlertsPage "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/web/src/pages/Alerts.tsx"
    click DashboardPage "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/web/src/pages/Dashboard.tsx"
    click Styles "https://github.com/priyankabedekar-ms/fintech-case-console/tree/main/web/src/styles/"
    click Styles "https://github.com/priyankabedekar-ms/fintech-case-console/tree/main/web/src/assets/"
    click SSEHook "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/web/src/hooks/useTriageStream.ts"
    click APIWrapper "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/web/src/lib/api.ts"
    click Index "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/index.ts"
    click Triage "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/routes/triage.ts"
    click AlertsEP "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/routes/alerts.ts"
    click Actions "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/routes/actions.ts"
    click Insights "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/routes/insights.ts"
    click Ingest "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/routes/ingest.ts"
    click Customer "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/routes/customer.ts"
    click Orchestrator "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/agents/orchestrator.ts"
    click EvalRunner "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/eval/runner.ts"
    click RateLimit "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/middleware/rateLimit.ts"
    click Security "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/middleware/security.ts"
    click MetricsMid "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/middleware/metrics.ts"
    click RedisLib "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/lib/redis.ts"
    click Redactor "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/lib/redactor.ts"
    click MetricsLib "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/src/lib/metrics.ts"
    click Schema "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/prisma/schema.prisma"
    click Migrations "https://github.com/priyankabedekar-ms/fintech-case-console/tree/main/api/prisma/migrations/20251026134334_init/"
    click Seed "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/api/prisma/seed.ts"
    click DockerCompose "https://github.com/priyankabedekar-ms/fintech-case-console/blob/main/docker-compose.yml"
    click API "https://github.com/priyankabedekar-ms/fintech-case-console/tree/main/api/Dockerfile"
    click UIApp "https://github.com/priyankabedekar-ms/fintech-case-console/tree/main/web/Dockerfile"

    classDef ui fill:#D0E8FF,stroke:#0366d6,stroke-width:2px
    classDef ui_comp fill:#EAF6FF,stroke:#0366d6
    classDef ui_page fill:#EAF6FF,stroke:#0366d6,stroke-dasharray:2 2
    classDef api fill:#E0FFE0,stroke:#34A853,stroke-width:2px
    classDef api_comp fill:#F0FFF0,stroke:#34A853
    classDef db fill:#FFD9B3,stroke:#D2691E,stroke-width:2px
    classDef obs fill:#E5D4FD,stroke:#6F42C1,stroke-width:2px
    classDef external fill:#F0F0F0,stroke:#999999,stroke-dasharray:5 5
```
