# lambda-i/aide architecture

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

- Interactive diagram: https://gitdiagram.com/lambda-i/aide
- Repository: https://github.com/lambda-i/aide

## Overview

##### Project Type and Purpose
- The project is a full-stack conversational AI system (named “AIDE”) intended for Hawaii’s Emergency Care System. Its core purpose is to act as an “AI Doctor,” simulating medical advice to help alleviate pressure on healthcare services.
- Key features include conversational capabilities, integration with external communication channels (via Twilio), and a knowledge base built from various PDF documents to support guided advice.

##### File Structure to Identify Main Components
- Root-level Files and Directories:
- Files like main.py, requirements.txt, and setup.py indicate that the project is built in Python with standard packaging.
- The .env.example and logging files indicate environment configuration and runtime logging.
- The "src" Directory:
- App.py – likely the main application driver which orchestrates the conversation flow.
- "pages" subfolder – contains modules like Assessment.py and PDFViewer.py suggesting different conversational or interface pages, which handle separate use cases (e.g., assessing symptoms, viewing PDF information).
- "assets" subfolder – includes prompt definitions that probably guide the AI responses.
- "utils" subfolder – contains modules such as pdf_generate.py and vector_rag.py, as well as a Jupyter Notebook (create_vectordb.ipynb) and a "knowledge_base" with multiple PDF files. This implies a well-defined process for ingesting, processing, and querying a knowledge base via vectorized representations.
- The "static" Directory:
- Contains static assets like the typing.wav file, which likely enhance the user interface or audio feedback elements.

##### Main Architectural Components and their Interactions
- External Interfaces:
- Frontend/UI / Communication Layer:
- Channels include possibly a web interface (through the ‘pages’ components) and a messaging/voice interface via Twilio. The “PDFViewer” might serve doctors or administrators as well as users needing detailed view of healthcare guidelines or supplemental information.
- Backend Application Layer:
- Core Application Logic (src/App.py) orchestrates user interactions.
- “pages” modules handle distinct user flows such as assessments or viewing documents.
- “assets” provide the prompt and conversation flows.
- Knowledge Base and AI Support:
- The “utils” component, including vector_rag.py and the Jupyter Notebook for creating a vector database, shows that the system uses a vectorized knowledge base extracted from a collection of PDFs. This module is crucial for retrieving context-relevant information during conversations.
- Logging and Documentation:
- Logs are maintained (in the logs folder) for monitoring system activities and debugging.
- External Dependencies and Configuration:
- .env.example and setup scripts indicate that the application depends on environment configurations and external Python packages as defined in requirements.txt.

##### Specific Elements
- Clear Labels: Ensure each module/component is clearly named (e.g., “Main Application – App.py”, “Assessment Page”, “PDF Viewer”, “Vector-based Knowledge Retrieval”).
- Visual Differentiators:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Services
    subgraph "External Services"
        A["Twilio Integration"]:::external
    end

    %% User Interface / Communication
    subgraph "User Interface / Communication"
        B["User Input (Call/Text/Web)"]:::ui
    end

    %% Core Application Logic
    subgraph "Core Application Logic"
        E["Main Application (App.py)"]:::backend
        K["AI Prompt Definitions (prompts.py)"]:::util
        L["Environment Configuration (.env.example)"]:::util
        D["Assessment Page"]:::page
        C["PDF Viewer Page"]:::page
    end

    %% Utility & Knowledge Base
    subgraph "Utility & Knowledge Base"
        F["Vector Retrieval Module"]:::util
        H["Knowledge Base (PDFs & Ingestion)"]:::kb
        I["PDF Generation Utility"]:::util
        J["Vector Database Creation Notebook"]:::util
        G["Logging & Monitoring"]:::log
    end

    %% Connections
    B -->|"initiates"| E
    A -->|"triggers"| E
    E -->|"renders"| D
    E -->|"renders"| C
    E -->|"loads"| K
    E -->|"loads"| L
    E -->|"invokes"| F
    F -->|"queries"| H
    E -->|"generates"| I
    E -->|"updates"| J
    E -->|"logs"| G

    %% Click Events
    click E "https://github.com/lambda-i/aide/blob/vector-voicerag/src/App.py"
    click D "https://github.com/lambda-i/aide/blob/vector-voicerag/src/pages/Assessment.py"
    click C "https://github.com/lambda-i/aide/blob/vector-voicerag/src/pages/PDFViewer.py"
    click K "https://github.com/lambda-i/aide/blob/vector-voicerag/src/assets/prompts.py"
    click H "https://github.com/lambda-i/aide/tree/vector-voicerag/src/utils/knowledge_base"
    click F "https://github.com/lambda-i/aide/blob/vector-voicerag/src/utils/vector_rag.py"
    click I "https://github.com/lambda-i/aide/blob/vector-voicerag/src/utils/pdf_generate.py"
    click J "https://github.com/lambda-i/aide/blob/vector-voicerag/src/utils/create_vectordb.ipynb"
    click G "https://github.com/lambda-i/aide/tree/vector-voicerag/logs"
    click L "https://github.com/lambda-i/aide/blob/vector-voicerag/.env.example"

    %% Styles
    classDef external fill:#f9c,stroke:#333,stroke-width:2px;
    classDef ui fill:#ccf,stroke:#333,stroke-width:2px;
    classDef backend fill:#9f9,stroke:#333,stroke-width:2px;
    classDef page fill:#ff9,stroke:#333,stroke-width:2px;
    classDef util fill:#cff,stroke:#333,stroke-width:2px;
    classDef kb fill:#fc9,stroke:#333,stroke-width:2px;
    classDef log fill:#cfc,stroke:#333,stroke-width:2px;
```
