# aditipatil38/aura architecture

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

- Interactive diagram: https://gitdiagram.com/aditipatil38/aura
- Repository: https://github.com/aditipatil38/aura

## Overview

##### Project type and purpose
- This is a full-stack conversational AI web application (“AURA – Virtual Therapy Assistant”) built with Flask.
- It exposes an HTML/JavaScript chat UI, communicates with a Python backend, leverages LangGraph + LangChain for LLM orchestration, uses a RAG pipeline (FAISS + HuggingFace embeddings over a local corpus), calls out to Groq’s LLaMA3 API, and persists chat history in Firebase.

##### File structure
- Top-level files:
- app.py – Flask application entry point, routes HTTP requests
- firebase_config.py – Firebase client setup for reading/writing chat history
- graph.py – Definition of the LangGraph workflow (turn-based LLM orchestration)
- rag.py – RAG logic (builds/queries FAISS index over data/therapy_notes.txt using HuggingFace embeddings)
- Directories:
- templates/chat.html – front-end UI served by Flask
- data/therapy_notes.txt – the corpus for retrieval augmentation
- img/ – static screenshots
- No separate “static” folder shown, but likely embedded JS/CSS in chat.html.

##### README for additional insights
- Confirms tech stack: Flask (backend), HTML+JS (frontend), LangGraph & LangChain, Groq API for LLM, FAISS + HuggingFace for RAG, Firebase Realtime DB.
- Describes features: emotional grounding, multilingual support, retrieval from therapy_notes, chat history via Firebase.

##### Components
a. Main components
- Frontend (Chat UI in browser)
- Flask Backend (app.py)
- LangGraph Workflow (graph.py)
- RAG Pipeline (rag.py + FAISS index over data/therapy_notes.txt + HuggingFace embeddings)
- LLM Service (Groq LLaMA3 API)
- Firebase Realtime Database (chat history)
b. Relationships & interactions
1. User → Browser (UI)
2. Browser ↔ Flask app (HTTP POST chat messages / GET HTML)
3. Flask app invokes LangGraph workflow → calls Groq LLM
4. RAG pipeline queries FAISS index → returns context
5. LangGraph orchestrates RAG context + prior conversation → LLM API → response
6. Flask app writes/reads last-3 messages to Firebase via firebase_config.py
7. Flask returns response JSON → Frontend displays
c. Architectural patterns & design principles
- Layered separation: Presentation (frontend), Application (Flask + Graph), Data (FAISS index, Firebase), External Service (Groq API)
- Retrieval-Augmented Generation pattern
- Checkpointing conversational state via LangGraph + Firebase
d. Relevant technologies
- Flask (web server / routing)
- LangGraph & LangChain (LLM orchestration)
- Groq’s LLaMA3 API (LLM endpoint)
- FAISS + HuggingFace embeddings (vector store)
- Firebase Realtime DB (persistent chat history)
- HTML + JavaScript (frontend chat UI)

##### Final guidance
- Be as granular as practical: separate the LangGraph orchestration from the RAG retrieval module even though they both live in the Python backend.
- Major actors: user browser, backend modules, vector store, external API, database.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        UI["Chat UI<br/>(templates/chat.html)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API["Flask API<br/>(app.py)"]:::backend
        Graph["LangGraph Workflow<br/>(graph.py)"]:::backend
        RAG["RAG Pipeline<br/>(rag.py)"]:::backend
        FBClient["Firebase Client<br/>(firebase_config.py)"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        Corpus["Therapy Notes Corpus<br/>(data/therapy_notes.txt)"]:::storage
        FAISS["FAISS Vector Store"]:::data
        DB["Firebase Realtime DB"]:::storage
    end

    %% External Services
    LLM["Groq LLaMA3 API"]:::external
    Doc["Project Documentation<br/>(README.md)"]:::externalDocs

    %% User Interaction
    User["User"]:::external
    User -->|"accesses UI"| UI
    UI -->|HTTP POST/GET| API

    %% Backend Orchestration
    API -->|calls| Graph
    Graph -->|invokes| RAG
    RAG -->|builds/queries| FAISS
    FAISS -->|returns contexts| RAG
    RAG -->|requests completion| LLM
    LLM -->|response| Graph
    Graph -->|response data| API
    API -->|returns JSON| UI

    %% Chat History Persistence
    API -->|reads/writes| FBClient
    FBClient -->|read/write| DB
    DB -->|history| FBClient

    %% Documentation Link
    API -.->|see docs| Doc

    %% Click Events
    click UI "https://github.com/aditipatil38/aura/blob/main/templates/chat.html"
    click API "https://github.com/aditipatil38/aura/blob/main/app.py"
    click Graph "https://github.com/aditipatil38/aura/blob/main/graph.py"
    click RAG "https://github.com/aditipatil38/aura/blob/main/rag.py"
    click Corpus "https://github.com/aditipatil38/aura/blob/main/data/therapy_notes.txt"
    click FBClient "https://github.com/aditipatil38/aura/blob/main/firebase_config.py"
    click Doc "https://github.com/aditipatil38/aura/blob/main/README.md"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#21618C,color:#1B4F72;
    classDef backend fill:#AED6F1,stroke:#2874A6,color:#1B2631;
    classDef data fill:#FCF3CF,stroke:#B7950B,color:#7D6608;
    classDef storage fill:#ABEBC6,stroke:#28B463,color:#145A32;
    classDef external fill:#F9E79F,stroke:#B9770E,color:#7E5109;
    classDef externalDocs fill:#D2B4DE,stroke:#7D3C98,color:#512E5F;
```
