# hamzicodes/ids_project-srs_classification architecture

> Architecture diagram of the GitHub repository hamzicodes/ids_project-srs_classification, 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/hamzicodes/ids_project-srs_classification
- Repository: https://github.com/hamzicodes/ids_project-srs_classification

## Overview

#### Purpose and Entry Points
Vertex IDS classifies software-requirement text as functional, non-functional (with NFR categories), or irrelevant. Main operational entry points are batch training via `PROJECT/RUN_PIPELINE_TRAINING.py`, browser testing via `PROJECT/streamlit_ui.py`, API serving via `backend/app/main.py` (or deployment wrapper `run.py`), and the Flutter client via `vertex_app/lib/main.dart`.

#### Training Pipeline
The numbered Python pipeline builds reproducible artifacts from CSV datasets. It trains an outlier gate, merges source data, filters irrelevant text, analyzes and cleans requirements, creates TF-IDF features, then trains/exports classifiers.
- `PROJECT/0_Outlier_Training.py`
- `PROJECT/1_Load_and_Merge.py`
- `PROJECT/2_Outlier_Gate.py`
- `PROJECT/4_Data_Cleaning.py`
- `PROJECT/5_Feature_Engineering.py`
- `PROJECT/6_Model_Training_and_Export.py`

Shared preprocessing/pipeline conventions reside in `PROJECT/pipeline_common.py`; input and intermediate datasets are persisted under `DATASETS/`.

#### Model and Artifact Boundary
Training outputs serialized scikit-learn-compatible artifacts consumed unchanged by UIs and APIs. The principal boundary is `trained_models/`: FR/NFR model, NFR-type model, vectorizer, labels, metadata, plus independent outlier models.
- `trained_models/FR_NFRTrained_models/model_fr_nfr.pkl`
- `trained_models/FR_NFRTrained_models/vectorizer_combined.pkl`
- `trained_models/outlierTrained_model/outlier_classifier.pkl`

Changing source data or cleaning/vectorization requires retraining so artifact schemas remain compatible with serving.

#### Inference Service
FastAPI is the server-side inference contract. `backend/app/main.py` exposes health, prediction, and model-information endpoints; request/response shapes are defined in `backend/app/schemas.py`. `backend/app/model_loader.py` loads the persisted artifacts, while `backend/app/predictor.py` applies item splitting, outlier checks, preprocessing/vectorization, FR/NFR prediction, NFR-category prediction, and result grouping.

The repository also contains a deployment-adjacent backend copy at `vertex_app/backend/app/main.py`; it should be treated as a synchronization risk if backend logic evolves.

#### Prediction Flow
Input text may contain multiple requirement items. Each item crosses an eligibility boundary: outlier rules/model can return “neither”; valid items are normalized and vectorized; the FR/NFR model determines top-level class; NFR items receive one or more category predictions. Results are grouped into functional, non-functional, neither, item details, and aggregate counts before returning through API/UI boundaries.

#### Client Layers
The Streamlit interface directly exercises trained inference behavior for quick manual testing: `PROJECT/streamlit_ui.py`. The Flutter application is the primary product client, with routing/app composition in `vertex_app/lib/app/app.dart` and `vertex_app/lib/app/router.dart`. Its chat feature owns API/repository/controller flow:
- `vertex_app/lib/features/chat/data/chat_api.dart`
- `vertex_app/lib/features/chat/data/chat_repository.dart`
- `vertex_app/lib/features/chat/presentation/controller/chat_controller.dart`

It also exposes model information, diagnostics, CSV export, and PDF sharing.

#### Runtime and Infrastructure
Python runtime uses Pandas/NumPy/SciPy, NLTK, scikit-learn, Streamlit, FastAPI/Uvicorn, and Pydantic; dependency scopes are in `PROJECT/requirements.txt` and `backend/requirements.txt`. Flutter/Dart provides Android, iOS, desktop, and web clients, configured by `vertex_app/pubspec.yaml`. No database or external ML service is indicated: persistence is CSV datasets and local pickle/NPZ artifacts, while client-to-server communication is HTTP with a configurable API base URL.

