# debonir-projects/study-ai-automation architecture

> Architecture diagram of the GitHub repository debonir-projects/study-ai-automation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/debonir-projects/study-ai-automation
- Repository: https://github.com/debonir-projects/study-ai-automation

## Overview

Based on your file tree and README, you’re looking at a full-stack application that combines a Next.js frontend with a Python-based backend. The project not only delivers a web interface for client interaction but also features a robust API layer on the backend, along with integrations (e.g., Google services, WhatsApp, Supabase) and custom business logic for events, calendars, performance analysis, and more.

##### Main Components
- Frontend (Next.js): Located in the “src” directory, this layer is responsible for the user interface and includes various pages (e.g., authentication, dashboard, channels), API routes for third-party integrations (Google Cloud, WhatsApp, etc.), and shared components.
- Python Backend: Found in the “python_backend” directory, this component exposes REST API endpoints (e.g., under app/api/routes for “calendar”, “performance”, “reports”) and houses core business logic in both “models” and “services” folders. It likely serves as the dedicated processing engine for calendar events, notifications, performance analysis, and report generation.
- Database & Migrations (Supabase): A Supabase directory with SQL migrations indicates a managed database system (likely PostgreSQL) that underpins persistent storage for this application.
- External Service Integrations: Various libraries under “src/lib” (e.g., google-classroom.ts, google-vision.ts, whatsapp.ts, study-planner.ts) show that the frontend directly integrates with external APIs or services, while the backend also addresses integrations (e.g., notification_service, scheduler_service).

##### Out Relationships and Interactions
- Internal API Layer Separation: Inside the Python backend, distinguish the routing (exposed in “app/api/routes”) from the service logic (in “app/services”) and business models (in “app/models”). This layered approach facilitates maintainability and modular design.
- Database Access: Illustrate how both the Python backend (for persistent data operations) and possibly some parts of the frontend (via Supabase client libraries) interact with the underlying database.

