# lanthoiba2022/academicomeback architecture

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

- Interactive diagram: https://gitdiagram.com/lanthoiba2022/academicomeback
- Repository: https://github.com/lanthoiba2022/academicomeback

## Overview

##### Project type and purpose
- This is a full-stack, single-page web application (“AcademiComeback”) built with React/TypeScript (Vite) on the frontend and Supabase as its backend (Auth, Database, Realtime, Storage).
- Key features suggested by the file tree: authenticated study rooms with chat, calendars, quizzes, analytics dashboards, gamification, file storage, and a premium subscription system.

##### File structure
- Top-level files & dirs:
- index.html, main.tsx, App.tsx → entry point for the React SPA
- src/components, src/pages, src/contexts, src/hooks, src/lib, src/utils → modular React architecture (UI components, page views, state contexts, custom hooks, external-service wrappers, utilities)
- supabase/migrations & .bolt/supabase_discarded_migrations → database schema migrations
- setup-chat-system.js → possibly automates Supabase realtime/chat setup
- netlify.toml → deployment config on Netlify
- .env.example → environment variable template for Supabase, RevenueCat, etc.

##### README for additional insights
- The README only gives the name “AcademiComeback,” but the file structure reveals the full-stack nature, the use of Supabase, and the feature set.

##### Main components & their interactions
a. Frontend (React SPA)
- Pages: Landing, Pricing, AuthModal
- Feature modules: Dashboard, Calendar, Quiz, Study Rooms (chat + task timers), Analytics, Files, Premium
- Context providers: AuthContext, ChatContext, PremiumContext
- UI library: custom Button, Card, Modal, etc.
b. API / Backend service (Supabase)
- Auth: sign-up, sign-in, RLS policies
- Database: Postgres tables for users, rooms, chat_messages, study_sessions, quizzes, achievements
- Realtime: subscriptions for chat and room updates
- Storage: file uploads/downloads via supabase.storage
c. External services
- RevenueCat (subscription management) via src/lib/revenuecat.ts
- Possibly a WebSocket server (src/lib/websocket.ts) or used in tandem with Supabase realtime
d. Hosting / Deployment
- Netlify hosting of the static frontend
- Environment variables for API keys in Netlify config

