# hareb4/sadim architecture

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

- Interactive diagram: https://gitdiagram.com/hareb4/sadim
- Repository: https://github.com/hareb4/sadim

## Overview

##### High-Level Components

a) Client-Side (Frontend):
- Next.js Application Layer
- Authentication Layer
- UI Components Layer
- State Management Layer

b) Server-Side:
- Next.js API Routes
- Authentication Services
- File Upload Service (UploadThing)

c) External Services:
- Supabase (for authentication and data storage)
- UploadThing (for file uploads)

##### Detailed Component Breakdown

a) Frontend Architecture:
- Home (/)
- Notes (/notes)
- Authentication (/login, /register)
- Individual Note Pages (/notes/[id])

- UI Components (src/components/ui)
- Layout Components (Header, Sidebar)
- Auth Components
- -specific Components
- Custom UI Components

b) State Management & Context:
- NotesContext provider
- Auth Provider
- Theme Provider

c) API Layer:
- Next.js API Routes
- UploadThing Integration
- Supabase Client

##### Data Flow Representation

- User authentication flow
- Creation/editing flow
- File upload flow
- State updates and context propagation

##### Specific Implementation Details

Technical details:
- Next.js 13+ App Router structure
- Server-side vs Client Components
- Authentication flow with Supabase
- File upload pipeline with UploadThing

**[User Interface Layer]**
- ↕
**[Component Layer]**
- ↕
**[State Management Layer]**
- ↕
**[API Integration Layer]**
- ↕
**[External Services Layer]**

##### Additional Notes

Annotations for:
- Security boundaries
- Authentication checkpoints
- Data persistence points
- Caching strategies
- Internationalization points

Remember to:
- Use consistent styling
- Version information
- Document key dependencies

This architecture represents a modern Next.js application with full-stack capabilities, focusing on note management with rich features like authentication, file uploads, and internationalization.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "User Interface Layer"
        UI[User Interface]
        Pages[Pages]
        UI --> Pages
        
        subgraph "Page Routes"
            Home["/"]
            Notes["/notes"]
            Auth["/auth"]
            NoteDetail["/notes/[id]"]
        end
    end

    subgraph "Component Layer"
        Layout[Layout Components]:::layout
        UIComp[UI Components]:::ui
        AuthComp[Auth Components]:::auth
        NoteComp[Note Components]:::notes
        
        Pages --> Layout
        Pages --> UIComp
        Pages --> AuthComp
        Pages --> NoteComp
    end

    subgraph "State Management Layer"
        NotesCtx[Notes Context]:::state
        AuthProvider[Auth Provider]:::state
        ThemeProvider[Theme Provider]:::state
        I18nProvider[i18n Provider]:::state
    end

    subgraph "API Integration Layer"
        APIRoutes["Next.js API Routes"]:::api
        UploadAPI[Upload Service]:::api
        SupabaseClient[Supabase Client]:::api
    end

    subgraph "External Services Layer"
        Supabase[(Supabase DB)]:::external
        UploadThing[UploadThing Service]:::external
    end

    %% Connections
    Layout --> NotesCtx
    Layout --> ThemeProvider
    AuthComp --> AuthProvider
    NoteComp --> NotesCtx
    NotesCtx --> APIRoutes
    AuthProvider --> SupabaseClient
    UploadAPI --> UploadThing
    SupabaseClient --> Supabase
    
    %% Click Events
    click Layout "https://github.com/Hareb4/sadim/tree/main/src/components/layout"
    click AuthComp "https://github.com/Hareb4/sadim/tree/main/src/components/auth"
    click UIComp "https://github.com/Hareb4/sadim/tree/main/src/components/ui"
    click AuthProvider "https://github.com/Hareb4/sadim/blob/main/src/components/providers/AuthProvider.js"
    click ThemeProvider "https://github.com/Hareb4/sadim/blob/main/src/components/providers/ThemeProvider.jsx"
    click NotesCtx "https://github.com/Hareb4/sadim/blob/main/src/context/NotesContext.js"
    click UploadAPI "https://github.com/Hareb4/sadim/blob/main/src/lib/uploadthing.ts"
    click SupabaseClient "https://github.com/Hareb4/sadim/blob/main/src/lib/supabaseClient.js"
    click Notes "https://github.com/Hareb4/sadim/tree/main/src/app/notes"
    click Auth "https://github.com/Hareb4/sadim/tree/main/src/app/(auth)"
    click Home "https://github.com/Hareb4/sadim/blob/main/src/app/page.js"

    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white
    classDef state fill:#9b59b6,stroke:#8e44ad,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef layout fill:#34495e,stroke:#2c3e50,color:white
    classDef notes fill:#1abc9c,stroke:#16a085,color:white

    %% Legend
    subgraph Legend
        L1[UI Components]:::ui
        L2[Auth Components]:::auth
        L3[State Management]:::state
        L4[API Services]:::api
        L5[External Services]:::external
        L6[Layout Components]:::layout
        L7[Note Components]:::notes
    end
```
