# sanjanats7/edu_bot architecture

> Architecture diagram of the GitHub repository sanjanats7/edu_bot, 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/sanjanats7/edu_bot
- Repository: https://github.com/sanjanats7/edu_bot

## Overview

##### Main Components
- Frontend/UI: Represented by app.py – This is the Streamlit application that serves as the web interface users interact with.
- Backend/Logic: The logic within app.py likely includes request management, invoking NLP services, and interacting with the database.
- Database: Represented by database.py – This module is responsible for storing or retrieving application data.
- External Service: Ollama – An external process that hosts and serves the Llama 3.1 model. EduBot interacts with this service to get NLP responses.

##### Relationships and Data Flows
- User interactions: Users access the Streamlit UI via a web browser (e.g., http://localhost:8501).
- Streamlit (app.py) receives user input and processes it.
- The application may call functions in database.py to log or retrieve persistent data.
- For generating responses, app.py sends requests to the Ollama server, which is running in the background serving the Llama 3.1 model. The answer from Ollama is then relayed back to the user via the UI.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The code is neatly separated across different files (UI, database, and configuration/dependencies).
- Modular Architecture: The external service (Ollama for Llama 3.1) is decoupled from core application logic, promoting easier maintenance and scalability.
- External Service Integration: Clearly show the dependency injection between the app and the external NLP service.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["User's Web Browser (via Streamlit)"]:::ui

    %% Application Layer
    App["Streamlit Application (app.py)"]:::app
    Env["Python Environment (requirements.txt)"]:::env

    %% Data Layer
    DB["Local Database (database.py)"]:::db

    %% External Service Layer
    Ollama["Ollama Service (Llama 3.1)"]:::external

    %% Data Flows
    Browser -->|"sends_input"| App
    App -->|"logs/retrieves"| DB
    DB -->|"returns_data"| App
    App -->|"queries"| Ollama
    Ollama -->|"responds"| App
    App ---|"depends_on"| Env

    %% Click Events
    click App "https://github.com/sanjanats7/edu_bot/blob/main/app.py"
    click DB "https://github.com/sanjanats7/edu_bot/blob/main/database.py"
    click Env "https://github.com/sanjanats7/edu_bot/blob/main/requirements.txt"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef app fill:#85C1E9,stroke:#2E86C1,stroke-width:2px;
    classDef db fill:#FAD7A0,stroke:#F39C12,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#EC7063,stroke-width:2px;
    classDef env fill:#D5F5E3,stroke:#58D68D,stroke-width:2px;
```
