# webby813/mbti_bot architecture

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

- Interactive diagram: https://gitdiagram.com/webby813/mbti_bot
- Repository: https://github.com/webby813/mbti_bot

## Overview

##### Project type and purpose
- This is a single-page, Streamlit-based, AI-powered academic advisory web application.
- Purpose:
- Let students take an MBTI style quiz
- Generate personalized course recommendations using Google Generative AI

##### File structure
- Top-level files:
- academyAI.py (core Streamlit app and orchestration logic)
- json_loader.py (loads and parses courses_info.json)
- courses_info.json (static course data)
- assets/ (images and UI assets)
- requirements.txt (.env configuration)
- No separate “frontend” or “backend” directories—this is a monolith using Streamlit for both UI and server logic.

##### README for additional insights
- Streamlit drives the UI pages: Home, Personality Assessment, Course Recommendations.
- Key modules:
- load_lottie_url → Lottie animations for UX
- create_radar_chart → Plotly radar chart generator
- create_progress_animation → Progress bars during API calls
- generate_recommendations → Calls Google Generative AI API

##### Main components and their interactions
a. Components
1. End-User (Web Browser)
2. Streamlit Server (academyAI.py)
- UI Layer: renders pages, forms, buttons
- Controller Logic: routes user actions to functions
3. Personality Quiz Module (built‐in forms in Streamlit)
4. Data Loader (json_loader.py + courses_info.json)
5. Visualization Module (Plotly Radar Chart + Lottie animations)
6. Progress Animation Module
7. AI Integration Layer (generate_recommendations → Google Generative AI API)
8. Static Assets Server (images under assets/)
9. Environment Config (.env → GEMINI_API_KEY)

b. Relationships & Data Flow
- User sends requests (clicks “Start Quiz”, “Get Recommendations”)
→ Streamlit Server
→ Quiz Module reads/writes user inputs
→ Controller invokes Data Loader to fetch course metadata
→ Controller invokes Visualization Module to display radar chart
→ Controller invokes Progress Animation while calling AI Integration
→ AI Integration calls Google API over HTTPS
→ API returns suggestions → Controller formats results
→ Streamlit Server returns UI updates and downloadable .txt file

c. Architectural patterns / principles
- Monolithic, event‐driven server (Streamlit handles both UI & backend logic)
- Modular function decomposition (each feature in its own function)
- Single responsibility for each module: loading data, visualizing, API calls

d. Key technologies & libraries
- Streamlit (web UI & server framework)
- Plotly (data visualization)
- Lottie (animations)
- Python standard libs + json_loader
- Google Generative AI API
- Static JSON for course catalog

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["End-User\n(Web Browser)"]:::external

    subgraph "Streamlit Server\n(academyAI.py)"
        UI["UI Layer\n(pages/forms/buttons)"]:::ui
        Quiz["Personality Quiz Module\n(Streamlit forms)"]:::internal
        Biz["Controller Logic"]:::internal
        DataLoader["Data Loader Module\n(json_loader.py)"]:::internal
        Viz["Visualization Module\n(Plotly & Lottie)"]:::internal
        Prog["Progress Animation Module"]:::internal
        AIInt["AI Integration Layer\n(generate_recommendations)"]:::internal
    end

    Database["Course Data Store\n(courses_info.json)"]:::external
    StaticAssets["Static Assets\n(assets/)"]:::external
    Env["Env Config\n(requirements.txt/.env)"]:::external
    GoogleAPI["Google Generative AI API"]:::externalService

    User -->|"clicks"| UI
    UI -->|"MBTI answers"| Quiz
    Quiz -->|"submits answers"| Biz
    Biz -->|"load courses"| DataLoader
    DataLoader -->|"reads JSON"| Database
    Biz -->|"generate chart data"| Viz
    Viz -->|"renders radar & animations"| UI
    Biz -->|"show progress"| Prog
    Prog -->|"animation frames"| UI
    Biz -->|"calls API"| AIInt
    AIInt -->|"API request/response"| GoogleAPI
    AIInt -->|"recommendations"| Biz
    UI -->|"loads images"| StaticAssets
    Env -->|"GEMINI_API_KEY"| AIInt

    click UI "https://github.com/webby813/mbti_bot/blob/main/academyAI.py"
    click Quiz "https://github.com/webby813/mbti_bot/blob/main/academyAI.py"
    click Biz "https://github.com/webby813/mbti_bot/blob/main/academyAI.py"
    click Viz "https://github.com/webby813/mbti_bot/blob/main/academyAI.py"
    click Prog "https://github.com/webby813/mbti_bot/blob/main/academyAI.py"
    click AIInt "https://github.com/webby813/mbti_bot/blob/main/academyAI.py"
    click DataLoader "https://github.com/webby813/mbti_bot/blob/main/json_loader.py"
    click Database "https://github.com/webby813/mbti_bot/blob/main/courses_info.json"
    click StaticAssets "https://github.com/webby813/mbti_bot/tree/main/assets/"
    click Env "https://github.com/webby813/mbti_bot/blob/main/requirements.txt"

    classDef ui fill:#ADD8E6,stroke:#000
    classDef internal fill:#90EE90,stroke:#000
    classDef external fill:#FFFFE0,stroke:#000
    classDef externalService fill:#FFFACD,stroke:#000
```
