# qiaoyi12/fyp architecture

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

- Interactive diagram: https://gitdiagram.com/qiaoyi12/fyp
- Repository: https://github.com/qiaoyi12/fyp

## Overview

TriageAI is a Flask SOC workflow: staff upload network-flow CSVs, the backend stores uploads and runs ML triage, then users review alerts/logs, assign and investigate tickets, and resolve or report incidents. Role-scoped pages and APIs expose the workflow; SQLite-backed models hold users, analyses, alerts, traffic logs, assignments, blacklist entries, and reports. Assignment, chatbot, and analyst-support agents are distinct assistance branches. Some service and model internals are unsampled, so edges to them rely on the SOURCE INDEX or README rather than inferred call chains.

Main entry points: [`app.py`](https://github.com/qiaoyi12/fyp/blob/main/app.py) (Flask app), [`backend/src/services/data_service.py`](https://github.com/qiaoyi12/fyp/blob/main/backend/src/services/data_service.py) (SOC data services), [`backend/src/routes/upload.py`](https://github.com/qiaoyi12/fyp/blob/main/backend/src/routes/upload.py) (Upload API), [`backend/src/database/models.py`](https://github.com/qiaoyi12/fyp/blob/main/backend/src/database/models.py) (SOC records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interface"]
  node_flask["Flask app<br/>[app.py]"]
  node_webui["SOC pages"]
  node_reactui["React routes<br/>[App.jsx]"]
  node_page_routes["Page routes<br/>[pages.py]"]
end

subgraph group_detection["Ingestion and detection"]
  node_upload_routes["Upload API<br/>[upload.py]"]
  node_preprocess["CSV preprocessing<br/>[preprocess.py]"]
  node_prediction["ML inference<br/>[predict.py]"]
end

subgraph group_operations["SOC operations"]
  node_data_service["SOC data services<br/>[data_service.py]"]
  node_analyst_routes["Analyst API<br/>[analyst.py]"]
  node_chat_routes["Chatbot API<br/>[chatbot_routes.py]"]
end

subgraph group_assistants["AI assistance"]
  node_assignment_agent["Ticket assignment"]
  node_assignment_tools["Assignment tools"]
  node_distribution["Fallback planning"]
  node_soc_chatbot["SOC chatbot<br/>[soc_chatbot.py]"]
  node_chat_tools["Chat context tools<br/>[chatbot_tools.py]"]
  node_analyst_agent["Analyst support<br/>[analyst_agent.py]"]
end

subgraph group_persistence["Application data"]
  node_db[("SQLite database<br/>[db.py]")]
  node_models["SOC records<br/>[models.py]"]
end

node_staff(("SOC staff"))

node_staff -->|"uses"| node_webui
node_webui -->|"requests pages"| node_flask
node_flask -->|"registers"| node_page_routes
node_flask -->|"registers"| node_upload_routes
node_flask -->|"registers"| node_chat_routes
node_flask -->|"registers"| node_analyst_routes
node_page_routes -->|"calls"| node_data_service
node_page_routes -->|"uses upload helper"| node_upload_routes
node_staff -->|"uploads CSV"| node_upload_routes
node_upload_routes -->|"validates features"| node_preprocess
node_data_service -->|"preprocesses traffic"| node_preprocess
node_data_service -->|"classifies flows"| node_prediction
node_data_service -->|"starts assignment"| node_assignment_agent
node_data_service -->|"reads and writes"| node_models
node_upload_routes -->|"records uploads"| node_models
node_page_routes -->|"queries users and logs"| node_models
node_assignment_agent -->|"fetches and assigns"| node_assignment_tools
node_assignment_agent -->|"uses fallback"| node_distribution
node_assignment_tools -->|"queries and updates"| node_models
node_chat_routes -->|"calls"| node_soc_chatbot
node_soc_chatbot -->|"uses"| node_chat_tools
node_chat_tools -->|"reads SOC context"| node_data_service
node_analyst_routes -->|"invokes support"| node_analyst_agent
node_models -->|"defines ORM records"| node_db
node_reactui -->|"fetches session"| node_flask

click node_flask "https://github.com/qiaoyi12/fyp/blob/main/app.py"
click node_webui "https://github.com/qiaoyi12/fyp/tree/main/frontend"
click node_reactui "https://github.com/qiaoyi12/fyp/blob/main/frontend/src/App.jsx"
click node_page_routes "https://github.com/qiaoyi12/fyp/blob/main/backend/src/routes/pages.py"
click node_upload_routes "https://github.com/qiaoyi12/fyp/blob/main/backend/src/routes/upload.py"
click node_preprocess "https://github.com/qiaoyi12/fyp/blob/main/backend/src/ml/preprocess.py"
click node_prediction "https://github.com/qiaoyi12/fyp/blob/main/backend/src/ml/predict.py"
click node_data_service "https://github.com/qiaoyi12/fyp/blob/main/backend/src/services/data_service.py"
click node_analyst_routes "https://github.com/qiaoyi12/fyp/blob/main/backend/src/routes/analyst.py"
click node_chat_routes "https://github.com/qiaoyi12/fyp/blob/main/backend/src/routes/chatbot_routes.py"
click node_assignment_agent "https://github.com/qiaoyi12/fyp/blob/main/agenticAI/assignment_agent.py"
click node_assignment_tools "https://github.com/qiaoyi12/fyp/blob/main/agenticAI/assignment_tools.py"
click node_distribution "https://github.com/qiaoyi12/fyp/blob/main/agenticAI/distribution_plan.py"
click node_soc_chatbot "https://github.com/qiaoyi12/fyp/blob/main/agenticAI/soc_chatbot.py"
click node_chat_tools "https://github.com/qiaoyi12/fyp/blob/main/agenticAI/chatbot_tools.py"
click node_analyst_agent "https://github.com/qiaoyi12/fyp/blob/main/agenticAI/analyst_agent.py"
click node_db "https://github.com/qiaoyi12/fyp/blob/main/backend/src/database/db.py"
click node_models "https://github.com/qiaoyi12/fyp/blob/main/backend/src/database/models.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_flask,node_webui,node_reactui,node_page_routes toneBlue
class node_upload_routes,node_preprocess,node_prediction toneAmber
class node_data_service,node_analyst_routes,node_chat_routes toneMint
class node_assignment_agent,node_assignment_tools,node_distribution,node_soc_chatbot,node_chat_tools,node_analyst_agent toneRose
class node_db,node_models,node_staff toneIndigo
```

## Components

### User interface

- [Flask app](https://github.com/qiaoyi12/fyp/blob/main/app.py): `app.py`
- [SOC pages](https://github.com/qiaoyi12/fyp/tree/main/frontend): `frontend`
- [React routes](https://github.com/qiaoyi12/fyp/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Page routes](https://github.com/qiaoyi12/fyp/blob/main/backend/src/routes/pages.py): `backend/src/routes/pages.py`

### Ingestion and detection

- [Upload API](https://github.com/qiaoyi12/fyp/blob/main/backend/src/routes/upload.py): `backend/src/routes/upload.py`
- [CSV preprocessing](https://github.com/qiaoyi12/fyp/blob/main/backend/src/ml/preprocess.py): `backend/src/ml/preprocess.py`
- [ML inference](https://github.com/qiaoyi12/fyp/blob/main/backend/src/ml/predict.py): `backend/src/ml/predict.py`

### SOC operations

- [SOC data services](https://github.com/qiaoyi12/fyp/blob/main/backend/src/services/data_service.py): `backend/src/services/data_service.py`
- [Analyst API](https://github.com/qiaoyi12/fyp/blob/main/backend/src/routes/analyst.py): `backend/src/routes/analyst.py`
- [Chatbot API](https://github.com/qiaoyi12/fyp/blob/main/backend/src/routes/chatbot_routes.py): `backend/src/routes/chatbot_routes.py`

### AI assistance

- [Ticket assignment](https://github.com/qiaoyi12/fyp/blob/main/agenticAI/assignment_agent.py): `agenticAI/assignment_agent.py`
- [Assignment tools](https://github.com/qiaoyi12/fyp/blob/main/agenticAI/assignment_tools.py): `agenticAI/assignment_tools.py`
- [Fallback planning](https://github.com/qiaoyi12/fyp/blob/main/agenticAI/distribution_plan.py): `agenticAI/distribution_plan.py`
- [SOC chatbot](https://github.com/qiaoyi12/fyp/blob/main/agenticAI/soc_chatbot.py): `agenticAI/soc_chatbot.py`
- [Chat context tools](https://github.com/qiaoyi12/fyp/blob/main/agenticAI/chatbot_tools.py): `agenticAI/chatbot_tools.py`
- [Analyst support](https://github.com/qiaoyi12/fyp/blob/main/agenticAI/analyst_agent.py): `agenticAI/analyst_agent.py`

### Application data

- [SQLite database](https://github.com/qiaoyi12/fyp/blob/main/backend/src/database/db.py): `backend/src/database/db.py`
- [SOC records](https://github.com/qiaoyi12/fyp/blob/main/backend/src/database/models.py): `backend/src/database/models.py`

### Other components

- **SOC staff**

## Connections

- SOC staff → SOC pages: uses (evidence: `README.md`)
- SOC pages → Flask app: requests pages (evidence: `README.md`)
- Flask app → Page routes: registers (evidence: `app.py`)
- Flask app → Upload API: registers (evidence: `app.py`)
- Flask app → Chatbot API: registers (evidence: `app.py`)
- Flask app → Analyst API: registers (evidence: `app.py`)
- Page routes → SOC data services: calls (evidence: `backend/src/routes/pages.py`)
- Page routes → Upload API: uses upload helper (evidence: `backend/src/routes/pages.py`)
- SOC staff → Upload API: uploads CSV (evidence: `README.md`)
- Upload API → CSV preprocessing: validates features (evidence: `backend/src/routes/upload.py`)
- SOC data services → CSV preprocessing: preprocesses traffic (evidence: `backend/src/services/data_service.py`)
- SOC data services → ML inference: classifies flows (evidence: `backend/src/services/data_service.py`)
- SOC data services → Ticket assignment: starts assignment (evidence: `backend/src/services/data_service.py`)
- SOC data services → SOC records: reads and writes (evidence: `backend/src/services/data_service.py`)
- Upload API → SOC records: records uploads (evidence: `backend/src/routes/upload.py`)
- Page routes → SOC records: queries users and logs (evidence: `backend/src/routes/pages.py`)
- Ticket assignment → Assignment tools: fetches and assigns (evidence: `agenticAI/assignment_agent.py`)
- Ticket assignment → Fallback planning: uses fallback (evidence: `agenticAI/assignment_agent.py`)
- Assignment tools → SOC records: queries and updates (evidence: `agenticAI/assignment_tools.py`)
- Chatbot API → SOC chatbot: calls (evidence: `backend/src/routes/chatbot_routes.py`)
- SOC chatbot → Chat context tools: uses (evidence: `agenticAI/soc_chatbot.py`)
- Chat context tools → SOC data services: reads SOC context (evidence: `agenticAI/chatbot_tools.py`)
- Analyst API → Analyst support: invokes support (evidence: `backend/src/routes/analyst.py`)
- SOC records → SQLite database: defines ORM records (evidence: `backend/src/database/models.py`)
- React routes → Flask app: fetches session (evidence: `frontend/src/App.jsx`)
