# dubeyanant/link-list architecture

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

- Interactive diagram: https://gitdiagram.com/dubeyanant/link-list
- Repository: https://github.com/dubeyanant/link-list

## Overview

##### Main Components
- Client/User Interface: Represented by the Next.js application. The pages and layouts found in the src/app directory form the UI, and the components (src/components) structure the various parts of the user interface (e.g., ListForm, NamesList, PageFooter).
- Application Logic: This is also in the Next.js layer, where hooks (src/hooks/useListData.js) and utilities (src/utils/supabase.js, src/utils/dateFormatters.js) manage data fetching, real-time updates, and date processing.
- Backend / Data Services: Although there is no custom server code, Supabase acts as the backend service. It handles database operations and real-time updates, using PostgreSQL as its underlying database.
- Database: The Supabase instance is backed by PostgreSQL and includes at least one table (lists) that supports realtime updates and automatic deletion after 7 days.

##### Relationships and Interactions
- The Client UI (browser) interacts with the Next.js frontend application.
- Next.js makes API calls or uses the Supabase client (configured in src/utils/supabase.js) to communicate with the Supabase backend.
- Supabase manages the database, ensuring that new names get added to the list (via realtime subscriptions) and that lists are automatically expired based on the SQL configuration.
- The real-time data flow is bi-directional between the Next.js hooks and Supabase, ensuring updates are sent to users instantly.

##### Important Architectural Patterns
- Server-Side Rendering / Client-Side Rendering provided by Next.js.
- Component-based design in React using Next.js conventions (folder structure in src/app and src/components).
- Use of hooks for stateful logic (like real-time updates from Supabase).
- External API integration with Supabase for database and realtime event management.

##### Relevant Technologies
- Next.js (React framework for frontend and server-side rendering).
- Supabase for database hosting and realtime functionality.
- PostgreSQL as the underlying database managed by Supabase.
- Additional utilities like ESLint and PostCSS for coding standards and styling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User/Client Layer
    subgraph "User/Client"
        Client["Web Browser"]:::user
    end

    %% Next.js Frontend Layer
    subgraph "Next.js Frontend"
        %% Pages (src/app)
        subgraph "Pages (src/app)"
            P1["page.js"]:::frontend
            P2["layout.js"]:::frontend
            P3["[id] page.js"]:::frontend
        end
        %% Components (src/components)
        subgraph "Components (src/components)"
            C1["ListForm.jsx"]:::frontend
            C2["NamesList.jsx"]:::frontend
            C3["ListHeader.jsx"]:::frontend
            C4["PageFooter.jsx"]:::frontend
        end
        %% Application Logic
        subgraph "Application Logic"
            AL1["useListData.js"]:::logic
            AL2["supabase.js"]:::logic
            AL3["dateFormatters.js"]:::logic
        end
    end

    %% Supabase Backend Layer
    subgraph "Supabase Backend"
        S["Supabase Realtime Engine"]:::backend
        DB["PostgreSQL Database (Lists expire after 7 days)"]:::database
        S -->|"manages"| DB
    end

    %% Connections between Layers
    Client -->|"HTTPRequests"| P1
    P1 -->|"fetchData"| AL1
    AL1 -->|"updateUI"| C2
    AL2 -->|"SupabaseClientCalls"| S
    S -->|"RealtimeUpdates"| AL1

    %% Styles
    classDef user fill:#ffe6cc,stroke:#ff9900,stroke-width:2px;
    classDef frontend fill:#cce5ff,stroke:#1a75ff,stroke-width:2px;
    classDef logic fill:#f9d5bb,stroke:#ed6a5a,stroke-width:2px;
    classDef backend fill:#e2f0d9,stroke:#82b366,stroke-width:2px;
    classDef database fill:#d1c4e9,stroke:#7e57c2,stroke-width:2px;

    %% Click Events for Component Mapping
    click P1 "https://github.com/dubeyanant/link-list/blob/main/src/app/page.js"
    click P2 "https://github.com/dubeyanant/link-list/blob/main/src/app/layout.js"
    click P3 "https://github.com/dubeyanant/link-list/blob/main/src/app/[id]/page.js"
    click C1 "https://github.com/dubeyanant/link-list/blob/main/src/components/list/ListForm.jsx"
    click C2 "https://github.com/dubeyanant/link-list/blob/main/src/components/list/NamesList.jsx"
    click C3 "https://github.com/dubeyanant/link-list/blob/main/src/components/list/ListHeader.jsx"
    click C4 "https://github.com/dubeyanant/link-list/blob/main/src/components/layout/PageFooter.jsx"
    click AL1 "https://github.com/dubeyanant/link-list/blob/main/src/hooks/useListData.js"
    click AL2 "https://github.com/dubeyanant/link-list/blob/main/src/utils/supabase.js"
    click AL3 "https://github.com/dubeyanant/link-list/blob/main/src/utils/dateFormatters.js"
```
