# don2604/accenture_hack architecture

> Architecture diagram of the GitHub repository don2604/accenture_hack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/don2604/accenture_hack
- Repository: https://github.com/don2604/accenture_hack

## Overview

##### Main components
- Backend API Server: Centered around the “backend/main.py” file; it defines the REST API endpoints (e.g., /weather, /sustainability, /market_trends, /carbon_footprint, /water_usage).
- AI Agent Layer: Under the “backend/agents” directory, include distinct agents for weather, sustainability, water usage, carbon footprint, and market trends. Also include the DecisionAgent that formats insights.
- Utility Modules: Under “backend/modules”, key subcomponents such as auth_handler, memory_handler, query_extract_run, response_handler, ticket_handler, and weather_fetcher should be depicted as supporting tools used by the primary agents.
- Database/Persistent Memory: Represent the “backend/db” directory containing SQLite databases and initialization scripts. This component supports persistent memory and previous insights.
- Data Sources: Include the “backend/data” directory (CSV datasets) as external input for initial advisory data.
- CI/CD: Optionally add the GitHub Actions workflows from the “.github/workflows” directory to note the automated build/deployment process.
- External Services: Represent external integrations like DuckDuckGo web search (as mentioned in the README) and LangChain/LLMs (e.g., LLaMA3-70B, Qwen 2.5 via Groq API).

##### Relationships and data flow
- Within the Backend, show request routing from main.py into specific AI agents. Then illustrate how these agents may call utility modules (for memory handling, query extraction, etc.) as well as interact with the SQLite databases.

##### Architectural patterns and principles
- Modular design: The separation of domain-specific agents (each handling a distinct agricultural advisory domain) emphasizes a plug-and-play, scalable architecture.
- RESTful API: The backend exposes clearly defined endpoints.
- Data persistence & memory: The integration of SQLite databases shows state persistence for smarter future responses.
- Integration of AI: The sophisticated usage of LangChain for handling language models and AI agent-driven decision making.

##### Relevant technologies
- Backend: Python, Flask, SQLite, LangChain, and custom module logic.
- Frontend: Flutter (with sub-folders for Android, iOS, web, Linux, macOS, Windows).
- Others: GitHub Actions for continuous integration, external web scraping (DuckDuckGo).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend – Flutter UI"]:::frontend
        FE_A["Android"]:::frontend
        FE_I["iOS"]:::frontend
        FE_W["Web"]:::frontend
        FE_Win["Windows"]:::frontend
        FE_Mac["macOS"]:::frontend
        FE_Lin["Linux"]:::frontend
        FE --> FE_A
        FE --> FE_I
        FE --> FE_W
        FE --> FE_Win
        FE --> FE_Mac
        FE --> FE_Lin
    end

    %% Backend API Server
    BE["Backend API Server – Flask"]:::backend

    %% CI/CD Workflows
    CICD["CI/CD Workflows – GitHub Actions"]:::cicd

    %% Connections from CI/CD
    CICD --- FE
    CICD --- BE

    %% Data flow from Frontend to Backend
    FE -->|"RESTRequest"| BE

    %% AI Agent Layer Subgraph
    subgraph "AI Agent Layer"
        A1["Weather Agent"]:::agent
        A2["Sustainability Agent"]:::agent
        A3["Water Usage Agent"]:::agent
        A4["Carbon Footprint Agent"]:::agent
        A5["Market Trends Agent"]:::agent
        A6["Decision Agent"]:::agent
    end

    %% Backend routes request to each AI Agent
    BE ---|"RoutesRequest"| A1
    BE ---|"RoutesRequest"| A2
    BE ---|"RoutesRequest"| A3
    BE ---|"RoutesRequest"| A4
    BE ---|"RoutesRequest"| A5
    BE ---|"RoutesRequest"| A6

    %% Aggregate node for AI Agents operations
    AO["Agent Operations"]:::agent

    %% Each AI Agent calls operations
    A1 --> AO
    A2 --> AO
    A3 --> AO
    A4 --> AO
    A5 --> AO
    A6 --> AO

    %% Supporting Components
    UM["Utility Modules"]:::module
    DB["Database/Persistent Memory"]:::db
    DS["Data Sources (CSV)"]:::external

    %% External Services Subgraph
    subgraph "External Services"
        EX1["DuckDuckGo Web Search"]:::external
        EX2["LangChain/LLMs (LLaMA3-70B, Qwen 2.5)"]:::external
    end

    %% Agent Operations interacting with supporting components
    AO -->|"utilCalls"| UM
    AO -->|"dbOps"| DB
    AO -->|"dataFetch"| DS
    AO -->|"externalCalls"| EX1
    AO -->|"externalCalls"| EX2

    %% Response back to Frontend
    BE -->|"JSONResponse"| FE

    %% Click Events
    click FE "https://github.com/don2604/accenture_hack/tree/main/frontend"
    click BE "https://github.com/don2604/accenture_hack/blob/main/backend/main.py"
    click A1 "https://github.com/don2604/accenture_hack/tree/main/backend/agents"
    click A2 "https://github.com/don2604/accenture_hack/tree/main/backend/agents"
    click A3 "https://github.com/don2604/accenture_hack/tree/main/backend/agents"
    click A4 "https://github.com/don2604/accenture_hack/tree/main/backend/agents"
    click A5 "https://github.com/don2604/accenture_hack/tree/main/backend/agents"
    click A6 "https://github.com/don2604/accenture_hack/tree/main/backend/agents"
    click UM "https://github.com/don2604/accenture_hack/tree/main/backend/modules"
    click DB "https://github.com/don2604/accenture_hack/tree/main/backend/db"
    click DS "https://github.com/don2604/accenture_hack/tree/main/backend/data"
    click CICD "https://github.com/don2604/accenture_hack/tree/main/.github/workflows"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef agent fill:#D5F5E3,stroke:#196F3D,stroke-width:2px;
    classDef module fill:#FADBD8,stroke:#922B21,stroke-width:2px;
    classDef db fill:#D6EAF8,stroke:#1B4F72,stroke-width:2px;
    classDef external fill:#F5EEF8,stroke:#6C3483,stroke-width:2px;
    classDef cicd fill:#FCF3CF,stroke:#B9770E,stroke-width:2px;
```