##### Architectural patterns & design principles
- SPA with component-based UI (separation of concerns)
- Context API for global state (Auth, Chat, Premium)
- Hooks for reusable logic (useLocalStorage, useStudyStreak, useGamification)
- BaaS (Supabase) for minimal custom backend
- Migration-driven schema (supabase/migrations)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client - React SPA
    subgraph "Client - React SPA"
        direction TB
        SPA["React SPA"]:::frontend
        subgraph "Entry Point"
            direction TB
            INDEX["index.html"]:::frontend
            MAIN["src/main.tsx"]:::frontend
            APP["src/App.tsx"]:::frontend
        end
        subgraph "Pages"
            direction TB
            LANDING["Landing Page"]:::frontend
            PRICING["Pricing Page"]:::frontend
            AUTHMODAL["Auth Modal"]:::frontend
            DASHBOARD["Dashboard"]:::frontend
            CALENDAR["Calendar Page"]:::frontend
            QUIZ["Quiz Page"]:::frontend
            STUDYROOMS["Study Rooms"]:::frontend
            STUDYROOM["Individual Room"]:::frontend
            ANALYTICS["Analytics Page"]:::frontend
            FILES["Files Page"]:::frontend
            PREMIUM["Premium Pages"]:::frontend
        end
        subgraph "Contexts & Hooks"
            direction TB
            AUTHCTX["AuthContext"]:::frontend
            CHATCTX["ChatContext"]:::frontend
            PREMIUMCTX["PremiumContext"]:::frontend
            HOOKS["Custom Hooks"]:::frontend
        end
        subgraph "Lib Wrappers"
            direction TB
            SUPABASELIB["supabase.ts"]:::frontend
            WS["websocket.ts"]:::frontend
            FILESTORAGE["fileStorage.ts"]:::frontend
            REVENUECAT["revenuecat.ts"]:::external
        end
        INDEX --> MAIN --> APP --> SPA
        SPA --> LANDING
        SPA --> PRICING
        SPA --> AUTHMODAL
        SPA --> DASHBOARD
        SPA --> CALENDAR
        SPA --> QUIZ
        SPA --> STUDYROOMS
        SPA --> STUDYROOM
        SPA --> ANALYTICS
        SPA --> FILES
        SPA --> PREMIUM
        SPA --> AUTHCTX
        SPA --> CHATCTX
        SPA --> PREMIUMCTX
        SPA --> HOOKS
        SPA --> SUPABASELIB
        SPA --> WS
        SPA --> FILESTORAGE
        SPA --> REVENUECAT
    end

    %% BaaS - Supabase
    subgraph "BaaS - Supabase"
        direction TB
        AUTH["Auth Service"]:::baas
        DB[(Postgres Database)]:::baas
        REALTIME["Realtime Service"]:::baas
        STORAGE["Storage Service"]:::baas
        MIGRATIONS["Migrations"]:::baas
        DISCARDED[".bolt Discarded Migrations"]:::baas
        DEV["Developers"]:::external
        DEV --> MIGRATIONS
        DEV --> DISCARDED
    end

    %% External Services
    subgraph "External Services"
        direction TB
        REVCAT["RevenueCat API"]:::external
        WEBSOCKET["Custom WebSocket"]:::external
    end

    %% Deployment
    subgraph "Deployment"
        direction TB
        NETLIFY["Netlify Hosting"]:::hosting
        SCRIPT["setup-chat-system.js"]:::hosting
        NETLIFY --> SCRIPT
    end

    %% Data Flows
    SPA -->|"sign-in/signup"| AUTH
    SPA -->|"REST Calls"| DB
    SPA -->|subscribe| REALTIME
    SPA -->|"upload/download"| STORAGE
    SPA -->|"subscription events"| REVCAT
    SPA -->|"ws messages"| WEBSOCKET

    %% Click Events
    click INDEX "https://github.com/lanthoiba2022/academicomeback/blob/main/index.html"
    click MAIN "https://github.com/lanthoiba2022/academicomeback/blob/main/src/main.tsx"
    click APP "https://github.com/lanthoiba2022/academicomeback/blob/main/src/App.tsx"
    click LANDING "https://github.com/lanthoiba2022/academicomeback/blob/main/src/pages/Landing.tsx"
    click PRICING "https://github.com/lanthoiba2022/academicomeback/blob/main/src/pages/PricingPage.tsx"
    click AUTHMODAL "https://github.com/lanthoiba2022/academicomeback/blob/main/src/components/auth/AuthModal.tsx"
    click AUTHCTX "https://github.com/lanthoiba2022/academicomeback/blob/main/src/contexts/AuthContext.tsx"
    click DASHBOARD "https://github.com/lanthoiba2022/academicomeback/blob/main/src/pages/Dashboard.tsx"
    click CALENDAR "https://github.com/lanthoiba2022/academicomeback/blob/main/src/pages/CalendarPage.tsx"
    click QUIZ "https://github.com/lanthoiba2022/academicomeback/blob/main/src/pages/QuizPage.tsx"
    click STUDYROOMS "https://github.com/lanthoiba2022/academicomeback/blob/main/src/pages/StudyRooms.tsx"
    click STUDYROOM "https://github.com/lanthoiba2022/academicomeback/blob/main/src/pages/StudyRoom.tsx"
    click ANALYTICS "https://github.com/lanthoiba2022/academicomeback/blob/main/src/pages/AnalyticsPage.tsx"
    click FILES "https://github.com/lanthoiba2022/academicomeback/blob/main/src/pages/FilesPage.tsx"
    click PREMIUM "https://github.com/lanthoiba2022/academicomeback/blob/main/src/pages/Premium.tsx"
    click SUPABASELIB "https://github.com/lanthoiba2022/academicomeback/blob/main/src/lib/supabase.ts"
    click WS "https://github.com/lanthoiba2022/academicomeback/blob/main/src/lib/websocket.ts"
    click FILESTORAGE "https://github.com/lanthoiba2022/academicomeback/blob/main/src/lib/fileStorage.ts"
    click REVENUECAT "https://github.com/lanthoiba2022/academicomeback/blob/main/src/lib/revenuecat.ts"
    click MIGRATIONS "https://github.com/lanthoiba2022/academicomeback/tree/main/supabase/migrations"
    click DISCARDED "https://github.com/lanthoiba2022/academicomeback/tree/main/.bolt/supabase_discarded_migrations"
    click SCRIPT "https://github.com/lanthoiba2022/academicomeback/blob/main/setup-chat-system.js"
    click NETLIFY "https://github.com/lanthoiba2022/academicomeback/blob/main/netlify.toml"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:1px
    classDef baas fill:#d4edda,stroke:#155724,stroke-width:1px
    classDef external fill:#f2f2f2,stroke:#6c757d,stroke-width:1px
    classDef hosting fill:#ffe5cc,stroke:#9f6000,stroke-width:1px
```
