# shivamtiwari01016/nlp architecture

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

- Interactive diagram: https://gitdiagram.com/shivamtiwari01016/nlp
- Repository: https://github.com/shivamtiwari01016/nlp

## Overview

Support Ticket Triage is a browser-based console backed by a FastAPI service. Operators submit ticket text; the API classifies its category, independently scores sentiment-based urgency, maps the category to a team, and persists the ticket with its prediction before returning a result. The console also presents ticket history, database statistics, model metrics, and an explainer for the NLP pipeline. Training uses the Kaggle-derived data and produces the classifier and evaluation metrics. The workflow follows the README and sampled service/client code; detailed route wiring and model internals were not sampled.

Main entry points: [`frontend/src/services/api.js`](https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/services/api.js) (HTTP client), [`src/ticket_triage/api.py`](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/api.py) (FastAPI routes), [`src/ticket_triage/services/prediction_service.py`](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/services/prediction_service.py) (Prediction workflow), [`src/ticket_triage/train.py`](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/train.py) (Training workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Triage console"]
  node_app["Web application<br/>[App.jsx]"]
  node_analyzer["Ticket analyzer<br/>[TicketAnalyzer.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_model_info["Model information<br/>[ModelInfo.jsx]"]
  node_pipeline_view["Pipeline explainer<br/>[Pipeline.jsx]"]
  node_api_client["HTTP client<br/>[api.js]"]
end

subgraph group_api["API workflows"]
  node_fastapi["FastAPI routes<br/>[api.py]"]
  node_prediction_service["Prediction workflow"]
  node_ticket_service["Ticket read workflows<br/>[ticket_service.py]"]
end

subgraph group_inference["Inference and routing"]
  node_classifier["Category classifier<br/>[model.py]"]
  node_preprocessing["Text preprocessing<br/>[preprocessing.py]"]
  node_urgency["Urgency scoring<br/>[urgency.py]"]
  node_routing["Team assignment<br/>[routing_service.py]"]
end

subgraph group_storage["Ticket persistence"]
  node_repository["Ticket repository"]
  node_database[("MySQL database<br/>[models.py]")]
end

subgraph group_training["Model training"]
  node_training["Training workflow<br/>[train.py]"]
  node_data_prep["Label preparation<br/>[data.py]"]
  node_metrics["Evaluation metrics<br/>[api.py]"]
end

node_operator(("Support operator"))
node_nlp_tools{{"spaCy and VADER"}}

node_operator -->|"enters ticket"| node_analyzer
node_app -->|"loads history and health"| node_api_client
node_analyzer -->|"submits ticket"| node_api_client
node_dashboard -->|"requests dashboard data"| node_api_client
node_model_info -->|"requests metrics"| node_api_client
node_api_client -->|"sends HTTP requests"| node_fastapi
node_fastapi -->|"dispatches inference"| node_prediction_service
node_fastapi -->|"dispatches reads"| node_ticket_service
node_prediction_service -->|"predicts category"| node_classifier
node_classifier -->|"transforms text"| node_preprocessing
node_prediction_service -->|"scores sentiment"| node_urgency
node_urgency -.->|"uses VADER"| node_nlp_tools
node_prediction_service -->|"assigns team"| node_routing
node_prediction_service -->|"saves prediction"| node_repository
node_ticket_service -->|"queries tickets"| node_repository
node_repository -->|"reads and writes"| node_database
node_training -->|"prepares labels"| node_data_prep
node_training -->|"builds text features"| node_preprocessing
node_training -->|"trains classifier"| node_classifier
node_training -.->|"uses spaCy"| node_nlp_tools
node_fastapi -->|"serves evaluation"| node_metrics
node_fastapi -->|"returns API data"| node_api_client

click node_app "https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/App.jsx"
click node_analyzer "https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/pages/TicketAnalyzer.jsx"
click node_dashboard "https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/pages/Dashboard.jsx"
click node_model_info "https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/pages/ModelInfo.jsx"
click node_pipeline_view "https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/pages/Pipeline.jsx"
click node_api_client "https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/services/api.js"
click node_fastapi "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/api.py"
click node_prediction_service "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/services/prediction_service.py"
click node_ticket_service "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/services/ticket_service.py"
click node_classifier "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/model.py"
click node_preprocessing "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/preprocessing.py"
click node_urgency "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/urgency.py"
click node_routing "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/services/routing_service.py"
click node_repository "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/repositories/ticket_repository.py"
click node_database "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/models.py"
click node_training "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/train.py"
click node_data_prep "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/data.py"
click node_metrics "https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/api.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_app,node_analyzer,node_dashboard,node_model_info,node_pipeline_view,node_api_client toneBlue
class node_fastapi,node_prediction_service,node_ticket_service toneAmber
class node_classifier,node_preprocessing,node_urgency,node_routing toneMint
class node_repository,node_database toneRose
class node_training,node_data_prep,node_metrics,node_operator,node_nlp_tools toneIndigo
```

## Components

### Triage console

- [Web application](https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Ticket analyzer](https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/pages/TicketAnalyzer.jsx): `frontend/src/pages/TicketAnalyzer.jsx`
- [Dashboard](https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Model information](https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/pages/ModelInfo.jsx): `frontend/src/pages/ModelInfo.jsx`
- [Pipeline explainer](https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/pages/Pipeline.jsx): `frontend/src/pages/Pipeline.jsx`
- [HTTP client](https://github.com/shivamtiwari01016/nlp/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### API workflows

- [FastAPI routes](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/api.py): `src/ticket_triage/api.py`
- [Prediction workflow](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/services/prediction_service.py): `src/ticket_triage/services/prediction_service.py`
- [Ticket read workflows](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/services/ticket_service.py): `src/ticket_triage/services/ticket_service.py`

### Inference and routing

- [Category classifier](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/model.py): `src/ticket_triage/model.py`
- [Text preprocessing](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/preprocessing.py): `src/ticket_triage/preprocessing.py`
- [Urgency scoring](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/urgency.py): `src/ticket_triage/urgency.py`
- [Team assignment](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/services/routing_service.py): `src/ticket_triage/services/routing_service.py`

### Ticket persistence

- [Ticket repository](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/repositories/ticket_repository.py): `src/ticket_triage/repositories/ticket_repository.py`
- [MySQL database](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/models.py): `src/ticket_triage/models.py`

### Model training

- [Training workflow](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/train.py): `src/ticket_triage/train.py`
- [Label preparation](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/data.py): `src/ticket_triage/data.py`
- [Evaluation metrics](https://github.com/shivamtiwari01016/nlp/blob/main/src/ticket_triage/api.py): `src/ticket_triage/api.py`

### Other components

- **Support operator**
- **spaCy and VADER**

## Connections

- Support operator → Ticket analyzer: enters ticket
- Web application → HTTP client: loads history and health
- Ticket analyzer → HTTP client: submits ticket
- Dashboard → HTTP client: requests dashboard data
- Model information → HTTP client: requests metrics
- HTTP client → FastAPI routes: sends HTTP requests
- FastAPI routes → Prediction workflow: dispatches inference
- FastAPI routes → Ticket read workflows: dispatches reads
- Prediction workflow → Category classifier: predicts category
- Category classifier → Text preprocessing: transforms text
- Prediction workflow → Urgency scoring: scores sentiment
- Urgency scoring → spaCy and VADER: uses VADER
- Prediction workflow → Team assignment: assigns team
- Prediction workflow → Ticket repository: saves prediction
- Ticket read workflows → Ticket repository: queries tickets
- Ticket repository → MySQL database: reads and writes
- Training workflow → Label preparation: prepares labels
- Training workflow → Text preprocessing: builds text features
- Training workflow → Category classifier: trains classifier
- Training workflow → spaCy and VADER: uses spaCy
- FastAPI routes → Evaluation metrics: serves evaluation
- FastAPI routes → HTTP client: returns API data
