# sri250691/housing-benefits-mas architecture

> Architecture diagram of the GitHub repository sri250691/housing-benefits-mas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sri250691/housing-benefits-mas
- Repository: https://github.com/sri250691/housing-benefits-mas

## Overview

##### Main Components Identification
- Frontend: This is built with React, Chakra UI, and utilizes libraries like react-force-graph to render interactive network visualizations. It resides under the src/frontend directory.
- Backend: Located under src/backend, this component is implemented using FastAPI. It handles REST and WebSocket communications, oversees the multi-agent orchestration, and serves as the central hub for processing housing and benefits application flows.
- Autonomous Agent System: Within the backend, the agents are modular and independent, with agents such as the Orchestration Agent, Housing Application Processing Agent, Fraud Detection Agent, and several others. These agents interact dynamically using custom logic and adaptive routing without hardcoded paths.
- LLM Integration: The project integrates with Ollama (utilizing the LLaMA 3.2 model) to enable enhanced decision-making for agents. This should be clearly represented as an external dependency and service target within the backend’s logic.
- Containerization & Deployment: Docker and docker-compose are used to containerize the system for easy deployment. The Docker configuration, including the Dockerfile and docker-compose.yml, should be represented as infrastructural support for how the entire system is deployed and scaled.

##### Relationships and Interactions
- Optionally, show how Docker encapsulates both the frontend and backend environments, providing a layer for container orchestration and deployment.

##### Architectural Patterns and Design Principles
- Multi-agent system pattern where agents have independent reasoning capabilities and adaptive routing. This should be highlighted by drawing each agent with a distinct identity.
- That the system uses a fallback mechanism for LLM calls. This redundancy and resiliency can be indicated in a note or a separate block describing the layered approach to LLM integration.

##### Technologies and Frameworks to Highlight
- Frontend: React, Chakra UI, react-force-graph, Vite (from vite.config.js).
- Backend: FastAPI, WebSockets.
- Agent System: Custom autonomous agents built atop LangChain patterns.
- LLM Integration: Ollama integration with LLaMA 3.2 model.
- Containerization: Docker and docker-compose.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FE["React/Chakra UI Frontend"]:::frontend
        FEComp["Visualization Components (Dashboard,AgentGraph,Forms)"]:::frontend
        FE --> FEComp
    end

    subgraph "Backend Layer"
        BE["FastAPI Server (REST&WebSocket)"]:::backend
        subgraph "Multi-Agent System"
            AgentModule["General Agents Module"]:::agents
            Orch["Orchestration Agent"]:::agents
            Housing["Housing Application Processing Agent"]:::agents
            Fraud["Fraud Detection Agent"]:::agents
            AgentModule --> Orch
            AgentModule --> Housing
            AgentModule --> Fraud
        end
        BE -->|"managesAgents"| AgentModule
    end

    subgraph "External Services"
        LLM["LLM Integration (Ollama,LLaMA3.2)"]:::external
    end

    FE -->|"API/WebSocket"| BE
    BE -->|"RealTimeUpdates"| FE
    AgentModule -->|"LLMQueries"| LLM

    subgraph "Containerization & Deployment"
        dockerCompose["docker-compose.yml"]:::infra
        dockerFile["docker/Dockerfile"]:::infra
    end

    dockerCompose --> FE
    dockerCompose --> BE
    dockerFile --> FE
    dockerFile --> BE

    click FE "https://github.com/sri250691/housing-benefits-mas/tree/main/src/frontend"
    click BE "https://github.com/sri250691/housing-benefits-mas/tree/main/src/backend"
    click AgentModule "https://github.com/sri250691/housing-benefits-mas/tree/main/src/backend/agents"
    click Orch "https://github.com/sri250691/housing-benefits-mas/blob/main/src/backend/agents/orchestrator.py"
    click Housing "https://github.com/sri250691/housing-benefits-mas/blob/main/src/backend/agents/housing_application.py"
    click Fraud "https://github.com/sri250691/housing-benefits-mas/blob/main/src/backend/agents/fraud_detection.py"
    click LLM "https://github.com/sri250691/housing-benefits-mas/blob/main/src/backend/agents/direct_ollama.py"
    click dockerCompose "https://github.com/sri250691/housing-benefits-mas/blob/main/docker-compose.yml"
    click dockerFile "https://github.com/sri250691/housing-benefits-mas/tree/main/docker/Dockerfile"
    click FEComp "https://github.com/sri250691/housing-benefits-mas/tree/main/src/frontend/src/components"

    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef agents fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef infra fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
