# p-kundan/ai-requirements-assistant architecture

> Architecture diagram of the GitHub repository p-kundan/ai-requirements-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/p-kundan/ai-requirements-assistant
- Repository: https://github.com/p-kundan/ai-requirements-assistant

## Overview

##### Project type and purpose
- This is a local-first, Python-based requirements engineering assistant with a Streamlit GUI (“app.py”) on top of a collection of processing modules in `src/`.
- It ingests requirement documents (`.docx`, `.pdf`, `.xlsx`, etc.), uses a local LLM (`models/mistral-7b…gguf` via `llama-cpp-python`) to classify & score requirements, builds a traceability matrix, and renders interactive graphs & exports.

##### File structure
- Top-level:
- `app.py` – Streamlit entrypoint (frontend)
- `models/` – Local LLM model files
- `src/` – Core processing modules
- `data/` – Sample documents & test data
- `tests/` – Unit tests for modules (e.g., `test_extractor.py`)
- Key modules in `src/`:
- `file_loader.py` – Handles uploads, format detection, parsing
- `extractor.py` – Extracts raw text from parsed docs
- `nlp.py` – Classification, ambiguity scoring logic (calls LLM)
- `validator.py` – Validates requirement formats & rules
- `traceability.py` – Builds Stakeholder→System→Test Case links, network graph
- Config & dependencies: `requirements.txt`, uses `streamlit`, `llama-cpp-python`, common Python libs.

##### README for additional insights
- Confirms offline, privacy-first design; explains features: upload, classify, explain, score, trace, export.
- Mentions roadmap (future PDF reports, MBSE integration) but no external services currently.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        GUI["Streamlit GUI"]:::frontend
    end

    %% Processing Layer
    subgraph "Processing Modules"
        FL["File Loader"]:::processing
        EX["Text Extractor"]:::processing
        NLP["NLP Engine"]:::processing
        VAL["Validator"]:::processing
        TR["Traceability Engine & Graph Generator"]:::processing
    end

    %% Model Layer
    subgraph "Local Model Repository"
        M["Local LLM Model"]:::llm
    end

    %% Data & Tests
    subgraph "Data Inputs & Outputs"
        DI["Data Inputs (docs)"]:::storage
        EO["Exports (CSV/Excel/Graphs)"]:::storage
    end
    subgraph "Testing"
        UT["Unit Tests Suite"]:::storage
    end

    %% Data Flow
    GUI -->|"upload triggers"| FL
    FL -->|"parse docs"| EX
    EX -->|"raw text"| NLP
    NLP -->|"calls inference"| M
    NLP -->|"labels & scores"| VAL
    VAL -->|"validated requirements"| TR
    TR -->|"generate graph"| EO
    TR -->|"results for display"| GUI

    DI --> FL
    GUI -->|"export command"| EO

    UT -.-> FL
    UT -.-> EX
    UT -.-> NLP
    UT -.-> VAL
    UT -.-> TR

    %% Click Events
    click GUI "https://github.com/p-kundan/ai-requirements-assistant/blob/main/app.py"
    click FL "https://github.com/p-kundan/ai-requirements-assistant/blob/main/src/file_loader.py"
    click EX "https://github.com/p-kundan/ai-requirements-assistant/blob/main/src/extractor.py"
    click NLP "https://github.com/p-kundan/ai-requirements-assistant/blob/main/src/nlp.py"
    click VAL "https://github.com/p-kundan/ai-requirements-assistant/blob/main/src/validator.py"
    click TR "https://github.com/p-kundan/ai-requirements-assistant/blob/main/src/traceability.py"
    click M "https://github.com/p-kundan/ai-requirements-assistant/blob/main/models/mistral-7b-instruct-v0.1.Q4_K_M.gguf"
    click DI "https://github.com/p-kundan/ai-requirements-assistant/tree/main/data/"
    click UT "https://github.com/p-kundan/ai-requirements-assistant/tree/main/tests/"

    %% Styling
    classDef frontend fill:#D6EAF8,stroke:#2E86C1,color:#1B4F72
    classDef processing fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef llm fill:#FCF3CF,stroke:#D68910,color:#7D6608
    classDef storage fill:#DCDBDB,stroke:#7F8C8D,color:#1C2833
```
