# m3ayush/study-zen-23 architecture

> Architecture diagram of the GitHub repository m3ayush/study-zen-23, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/m3ayush/study-zen-23
- Repository: https://github.com/m3ayush/study-zen-23

## Overview

##### Project type and purpose
- This is a full-stack (front-end + BaaS) Single-Page Application built with Vite, TypeScript, React, Tailwind CSS, and shadcn-ui.
- The “backend” is provided by Supabase (PostgreSQL, Auth, Storage) via the `src/integrations/supabase` client.

##### Main components
A. Frontend
- Browser / User Interface
- HTML/CSS/JS served by Vite (or static host after build)
- React components (pages under `src/pages`, UI under `src/components/ui`)
- Build & Deployment
- Vite build → static assets (index.html, JS bundle, CSS)
- Deployed via Lovable (static hosting + optional custom domain)
B. Backend (Supabase)
- Authentication service
- PostgreSQL database (with migrations under `supabase/migrations`)
- Storage (if used)
- Supabase REST/WebSocket APIs

##### Relationships and interactions
- The Browser loads the React SPA from the static host.
- The React SPA initializes the Supabase client (`src/integrations/supabase/client.ts`).
- User actions (login, CRUD operations) → client calls Supabase Auth & Database endpoints.
- Supabase returns data/responses → React state updates (via hooks and context).

##### Architectural patterns and design principles
- Separation of concerns: UI layer vs. data layer (BaaS).
- SPA pattern: client-side routing (`src/pages` + `ProtectedRoute`).
- Utility / integration layer: `src/lib/utils.ts`, `src/integrations/supabase`.
- UI component library: shadcn-ui under `src/components/ui`.

##### Summary
- Focus only on the two main systems: Frontend SPA vs. Supabase backend.
- Exclude deep dives into individual components like `App.tsx`.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Subgraphs
    subgraph "Frontend (React SPA)"
        direction TB
        Browser["Browser"]:::external
        ReactSPA["React SPA"]:::frontend
        StaticAssets["Static Assets\n(index.html, JS bundle, CSS)"]:::artifact
        Pages["Pages"]:::frontend
        ComponentsUI["UI Components"]:::ui
        Layouts["Layout & ProtectedRoute"]:::frontend
        SupabaseClient["Supabase Client\n(src/integrations/supabase)"]:::integration
        Utils["Utility & Hooks"]:::utility
        BuildDeploy["Build & Deployment\n(Vite, Tailwind CSS)"]:::artifact
    end

    subgraph "Backend (Supabase BaaS)"
        direction TB
        Auth["Supabase Auth"]:::service
        Database["Supabase DB"]:::db
        Migrations["DB Migrations"]:::db
        Storage["Supabase Storage"]:::service
    end

    %% Relationships
    Browser -->|"loads SPA"| StaticAssets
    StaticAssets --> ReactSPA
    ReactSPA --> Pages
    ReactSPA --> ComponentsUI
    ReactSPA --> Layouts
    ReactSPA --> SupabaseClient
    ReactSPA --> Utils
    ReactSPA --> BuildDeploy

    ReactSPA -->|"login request"| Auth
    ReactSPA -->|"query: CRUD operations"| Database
    ReactSPA -- "real-time" --> Database

    Auth -->|"auth responses"| ReactSPA
    Database -->|"data responses"| ReactSPA

    %% Click Events - Frontend
    click StaticAssets "https://github.com/m3ayush/study-zen-23/blob/main/index.html"
    click StaticAssets "https://github.com/m3ayush/study-zen-23/blob/main/public/robots.txt"
    click StaticAssets "https://github.com/m3ayush/study-zen-23/blob/main/src/main.tsx"
    click StaticAssets "https://github.com/m3ayush/study-zen-23/blob/main/src/App.tsx"
    click StaticAssets "https://github.com/m3ayush/study-zen-23/blob/main/src/index.css"

    click Pages "https://github.com/m3ayush/study-zen-23/blob/main/src/pages/Auth.tsx"
    click Pages "https://github.com/m3ayush/study-zen-23/blob/main/src/pages/Dashboard.tsx"
    click Pages "https://github.com/m3ayush/study-zen-23/blob/main/src/pages/Exams.tsx"
    click Pages "https://github.com/m3ayush/study-zen-23/blob/main/src/pages/Index.tsx"
    click Pages "https://github.com/m3ayush/study-zen-23/blob/main/src/pages/NotFound.tsx"
    click Pages "https://github.com/m3ayush/study-zen-23/blob/main/src/pages/Notes.tsx"
    click Pages "https://github.com/m3ayush/study-zen-23/blob/main/src/pages/Pomodoro.tsx"
    click Pages "https://github.com/m3ayush/study-zen-23/blob/main/src/pages/Settings.tsx"
    click Pages "https://github.com/m3ayush/study-zen-23/blob/main/src/pages/Tasks.tsx"

    click ComponentsUI "https://github.com/m3ayush/study-zen-23/tree/main/src/components/ui"

    click Layouts "https://github.com/m3ayush/study-zen-23/blob/main/src/components/Header.tsx"
    click Layouts "https://github.com/m3ayush/study-zen-23/blob/main/src/components/Layout.tsx"
    click Layouts "https://github.com/m3ayush/study-zen-23/blob/main/src/components/Sidebar.tsx"
    click Layouts "https://github.com/m3ayush/study-zen-23/blob/main/src/components/ProtectedRoute.tsx"

    click SupabaseClient "https://github.com/m3ayush/study-zen-23/blob/main/src/integrations/supabase/client.ts"
    click SupabaseClient "https://github.com/m3ayush/study-zen-23/blob/main/src/integrations/supabase/types.ts"

    click Utils "https://github.com/m3ayush/study-zen-23/blob/main/src/lib/utils.ts"
    click Utils "https://github.com/m3ayush/study-zen-23/blob/main/src/hooks/use-mobile.tsx"
    click Utils "https://github.com/m3ayush/study-zen-23/blob/main/src/hooks/use-toast.ts"

    click BuildDeploy "https://github.com/m3ayush/study-zen-23/blob/main/vite.config.ts"
    click BuildDeploy "https://github.com/m3ayush/study-zen-23/blob/main/tailwind.config.ts"
    click BuildDeploy "https://github.com/m3ayush/study-zen-23/blob/main/postcss.config.js"
    click BuildDeploy "https://github.com/m3ayush/study-zen-23/blob/main/tsconfig.json"
    click BuildDeploy "https://github.com/m3ayush/study-zen-23/blob/main/tsconfig.app.json"
    click BuildDeploy "https://github.com/m3ayush/study-zen-23/blob/main/tsconfig.node.json"

    %% Click Events - Backend
    click Migrations "https://github.com/m3ayush/study-zen-23/blob/main/supabase/migrations/20251011182307_5a223601-7054-4f18-9bab-abfa27fc55b9.sql"
    click Auth "https://github.com/m3ayush/study-zen-23/blob/main/supabase/config.toml"

    %% Styles
    classDef frontend fill:#a8e6cf,stroke:#333,stroke-width:1px
    classDef external fill:#f0f0f0,stroke:#333,stroke-width:1px
    classDef artifact fill:#dcedc1,stroke:#333,stroke-width:1px
    classDef ui fill:#ffd3b6,stroke:#333,stroke-width:1px
    classDef integration fill:#ffaaa5,stroke:#333,stroke-width:1px
    classDef utility fill:#ff8b94,stroke:#333,stroke-width:1px
    classDef service fill:#c3bef0,stroke:#333,stroke-width:1px
    classDef db fill:#b5e7a0,stroke:#333,stroke-width:1px
```
