# motsimaslam/afri-ai-tutor architecture

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

- Interactive diagram: https://gitdiagram.com/motsimaslam/afri-ai-tutor
- Repository: https://github.com/motsimaslam/afri-ai-tutor

## Overview

##### Project Components
- Main Application: The entry point is app.py, which runs the Streamlit application. This file contains the core logic to render the AI tutor interface, interactive lessons, tutoring forms, and the admin panel.
- Dependencies & Environment: The requirements.txt file lists Python packages (including Streamlit and integration libraries for OpenAI, ElevenLabs, and Stability APIs). The .devcontainer folder ensures a smooth containerized development environment.
- External Services: The application integrates with several external APIs for AI-powered functionalities:
- OpenAI for AI tutoring.
- ElevenLabs for voice integration.
- Stability for potentially generating offline or lightweight AI responses.
- User Interfaces: The README details several UI segments (multilingual chat interface, voice-enabled responses, career guidance pages, tutoring request forms, and an admin panel).

##### Architectural Relationships
- User Interface Layer: This comprises components for language selection, chat with the AI tutor, voice assistance, career guidance, and admin functionalities.
- Business Logic & API Integration Layer: This deals with processing user inputs, managing tutoring and career guidance requests, and interfacing with external APIs.
- Data Flow & External Interactions:
- Inputs come from users selecting languages, typing questions, or submitting forms.
- The application then uses direct API calls to interact with external services (OpenAI, ElevenLabs, Stability) to generate responses or content.
- The admin panel provides monitoring/management pathways for these requests.
- Development & Deployment Tools: The .devcontainer configuration indicates that development (and potentially deployment) is containerized for consistency.

##### Architectural Patterns & Technologies
- Pattern: Although built as a single application (with one main app.py), it is effectively modular, separating UI components and business logic.
- Technologies:
- Python and Streamlit for the web application.
- Containerization via the devcontainer setup.
- External APIs for AI, voice synthesis, and possibly stability models.
- Design Principle: Emphasis on a service-oriented approach where external services are decoupled from the core application and integrated via clear API boundaries.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI1["Chat Interface (Multilingual)"]:::ui
        UI2["Voice Integration Module"]:::ui
        UI3["Career Guidance & Tutoring Forms"]:::ui
        UI4["Admin Panel"]:::ui
    end

    %% Core Application Logic
    Core["Main Application (app.py)"]:::core

    %% External API Integrations
    subgraph "External API Integrations"
        API1["OpenAI Service"]:::external
        API2["ElevenLabs Service"]:::external
        API3["Stability Service"]:::external
    end

    %% Development & Environment
    subgraph "Development & Environment"
        ENV1["Dependencies (requirements.txt)"]:::env
        ENV2["Containerized Dev Environment (.devcontainer)"]:::env
    end

    %% Data Flow from UI to Core Application
    UI1 -->|"UserInput"| Core
    UI2 -->|"VoiceRequest"| Core
    UI3 -->|"FormSubmission"| Core
    UI4 -->|"AdminActions"| Core

    %% Core Application interacting with External APIs
    Core -->|"API_Call:OpenAI"| API1
    Core -->|"API_Call:ElevenLabs"| API2
    Core -->|"API_Call:Stability"| API3

    %% Environment supporting the Core Application
    ENV1 -.->|"Provides"| Core
    ENV2 -.->|"Provides"| Core

    %% Click Events
    click Core "https://github.com/motsimaslam/afri-ai-tutor/blob/main/app.py"
    click ENV1 "https://github.com/motsimaslam/afri-ai-tutor/blob/main/requirements.txt"
    click ENV2 "https://github.com/motsimaslam/afri-ai-tutor/blob/main/.devcontainer"

    %% Styles
    classDef ui fill:#ffdead,stroke:#333,stroke-width:2px;
    classDef core fill:#bbf,stroke:#333,stroke-width:2px;
    classDef external fill:#ffe4e1,stroke:#333,stroke-width:2px;
    classDef env fill:#cfc,stroke:#333,stroke-width:2px;
```
