# alyrraza/srs-using-ai-agent architecture

> Architecture diagram of the GitHub repository alyrraza/srs-using-ai-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alyrraza/srs-using-ai-agent
- Repository: https://github.com/alyrraza/srs-using-ai-agent

## Overview

##### Project type and purpose
- Full-stack web application (Python + Streamlit)
- Modular pipeline pattern inspired by n8n, where each “agent” produces one section of the SRS

##### File structure
Top-level files
- main.py – Streamlit entry point and UI layer
- model_test.py – unit tests for core logic
- requirements.txt, .env, .gitignore – environment/configuration

srs_generator/ (application modules)
- __init__.py – pipeline manager (SRSAgentManager)
- rag.py – Gemini API wrapper (AI content fetcher)
- first_page.py, introduction.py, overall_description.py, system_feature.py, use_cases.py, non_functional_requirements.py – individual section agents

##### Extract architecture insights from the README
- Streamlit UI collects input (user name, project description, file name)
- SRSAgentManager orchestrates a sequential chain of agents
- Each agent calls Gemini API (via rag.py) for AI-generated content
- python-docx handles formatting and page insertion
- Output: downloadable .docx with placeholder TOC

##### Main components and their relationships
a. Frontend (Streamlit UI)
– Collects user input
– Triggers SRSAgentManager

b. Application layer (Pipeline & Agents)
– SRSAgentManager (orchestrator)
– FirstPageAgent → IntroductionAgent → OverallDescriptionAgent → … → SystemModelsAgent

c. Document Generation
– python-docx
– SRSConcrete class methods: create_first_page(), add_page()

– PlantUML JAR (external service)
– system_models_diagrams.py generates .puml files, invokes PlantUML to produce images

e. External Services
– Gemini API (AI content)
– PlantUML CLI

f. Output & Storage
– Local `.docx` file saved
– Streamlit makes it downloadable

##### Architectural patterns & design principles
- Pipeline / Chain of Responsibility (n8n‐inspired): agents execute in defined sequence
- Separation of concerns: distinct modules for UI, orchestration, AI interaction, formatting, diagramming
- Extensibility: plug-in style agents (add new content sections without touching core)
- Resiliency: retries & logging (max_retries=5 via loguru)

##### Essential elements
– Streamlit UI (main.py)
– SRSAgentManager (srs_generator/__init__.py)
– Individual Agents (each .py under srs_generator/)
– rag.py (Gemini API wrapper)
– python-docx library
– PlantUML (JAR path)
– Output .docx

- Notes on configuration (.env, retries, logging)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Layer: UI
    UI["Streamlit UI\nmain.py"]:::ui
    click UI "https://github.com/alyrraza/srs-using-ai-agent/blob/main/main.py"

    %% Pipeline Orchestrator
    Manager["SRSAgentManager\n__init__.py"]:::internal
    click Manager "https://github.com/alyrraza/srs-using-ai-agent/blob/main/srs_generator/__init__.py"

    %% Agents Pipeline
    subgraph "Agents Pipeline"
        direction TB
        A1["FirstPageAgent\nfirst_page.py"]:::internal
        click A1 "https://github.com/alyrraza/srs-using-ai-agent/blob/main/srs_generator/first_page.py"
        A2["IntroductionAgent\nintroduction.py"]:::internal
        click A2 "https://github.com/alyrraza/srs-using-ai-agent/blob/main/srs_generator/introduction.py"
        A3["OverallDescriptionAgent\noverall_description.py"]:::internal
        click A3 "https://github.com/alyrraza/srs-using-ai-agent/blob/main/srs_generator/overall_description.py"
        A4["SystemFeatureAgent\nsystem_feature.py"]:::internal
        click A4 "https://github.com/alyrraza/srs-using-ai-agent/blob/main/srs_generator/system_feature.py"
        A5["UseCasesAgent\nuse_cases.py"]:::internal
        click A5 "https://github.com/alyrraza/srs-using-ai-agent/blob/main/srs_generator/use_cases.py"
        A6["NonFunctionalRequirementsAgent\nnon_functional_requirements.py"]:::internal
        click A6 "https://github.com/alyrraza/srs-using-ai-agent/blob/main/srs_generator/non_functional_requirements.py"
        A7["SystemModelsAgent\n(system_models_diagrams.py)"]:::internal
        click A7 "https://github.com/alyrraza/srs-using-ai-agent/blob/main/srs_generator/system_models_diagrams.py"
    end

    %% Document & Diagram Generators
    DocGen["python-docx\nLibrary"]:::lib
    UMLGen["PlantUML CLI\n(JAR)"]:::external
    Example["Sample Usage & Templates\nexample.py / example.puml"]:::internal
    click Example "https://github.com/alyrraza/srs-using-ai-agent/blob/main/srs_generator/example.py"

    %% External AI Service
    AI["Gemini API"]:::external

    %% Output
    Output["Generated SRS Document\n.docx"]:::lib

    %% Connections
    UI -->|"triggers"| Manager
    Manager --> A1
    A1 --> A2
    A2 --> A3
    A3 --> A4
    A4 --> A5
    A5 --> A6
    A6 --> A7

    %% Agents call AI wrapper
    A1 -->|"calls"| RAG["AI API Wrapper\nrag.py"]:::internal
    click RAG "https://github.com/alyrraza/srs-using-ai-agent/blob/main/srs_generator/rag.py"
    A2 --> RAG
    A3 --> RAG
    A4 --> RAG
    A5 --> RAG
    A6 --> RAG

    RAG -->|"requests"| AI
    AI -->|"responses"| RAG

    %% Agents to Document Gen
    A1 --> DocGen
    A2 --> DocGen
    A3 --> DocGen
    A4 --> DocGen
    A5 --> DocGen
    A6 --> DocGen
    A7 --> DocGen

    %% Diagram Generation
    A7 -->|"generates PUML"| Example
    A7 -->|"invokes"| UMLGen
    UMLGen -->|"produces diagrams"| DocGen

    %% Final Output
    DocGen --> Output
    Output -->|"download via UI"| UI

    %% Styles
    classDef ui fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef internal fill:#d4edda,stroke:#333,stroke-width:1px;
    classDef lib fill:#ffe5b4,stroke:#333,stroke-width:1px;
    classDef external fill:#f8d7da,stroke:#333,stroke-width:1px;
```
