# hasini-kotha/fed_knowledge_graph_agentic_platform architecture

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

- Interactive diagram: https://gitdiagram.com/hasini-kotha/fed_knowledge_graph_agentic_platform
- Repository: https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform

## Overview

TraceAI is a privacy-preserving, cross-enterprise fraud and threat detection platform. Its documented workflow prepares private client data, trains and securely aggregates federated models, scores transactions, adds knowledge-graph context, generates explanations, and supports agent-driven response. A FastAPI service and Next.js console expose scanning, batch processing, decisions, administration, and federated-learning operations. The README documents the five-stage AI flow; source-index references show selected module relationships. Several runtime modules were not sampled, so uncertain internal links are omitted.

Main entry points: [`backend/main.py`](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/backend/main.py) (TraceAI API), [`src/fl/client.py`](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/fl/client.py) (Federated Client), [`src/gateway/routes.py`](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/gateway/routes.py) (Federated Gateway), [`src/main/run_data_pipeline.py`](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/main/run_data_pipeline.py) (Data Preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_console["User Console &amp; API"]
  node_console_ui["Web Console"]
  node_api_client["Frontend API Client<br/>[api.ts]"]
  node_api_server["TraceAI API<br/>[main.py]"]
  node_scan_batch["Scan &amp; Batch<br/>[scan.py]"]
  node_decision_admin["Decisions &amp; Admin<br/>[decisions.py]"]
end

subgraph group_federated["Federated Learning"]
  node_data_prep["Data Preparation"]
  node_metadata["Feature Mapping<br/>[metadata_engine.py]"]
  node_vectorizer["Feature Vectorizer<br/>[vectorizer.py]"]
  node_fl_client["Federated Client<br/>[client.py]"]
  node_train_engine["Training Engine<br/>[train_engine.py]"]
  node_secure_update["Secure Updates<br/>[secure_update.py]"]
  node_fl_server["Aggregation Server<br/>[server.py]"]
end

subgraph group_intelligence["Risk Intelligence"]
  node_model["Fraud Model<br/>[Fed_model.py]"]
  node_predictor["Risk Predictor<br/>[predictor.py]"]
  node_kg_builder["Knowledge Graph<br/>[kg_builder.py]"]
  node_kg_query["Graph Evidence Query<br/>[kg_query.py]"]
end

subgraph group_response["Explanation &amp; Response"]
  node_explainer["Explanation Generator"]
  node_agent["Agent Workflow<br/>[workflow.py]"]
  node_agent_actions["Response Actions<br/>[execute.py]"]
end

subgraph group_gateway["Gateway &amp; State"]
  node_gateway_routes["Federated Gateway<br/>[routes.py]"]
  node_auth["Gateway Authentication<br/>[auth.py]"]
  node_gateway_db[("Gateway Database<br/>[database.py]")]
end

node_enterprise(("Enterprise Operator"))

node_enterprise -->|"uses"| node_console_ui
node_console_ui -->|"requests data"| node_api_client
node_api_client -->|"calls API"| node_api_server
node_api_server -->|"mounts routes"| node_scan_batch
node_api_server -->|"mounts routes"| node_decision_admin
node_api_server -->|"mounts gateway"| node_gateway_routes
node_api_server -->|"initializes"| node_gateway_db
node_enterprise -.->|"provides private data"| node_data_prep
node_data_prep -->|"loads mapping"| node_metadata
node_data_prep -->|"fits features"| node_vectorizer
node_fl_client -->|"trains locally"| node_train_engine
node_fl_client -->|"uses model"| node_model
node_fl_client -->|"protects updates"| node_secure_update
node_fl_client -.->|"submits updates"| node_gateway_routes
node_gateway_routes -->|"authenticates"| node_auth
node_gateway_routes -->|"reads and writes"| node_gateway_db
node_fl_server -.->|"aggregates protected weights"| node_secure_update
node_fl_server -.->|"updates global model"| node_model
node_predictor -->|"loads model"| node_model
node_scan_batch -.->|"scores transactions"| node_predictor
node_predictor -->|"supplies risk scores"| node_kg_builder
node_kg_builder -.->|"builds queryable graph"| node_kg_query
node_kg_query -->|"provides evidence"| node_explainer
node_kg_query -->|"provides evidence"| node_agent
node_explainer -.->|"returns reasoning"| node_enterprise
node_agent -.->|"dispatches actions"| node_agent_actions

click node_console_ui "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/tree/main/frontend/src/app"
click node_api_client "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/frontend/src/lib/api.ts"
click node_api_server "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/backend/main.py"
click node_scan_batch "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/backend/routers/scan.py"
click node_decision_admin "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/backend/routers/decisions.py"
click node_data_prep "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/main/run_data_pipeline.py"
click node_metadata "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/core/metadata_engine.py"
click node_vectorizer "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/core/vectorizer.py"
click node_fl_client "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/fl/client.py"
click node_train_engine "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/models/train_engine.py"
click node_secure_update "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/fl/secure_update.py"
click node_fl_server "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/fl/server.py"
click node_model "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/models/Fed_model.py"
click node_predictor "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/prediction/predictor.py"
click node_kg_builder "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/kg/kg_builder.py"
click node_kg_query "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/kg/kg_query.py"
click node_explainer "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/explain/explanation_generator.py"
click node_agent "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/agent/workflow.py"
click node_agent_actions "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/agent/nodes/execute.py"
click node_gateway_routes "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/gateway/routes.py"
click node_auth "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/gateway/auth.py"
click node_gateway_db "https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/gateway/database.py"

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_console_ui,node_api_client,node_api_server,node_scan_batch,node_decision_admin toneBlue
class node_data_prep,node_metadata,node_vectorizer,node_fl_client,node_train_engine,node_secure_update,node_fl_server toneAmber
class node_model,node_predictor,node_kg_builder,node_kg_query toneMint
class node_explainer,node_agent,node_agent_actions toneRose
class node_gateway_routes,node_auth,node_gateway_db,node_enterprise toneIndigo
```

## Components

### User Console & API

- [Web Console](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/tree/main/frontend/src/app): `frontend/src/app`
- [Frontend API Client](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [TraceAI API](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/backend/main.py): `backend/main.py`
- [Scan & Batch](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/backend/routers/scan.py): `backend/routers/scan.py`
- [Decisions & Admin](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/backend/routers/decisions.py): `backend/routers/decisions.py`

### Federated Learning

- [Data Preparation](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/main/run_data_pipeline.py): `src/main/run_data_pipeline.py`
- [Feature Mapping](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/core/metadata_engine.py): `src/core/metadata_engine.py`
- [Feature Vectorizer](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/core/vectorizer.py): `src/core/vectorizer.py`
- [Federated Client](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/fl/client.py): `src/fl/client.py`
- [Training Engine](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/models/train_engine.py): `src/models/train_engine.py`
- [Secure Updates](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/fl/secure_update.py): `src/fl/secure_update.py`
- [Aggregation Server](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/fl/server.py): `src/fl/server.py`

### Risk Intelligence

- [Fraud Model](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/models/Fed_model.py): `src/models/Fed_model.py`
- [Risk Predictor](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/prediction/predictor.py): `src/prediction/predictor.py`
- [Knowledge Graph](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/kg/kg_builder.py): `src/kg/kg_builder.py`
- [Graph Evidence Query](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/kg/kg_query.py): `src/kg/kg_query.py`

### Explanation & Response

- [Explanation Generator](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/explain/explanation_generator.py): `src/explain/explanation_generator.py`
- [Agent Workflow](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/agent/workflow.py): `src/agent/workflow.py`
- [Response Actions](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/agent/nodes/execute.py): `src/agent/nodes/execute.py`

### Gateway & State

- [Federated Gateway](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/gateway/routes.py): `src/gateway/routes.py`
- [Gateway Authentication](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/gateway/auth.py): `src/gateway/auth.py`
- [Gateway Database](https://github.com/hasini-kotha/fed_knowledge_graph_agentic_platform/blob/main/src/gateway/database.py): `src/gateway/database.py`

### Other components

- **Enterprise Operator**

## Connections

- Enterprise Operator → Web Console: uses (evidence: `README.md`)
- Web Console → Frontend API Client: requests data (evidence: `README.md`)
- Frontend API Client → TraceAI API: calls API (evidence: `backend/main.py`)
- TraceAI API → Scan & Batch: mounts routes (evidence: `backend/main.py`)
- TraceAI API → Decisions & Admin: mounts routes (evidence: `backend/main.py`)
- TraceAI API → Federated Gateway: mounts gateway (evidence: `backend/main.py`)
- TraceAI API → Gateway Database: initializes (evidence: `backend/main.py`)
- Enterprise Operator → Data Preparation: provides private data (evidence: `README.md`)
- Data Preparation → Feature Mapping: loads mapping (evidence: `src/main/run_data_pipeline.py`)
- Data Preparation → Feature Vectorizer: fits features (evidence: `src/main/run_data_pipeline.py`)
- Federated Client → Training Engine: trains locally (evidence: `src/fl/client.py`)
- Federated Client → Fraud Model: uses model (evidence: `src/fl/client.py`)
- Federated Client → Secure Updates: protects updates (evidence: `src/fl/client.py`)
- Federated Client → Federated Gateway: submits updates
- Federated Gateway → Gateway Authentication: authenticates (evidence: `src/gateway/routes.py`)
- Federated Gateway → Gateway Database: reads and writes (evidence: `src/gateway/routes.py`)
- Aggregation Server → Secure Updates: aggregates protected weights (evidence: `README.md`)
- Aggregation Server → Fraud Model: updates global model (evidence: `README.md`)
- Risk Predictor → Fraud Model: loads model (evidence: `src/prediction/predictor.py`)
- Scan & Batch → Risk Predictor: scores transactions
- Risk Predictor → Knowledge Graph: supplies risk scores (evidence: `src/main/run_kg_pipeline.py`)
- Knowledge Graph → Graph Evidence Query: builds queryable graph
- Graph Evidence Query → Explanation Generator: provides evidence (evidence: `src/kg/kg_query.py`)
- Graph Evidence Query → Agent Workflow: provides evidence (evidence: `src/kg/kg_query.py`)
- Explanation Generator → Enterprise Operator: returns reasoning (evidence: `README.md`)
- Agent Workflow → Response Actions: dispatches actions (evidence: `README.md`)
