# tomngo03/group_study architecture

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

- Interactive diagram: https://gitdiagram.com/tomngo03/group_study
- Repository: https://github.com/tomngo03/group_study

## Overview

##### Project type and purpose
- This is a full-stack Django web application (“StudyHub”/“Study Group Assistant”) that provides an interactive study companion.
- It hosts both HTML + JS front-end components (Django templates + static assets) and a back-end API layer (Django views + DRF serializers) and integrates with an external OpenAI conversational API.

##### File structure
- Top-level “study_group” directory: Django project configuration (settings.py, urls.py, ASGI/WSGI entrypoints).
- “study_project” directory: the core Django app containing:
- models.py, migrations/ → ORM data models (User, Task, Room, etc.)
- views.py, forms.py, templates/study_project/ → view logic + HTML templates
- api/serializers.py, api/views.py, api/urls.py → REST API endpoints
- utils.py & load_test.py → helper functions (e.g. OpenAI API wrapper)
- static/ & templates/ & theme/: shared frontend assets (CSS, JS, images) and base HTML.
- db.sqlite3: development database
- private.key: (probably for secure tokens, OAuth credentials)
- manage.py: Django CLI entrypoint

##### README for additional insights
- Confirms Django framework + OpenAI API integration for chatbot features
- Highlights key features: user registration & login, multiple study topics, chat interface, back-end migrations, and settings for OPENAI_API_KEY

##### Elements
- Labels for each component (Browser, Django Router, Template View, API View, ORM, Database, OpenAI API)
- HTTP requests/responses
- DB reads/writes
- External API calls
- Blue for user-facing components (templates, static)
- Green for back-end modules (views, models, utils)
- Orange for external systems (OpenAI API, OAuth)

##### Detailed separation of components
- “study_group” project container: settings, URL router, ASGI/WSGI
- “study_project” app container:
- models.py + migrations
- forms.py + views.py (HTML)
- api/serializers.py + api/views.py (REST)
- utils.py (OpenAI wrapper)
- Static & Template directories: CSS, JS, images, common layouts
- Database server
- External OpenAI service

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Browser" 
        direction TB
        Browser["User Browser"]:::frontend
    end

    %% Web Server Layer
    subgraph "Web Server (Django)"
        direction TB

        subgraph "Project Configuration"
            direction TB
            ASGI["asgi.py"]:::backend
            WSGI["wsgi.py"]:::backend
            Settings["settings.py"]:::backend
            ProjectURLs["urls.py"]:::backend
        end

        Manage["manage.py"]:::backend

        Router["Django Router"]:::backend

        subgraph "study_project App"
            direction TB
            Apps["apps.py"]:::backend
            Admin["admin.py"]:::backend
            subgraph "Models & ORM"
                direction TB
                Models["models.py"]:::backend
                Migrations["migrations/"]:::backend
            end
            subgraph "Template Views & Forms"
                direction TB
                Views["views.py"]:::backend
                Forms["forms.py"]:::backend
            end
            subgraph "REST API Layer"
                direction TB
                Serializers["serializers.py"]:::backend
                APIViews["views.py"]:::backend
                APIURLs["urls.py"]:::backend
            end
            subgraph "Utility Layer"
                direction TB
                Utils["utils.py"]:::backend
                LoadTest["load_test.py"]:::backend
            end
            Tests["tests.py"]:::backend
        end

        subgraph "Templates"
            direction TB
            ProjectTemplates["templates/study_project/"]:::frontend
            BaseTemplates["templates/main.html\nnavbar.html"]:::frontend
            ThemeTemplates["theme/*.html"]:::frontend
        end

        subgraph "Static Assets"
            direction TB
            JS["static/js/"]:::frontend
            Styles["static/styles/"]:::frontend
            Images["static/images/"]:::frontend
            ThemeAssets["theme/assets/icons"]:::frontend
        end

    end

    %% Database Layer
    Database["SQLite (db.sqlite3)"]:::data

    %% External Services
    subgraph "External Services"
        direction TB
        OpenAI["OpenAI API"]:::external
        OAuth["Google OAuth"]:::external
    end

    %% Connections
    Browser -->|HTTP Requests| Router
    Router -->|routes to| Views
    Router -->|routes to| APIViews
    Views -->|renders| ProjectTemplates
    Views -->|renders| BaseTemplates
    Views -->|renders| ThemeTemplates
    APIViews -->|serializes| Serializers
    Views -->|uses forms| Forms
    Forms -->|provides data| Views
    Views -->|queries| Models
    APIViews -->|queries| Models
    Models -->|stores/retrieves| Database
    Router -->|serves| JS
    Router -->|serves| Styles
    Router -->|serves| Images
    Router -->|serves| ThemeAssets
    APIViews -->|calls| Utils
    Utils -->|calls| OpenAI
    LoadTest -->|calls| OpenAI
    Views -->|optional OAuth| OAuth
    Browser -->|loads assets| JS
    Browser -->|loads assets| Styles
    Browser -->|loads assets| Images

    %% Click Events
    click ASGI "https://github.com/tomngo03/group_study/blob/main/study_group/asgi.py"
    click WSGI "https://github.com/tomngo03/group_study/blob/main/study_group/wsgi.py"
    click Settings "https://github.com/tomngo03/group_study/blob/main/study_group/settings.py"
    click ProjectURLs "https://github.com/tomngo03/group_study/blob/main/study_group/urls.py"
    click Manage "https://github.com/tomngo03/group_study/blob/main/manage.py"
    click Apps "https://github.com/tomngo03/group_study/blob/main/study_project/apps.py"
    click Admin "https://github.com/tomngo03/group_study/blob/main/study_project/admin.py"
    click Models "https://github.com/tomngo03/group_study/blob/main/study_project/models.py"
    click Migrations "https://github.com/tomngo03/group_study/tree/main/study_project/migrations/"
    click Views "https://github.com/tomngo03/group_study/blob/main/study_project/views.py"
    click Forms "https://github.com/tomngo03/group_study/blob/main/study_project/forms.py"
    click Serializers "https://github.com/tomngo03/group_study/blob/main/study_project/api/serializers.py"
    click APIViews "https://github.com/tomngo03/group_study/blob/main/study_project/api/views.py"
    click APIURLs "https://github.com/tomngo03/group_study/blob/main/study_project/api/urls.py"
    click Utils "https://github.com/tomngo03/group_study/blob/main/study_project/utils.py"
    click LoadTest "https://github.com/tomngo03/group_study/blob/main/study_project/load_test.py"
    click Tests "https://github.com/tomngo03/group_study/blob/main/study_project/tests.py"
    click ProjectTemplates "https://github.com/tomngo03/group_study/tree/main/study_project/templates/study_project/"
    click BaseTemplates "https://github.com/tomngo03/group_study/blob/main/templates/main.html"
    click ThemeTemplates "https://github.com/tomngo03/group_study/tree/main/theme/"
    click JS "https://github.com/tomngo03/group_study/tree/main/static/js/"
    click Styles "https://github.com/tomngo03/group_study/tree/main/static/styles/"
    click Images "https://github.com/tomngo03/group_study/tree/main/static/images/icons"
    click ThemeAssets "https://github.com/tomngo03/group_study/tree/main/theme/assets/icons"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#1E90FF,color:#1E40AF
    classDef backend fill:#DFFFE0,stroke:#3CB371,color:#2E8B57
    classDef data fill:#FFF4E5,stroke:#FFA500,color:#CC8400
    classDef external fill:#FFE6E6,stroke:#FF6347,color:#B22222
```