##### Architectural Patterns and Design Principles
- Modular Design: Within the Python backend, note the logical grouping into API routes, models, schemas, and services. Similarly, the frontend components and API handlers in “src” are organized by functionality (auth, channels, dashboard, etc.).
- Microservices or Service-Oriented Architecture (if applicable): Even if the project runs as a monolith, the separation into distinct domains (calendar, performance, reports) should be visually segmented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend (Next.js UI)
    subgraph "Frontend (Next.js UI)"
        FE_Pages["Next.js Pages"]:::frontend
        FE_Components["Next.js Components"]:::frontend
        FE_API["API Handlers"]:::frontend
    end

    %% Backend (Python API)
    subgraph "Backend (Python API)"
        subgraph "API Routes"
            BE_Calendar["Calendar API"]:::backend
            BE_Performance["Performance API"]:::backend
            BE_Reports["Reports API"]:::backend
        end
        subgraph "Business Services"
            BE_CalendarService["Calendar Service"]:::backend
            BE_NotificationService["Notification Service"]:::backend
            BE_PerformanceAnalyzer["Performance Analyzer"]:::backend
            BE_ReportGenerator["Report Generator"]:::backend
            BE_SchedulerService["Scheduler Service"]:::backend
        end
        subgraph "Business Models"
            BE_EventsModel["Events Model"]:::backend
            BE_MarketplaceModel["Marketplace Model"]:::backend
            BE_StudentModel["Student Model"]:::backend
        end
    end

    %% Database & Migrations (Supabase)
    subgraph "Database"
        DB_Migrations["Supabase Migrations"]:::database
        DB_Schema["Supabase Schema"]:::database
    end

    %% External Service Integrations
    subgraph "External Services"
        EX_GoogleClass["Google Classroom"]:::external
        EX_GoogleVision["Google Vision"]:::external
        EX_WhatsApp["WhatsApp"]:::external
        EX_StudyPlanner["Study Planner"]:::external
    end

    %% Frontend to Backend API Routes
    FE_API -->|"calls"| BE_Calendar
    FE_API -->|"calls"| BE_Performance
    FE_API -->|"calls"| BE_Reports

    %% Backend Business Services to Database
    BE_CalendarService -->|"stores_data"| DB_Schema
    BE_NotificationService -->|"stores_data"| DB_Schema
    BE_PerformanceAnalyzer -->|"analyzes"| DB_Schema
    BE_ReportGenerator -->|"stores_results"| DB_Schema
    BE_SchedulerService -->|"schedules"| DB_Schema

    %% Define relationship between DB components
    DB_Migrations -->|"defines"| DB_Schema

    %% Backend Business Services integrating with External Services
    BE_CalendarService -->|"integrates"| EX_GoogleClass
    BE_NotificationService -->|"integrates"| EX_WhatsApp
    BE_PerformanceAnalyzer -->|"integrates"| EX_GoogleVision
    BE_ReportGenerator -->|"integrates"| EX_StudyPlanner

    %% Frontend External Integrations
    FE_API -->|"integrates"| EX_GoogleVision
    FE_API -->|"integrates"| EX_WhatsApp

    %% Click Events for Frontend
    click FE_Pages "https://github.com/debonir-projects/study-ai-automation/tree/master/src/app"
    click FE_Components "https://github.com/debonir-projects/study-ai-automation/tree/master/src/components"
    click FE_API "https://github.com/debonir-projects/study-ai-automation/tree/master/src/app/api"

    %% Click Events for Python Backend API Routes
    click BE_Calendar "https://github.com/debonir-projects/study-ai-automation/blob/master/python_backend/app/api/routes/calendar.py"
    click BE_Performance "https://github.com/debonir-projects/study-ai-automation/blob/master/python_backend/app/api/routes/performance.py"
    click BE_Reports "https://github.com/debonir-projects/study-ai-automation/blob/master/python_backend/app/api/routes/reports.py"

    %% Click Events for Python Backend Business Services
    click BE_CalendarService "https://github.com/debonir-projects/study-ai-automation/blob/master/python_backend/app/services/calendar_service.py"
    click BE_NotificationService "https://github.com/debonir-projects/study-ai-automation/blob/master/python_backend/app/services/notification_service.py"
    click BE_PerformanceAnalyzer "https://github.com/debonir-projects/study-ai-automation/blob/master/python_backend/app/services/performance_analyzer.py"
    click BE_ReportGenerator "https://github.com/debonir-projects/study-ai-automation/blob/master/python_backend/app/services/report_generator.py"
    click BE_SchedulerService "https://github.com/debonir-projects/study-ai-automation/blob/master/python_backend/app/services/scheduler_service.py"

    %% Click Events for Python Backend Business Models
    click BE_EventsModel "https://github.com/debonir-projects/study-ai-automation/blob/master/python_backend/app/models/events.py"
    click BE_MarketplaceModel "https://github.com/debonir-projects/study-ai-automation/blob/master/python_backend/app/models/marketplace.py"
    click BE_StudentModel "https://github.com/debonir-projects/study-ai-automation/blob/master/python_backend/app/models/student.py"

    %% Click Events for Database & Migrations
    click DB_Migrations "https://github.com/debonir-projects/study-ai-automation/tree/master/supabase/migrations"
    click DB_Schema "https://github.com/debonir-projects/study-ai-automation/blob/master/supabase/schema.sql"

    %% Click Events for External Service Integrations
    click EX_GoogleClass "https://github.com/debonir-projects/study-ai-automation/blob/master/src/lib/google-classroom.ts"
    click EX_GoogleVision "https://github.com/debonir-projects/study-ai-automation/blob/master/src/lib/google-vision.ts"
    click EX_WhatsApp "https://github.com/debonir-projects/study-ai-automation/blob/master/src/lib/whatsapp.ts"
    click EX_StudyPlanner "https://github.com/debonir-projects/study-ai-automation/blob/master/src/lib/study-planner.ts"

    %% Style Definitions
    classDef frontend fill:#D6EAF8,stroke:#1F618D,stroke-width:2px;
    classDef backend fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
    classDef database fill:#FAD7A0,stroke:#D68910,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