Main entry points: [`PROJECT/RUN_PIPELINE_TRAINING.py`](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/RUN_PIPELINE_TRAINING.py) (Training runner), [`PROJECT/6_Model_Training_and_Export.py`](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/6_Model_Training_and_Export.py) (Model training and export), [`backend/app/main.py`](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/backend/app/main.py) (FastAPI endpoints), [`PROJECT/4_Data_Cleaning.py`](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/4_Data_Cleaning.py) (Data cleaning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training pipeline"]
  node_training_runner["Training runner<br/>pipeline entry"]
  node_source_datasets[("CSV datasets<br/>data storage")]
  node_outlier_training["Outlier training<br/>pipeline stage"]
  node_merge_data["Load and merge<br/>pipeline stage"]
  node_outlier_gate_stage["Outlier gate<br/>pipeline stage<br/>[2_Outlier_Gate.py]"]
  node_cleaning["Data cleaning<br/>pipeline stage<br/>[4_Data_Cleaning.py]"]
  node_features["TF-IDF features<br/>pipeline stage"]
  node_model_export["Model training and export<br/>pipeline stage"]
  node_pipeline_common["Pipeline conventions<br/>shared preprocessing<br/>[pipeline_common.py]"]
  node_model_artifacts[("Trained artifacts<br/>pickle artifacts<br/>[model_metadata.pkl]")]
  node_fr_nfr_model["FR/NFR classifier<br/>model artifact<br/>[model_fr_nfr.pkl]"]
  node_vectorizer["Combined vectorizer<br/>feature artifact"]
  node_outlier_model["Outlier classifier<br/>model artifact"]
end

subgraph group_serving["Inference service"]
  node_fastapi_api{{"FastAPI endpoints<br/>HTTP API<br/>[main.py]"}}
  node_api_schemas["API schemas<br/>Pydantic contracts<br/>[schemas.py]"]
  node_model_loader["Artifact loader<br/>serving component<br/>[model_loader.py]"]
  node_predictor["Prediction pipeline<br/>inference component<br/>[predictor.py]"]
  node_backend_copy["Deployment backend copy<br/>synchronization risk<br/>[main.py]"]
end

subgraph group_clients["Client applications"]
  node_streamlit_ui["Streamlit tester<br/>browser UI<br/>[streamlit_ui.py]"]
  node_flutter_app["Flutter application<br/>product client<br/>[app.dart]"]
  node_flutter_router["Flutter router<br/>client routing<br/>[router.dart]"]
  node_chat_api["Chat API client<br/>HTTP client<br/>[chat_api.dart]"]
  node_chat_repository["Chat repository<br/>client data layer"]
  node_chat_controller["Chat controller<br/>presentation controller"]
end

node_training_runner -->|"runs"| node_outlier_training
node_training_runner -->|"runs"| node_merge_data
node_training_runner -->|"runs"| node_outlier_gate_stage
node_training_runner -->|"runs"| node_cleaning
node_training_runner -->|"runs"| node_features
node_training_runner -->|"runs"| node_model_export
node_source_datasets -->|"source CSVs"| node_merge_data
node_outlier_training -->|"exports"| node_outlier_model
node_merge_data -->|"merged text"| node_outlier_gate_stage
node_outlier_gate_stage -->|"eligible items"| node_cleaning
node_cleaning -->|"normalized text"| node_features
node_features -->|"feature matrix"| node_model_export
node_pipeline_common -.->|"shared conventions"| node_cleaning
node_pipeline_common -.->|"shared conventions"| node_features
node_model_export -->|"exports"| node_fr_nfr_model
node_model_export -->|"exports"| node_vectorizer
node_fr_nfr_model -->|"stored with metadata"| node_model_artifacts
node_vectorizer -->|"stored with metadata"| node_model_artifacts
node_outlier_model -->|"stored with metadata"| node_model_artifacts
node_fastapi_api -->|"uses contracts"| node_api_schemas
node_fastapi_api -->|"serves predictions"| node_predictor
node_model_loader -->|"loads"| node_model_artifacts
node_predictor -->|"uses loaded artifacts"| node_model_loader
node_streamlit_ui -->|"exercises inference"| node_predictor
node_flutter_app -->|"routes with"| node_flutter_router
node_flutter_router -->|"opens chat"| node_chat_controller
node_chat_controller -->|"requests predictions"| node_chat_repository
node_chat_repository -->|"delegates HTTP"| node_chat_api
node_chat_api -->|"HTTP"| node_fastapi_api
node_backend_copy -.->|"must stay synchronized"| node_fastapi_api

click node_training_runner "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/RUN_PIPELINE_TRAINING.py"
click node_source_datasets "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/DATASETS/combined_stage1.csv"
click node_outlier_training "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/0_Outlier_Training.py"
click node_merge_data "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/1_Load_and_Merge.py"
click node_outlier_gate_stage "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/2_Outlier_Gate.py"
click node_cleaning "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/4_Data_Cleaning.py"
click node_features "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/5_Feature_Engineering.py"
click node_model_export "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/6_Model_Training_and_Export.py"
click node_pipeline_common "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/pipeline_common.py"
click node_model_artifacts "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/trained_models/FR_NFRTrained_models/model_metadata.pkl"
click node_fr_nfr_model "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/trained_models/FR_NFRTrained_models/model_fr_nfr.pkl"
click node_vectorizer "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/trained_models/FR_NFRTrained_models/vectorizer_combined.pkl"
click node_outlier_model "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/trained_models/outlierTrained_model/outlier_classifier.pkl"
click node_fastapi_api "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/backend/app/main.py"
click node_api_schemas "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/backend/app/schemas.py"
click node_model_loader "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/backend/app/model_loader.py"
click node_predictor "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/backend/app/predictor.py"
click node_backend_copy "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/backend/app/main.py"
click node_streamlit_ui "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/streamlit_ui.py"
click node_flutter_app "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/lib/app/app.dart"
click node_flutter_router "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/lib/app/router.dart"
click node_chat_api "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/lib/features/chat/data/chat_api.dart"
click node_chat_repository "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/lib/features/chat/data/chat_repository.dart"
click node_chat_controller "https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/lib/features/chat/presentation/controller/chat_controller.dart"

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_training_runner,node_source_datasets,node_outlier_training,node_merge_data,node_outlier_gate_stage,node_cleaning,node_features,node_model_export,node_pipeline_common,node_model_artifacts,node_fr_nfr_model,node_vectorizer,node_outlier_model toneBlue
class node_fastapi_api,node_api_schemas,node_model_loader,node_predictor,node_backend_copy toneAmber
class node_streamlit_ui,node_flutter_app,node_flutter_router,node_chat_api,node_chat_repository,node_chat_controller toneMint
```

## Components

### Training pipeline

Builds compatible local inference artifacts from CSV data.

- [Training runner](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/RUN_PIPELINE_TRAINING.py): pipeline entry · `PROJECT/RUN_PIPELINE_TRAINING.py`
- [CSV datasets](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/DATASETS/combined_stage1.csv): data storage · Input and intermediate datasets persist locally. · `DATASETS/combined_stage1.csv`
- [Outlier training](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/0_Outlier_Training.py): pipeline stage · `PROJECT/0_Outlier_Training.py`
- [Load and merge](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/1_Load_and_Merge.py): pipeline stage · `PROJECT/1_Load_and_Merge.py`
- [Outlier gate](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/2_Outlier_Gate.py): pipeline stage · Filters irrelevant requirement text. · `PROJECT/2_Outlier_Gate.py`
- [Data cleaning](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/4_Data_Cleaning.py): pipeline stage · `PROJECT/4_Data_Cleaning.py`
- [TF-IDF features](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/5_Feature_Engineering.py): pipeline stage · `PROJECT/5_Feature_Engineering.py`
- [Model training and export](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/6_Model_Training_and_Export.py): pipeline stage · `PROJECT/6_Model_Training_and_Export.py`
- [Pipeline conventions](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/pipeline_common.py): shared preprocessing · `PROJECT/pipeline_common.py`
- [Trained artifacts](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/trained_models/FR_NFRTrained_models/model_metadata.pkl): pickle artifacts · Serving requires schemas compatible with cleaning and vectorization. · `trained_models/FR_NFRTrained_models/model_metadata.pkl`
- [FR/NFR classifier](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/trained_models/FR_NFRTrained_models/model_fr_nfr.pkl): model artifact · `trained_models/FR_NFRTrained_models/model_fr_nfr.pkl`
- [Combined vectorizer](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/trained_models/FR_NFRTrained_models/vectorizer_combined.pkl): feature artifact · `trained_models/FR_NFRTrained_models/vectorizer_combined.pkl`
- [Outlier classifier](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/trained_models/outlierTrained_model/outlier_classifier.pkl): model artifact · `trained_models/outlierTrained_model/outlier_classifier.pkl`

### Inference service

FastAPI contract and item-level prediction flow.

- [FastAPI endpoints](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/backend/app/main.py): HTTP API · Provides health, prediction, and model-information endpoints. · `backend/app/main.py`
- [API schemas](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/backend/app/schemas.py): Pydantic contracts · `backend/app/schemas.py`
- [Artifact loader](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/backend/app/model_loader.py): serving component · `backend/app/model_loader.py`
- [Prediction pipeline](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/backend/app/predictor.py): inference component · Splits items, gates outliers, classifies FR/NFR and NFR categories, then groups results. · `backend/app/predictor.py`
- [Deployment backend copy](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/backend/app/main.py): synchronization risk · A separate backend copy can diverge from the primary service. · `vertex_app/backend/app/main.py`

### Client applications

Manual and product-facing inference clients.

- [Streamlit tester](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/PROJECT/streamlit_ui.py): browser UI · Direct manual interface for trained inference behavior. · `PROJECT/streamlit_ui.py`
- [Flutter application](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/lib/app/app.dart): product client · Cross-platform client with app routing and composition. · `vertex_app/lib/app/app.dart`
- [Flutter router](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/lib/app/router.dart): client routing · `vertex_app/lib/app/router.dart`
- [Chat API client](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/lib/features/chat/data/chat_api.dart): HTTP client · `vertex_app/lib/features/chat/data/chat_api.dart`
- [Chat repository](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/lib/features/chat/data/chat_repository.dart): client data layer · `vertex_app/lib/features/chat/data/chat_repository.dart`
- [Chat controller](https://github.com/hamzicodes/ids_project-srs_classification/blob/main/vertex_app/lib/features/chat/presentation/controller/chat_controller.dart): presentation controller · `vertex_app/lib/features/chat/presentation/controller/chat_controller.dart`

## Connections

- Training runner → Outlier training: runs
- Training runner → Load and merge: runs
- Training runner → Outlier gate: runs
- Training runner → Data cleaning: runs
- Training runner → TF-IDF features: runs
- Training runner → Model training and export: runs
- CSV datasets → Load and merge: source CSVs
- Outlier training → Outlier classifier: exports
- Load and merge → Outlier gate: merged text
- Outlier gate → Data cleaning: eligible items
- Data cleaning → TF-IDF features: normalized text
- TF-IDF features → Model training and export: feature matrix
- Pipeline conventions → Data cleaning: shared conventions
- Pipeline conventions → TF-IDF features: shared conventions
- Model training and export → FR/NFR classifier: exports
- Model training and export → Combined vectorizer: exports
- FR/NFR classifier → Trained artifacts: stored with metadata
- Combined vectorizer → Trained artifacts: stored with metadata
- Outlier classifier → Trained artifacts: stored with metadata
- FastAPI endpoints → API schemas: uses contracts
- FastAPI endpoints → Prediction pipeline: serves predictions
- Artifact loader → Trained artifacts: loads
- Prediction pipeline → Artifact loader: uses loaded artifacts
- Streamlit tester → Prediction pipeline: exercises inference
- Flutter application → Flutter router: routes with
- Flutter router → Chat controller: opens chat
- Chat controller → Chat repository: requests predictions
- Chat repository → Chat API client: delegates HTTP
- Chat API client → FastAPI endpoints: HTTP
- Deployment backend copy → FastAPI endpoints: must stay synchronized
