# theolalande/pin-it architecture

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

- Interactive diagram: https://gitdiagram.com/theolalande/pin-it
- Repository: https://github.com/theolalande/pin-it

## Overview

##### Project Type and Purpose
- Full-stack web application built with Next.js 14 and TypeScript.
- Purpose: a PWA for sharing geolocated points of interest (“Pin-It”) with interactive maps, image upload, comments, favorites, offline mode and accessibility compliance.
- Backend is provided by Supabase (Auth, PostgreSQL database, Storage) via Next.js API routes.

##### File Structure Analysis
- src/app – Next.js App Router:
– api/… – serverless API routes (auth, pinpoints, comments, favorites, users, upload, health).
– components/… – UI components organized by feature (Map, PinPoint, ImageUploader, FullScreenImageModal, MyPinPoints, Searchbar, Settings, Common).
– contexts/, hooks/, store/ – React Context for auth, custom hooks (useAuth, useFavorites, useImageUpload…), Zustand store for client state.
– layout.tsx, page.tsx – root layout and entry points.
- src/lib/database.ts – Supabase client initialization.
- public/ – static assets, PWA manifest, service worker, map styles.
- utils/ – helper functions (security, accessibility, image processing, map utilities).
- test/ – unit, integration and security tests (Vitest).
- Configuration & deployment – Dockerfile, .github/workflows for CI & preview, Vercel recommended, .env example.

##### Key README Insights
- Core tech: Next.js App Router, React Leaflet, Tailwind CSS, Supabase, PostgreSQL, Storage.
- PWA features: offline caching (service worker), manifest, install prompt.
- Security layers: rate-limiting, sanitization, OWASP best practices, server-side/client-side validation.
- Accessibility: WCAG 2.1 compliance.
- Testing: Vitest for unit, integration, security and accessibility tests.

– Client components (blue)
– Server/API (green)
– BaaS (orange)
– External services (gray)
- Related elements in zones (e.g., “Next.js Runtime”, “Supabase Platform”, “User’s Browser”).
- Notes on PWA capabilities (offline cache, install prompt) and security layers (rate-limiting, validation).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser / PWA Layer
    subgraph "User’s Browser" 
        direction TB
        UI["React UI (Next.js App)"]:::client
        SW["Service Worker"]:::client
        Manifest["manifest.json"]:::client
        PWAHandler["PWAInstallHandler"]:::client
        UI -->|renders pages| UI
    end

    click SW "https://github.com/theolalande/pin-it/blob/main/public/sw.js"
    click Manifest "https://github.com/theolalande/pin-it/blob/main/public/manifest.json"
    click PWAHandler "https://github.com/theolalande/pin-it/blob/main/src/app/components/Common/PWAInstallHandler.tsx"
    click UI "https://github.com/theolalande/pin-it/blob/main/src/app/_offline/page.tsx"

    %% Next.js Runtime
    subgraph "Next.js Runtime" 
        direction TB

        subgraph "Frontend (App Router)" 
            direction TB
            Layout["layout.tsx"]:::frontend
            HomePage["page.tsx"]:::frontend
            LoginPage["login/page.tsx"]:::frontend
            RegisterPage["register/page.tsx"]:::frontend
            SettingsPage["settings/page.tsx"]:::frontend
            Middleware["middleware.ts"]:::frontend
        end

        subgraph "API Layer (BFF)" 
            direction TB
            AuthAPI["Auth API Routes"]:::api
            PinpointsAPI["PinPoints API Routes"]:::api
            CommentsAPI["Comments API Routes"]:::api
            FavoritesAPI["Favorites API Routes"]:::api
            UsersAPI["Users API Routes"]:::api
            UploadAPI["Upload API Route"]:::api
            HealthAPI["Health Check Route"]:::api
        end

        subgraph "Client State & Context" 
            direction TB
            AuthContext["AuthContext"]:::app
            Store["Zustand Store"]:::app
            Hooks["Custom Hooks"]:::app
        end

        DBClient["Supabase Client Init"]:::infra

        %% Relationships inside Next.js
        Layout -->|wraps| HomePage
        Layout -->|wraps| LoginPage
        Layout -->|wraps| RegisterPage
        Layout -->|wraps| SettingsPage
        HomePage -->|calls API| PinpointsAPI
        LoginPage -->|calls API| AuthAPI
        RegisterPage -->|calls API| AuthAPI
        SettingsPage -->|calls API| UsersAPI
        Hooks -->|used by| UI
        AuthContext -->|provides to| UI
        AuthAPI -->|uses| DBClient
        PinpointsAPI -->|uses| DBClient
        CommentsAPI -->|uses| DBClient
        FavoritesAPI -->|uses| DBClient
        UsersAPI -->|uses| DBClient
        UploadAPI -->|uses| DBClient
        HealthAPI -->|uses| DBClient

    end

    click Layout "https://github.com/theolalande/pin-it/blob/main/src/app/layout.tsx"
    click HomePage "https://github.com/theolalande/pin-it/blob/main/src/app/page.tsx"
    click LoginPage "https://github.com/theolalande/pin-it/blob/main/src/app/login/page.tsx"
    click RegisterPage "https://github.com/theolalande/pin-it/blob/main/src/app/register/page.tsx"
    click SettingsPage "https://github.com/theolalande/pin-it/blob/main/src/app/settings/page.tsx"
    click Middleware "https://github.com/theolalande/pin-it/blob/main/src/middleware.ts"
    click AuthAPI "https://github.com/theolalande/pin-it/blob/main/src/app/api/auth/login/route.ts"
    click PinpointsAPI "https://github.com/theolalande/pin-it/blob/main/src/app/api/pinpoints/route.ts"
    click CommentsAPI "https://github.com/theolalande/pin-it/blob/main/src/app/api/comments/[pointId]/route.ts"
    click FavoritesAPI "https://github.com/theolalande/pin-it/blob/main/src/app/api/favorites/route.ts"
    click UsersAPI "https://github.com/theolalande/pin-it/blob/main/src/app/api/users/profiles/route.ts"
    click UploadAPI "https://github.com/theolalande/pin-it/blob/main/src/app/api/upload/route.ts"
    click HealthAPI "https://github.com/theolalande/pin-it/blob/main/src/app/api/health/route.ts"
    click DBClient "https://github.com/theolalande/pin-it/blob/main/src/lib/database.ts"
    click AuthContext "https://github.com/theolalande/pin-it/blob/main/src/app/contexts/AuthContext.tsx"
    click Store "https://github.com/theolalande/pin-it/blob/main/src/app/store/commonStore.ts"
    click Hooks "https://github.com/theolalande/pin-it/blob/main/src/app/hooks/useAuth.ts"

    %% Supabase Platform
    subgraph "Supabase Platform"
        direction TB
        AuthService["Auth (JWT)"]:::baas
        PostgresDB["PostgreSQL DB"]:::baas
        StorageService["Storage (Images)"]:::baas
    end

    DBClient --> AuthService
    DBClient --> PostgresDB
    DBClient --> StorageService

    %% External Services
    subgraph "External Services"
        direction TB
        MapTiles["Map Tile Provider"]:::external
        PushNotif["Push Notifications (Future)"]:::external
    end

    UI -->|fetch tiles| MapTiles

    %% CI/CD & Deployment
    subgraph "CI/CD & Deployment"
        direction TB
        CI["GitHub Actions"]:::infra
        Vercel["Vercel / Docker"]:::infra
    end

    CI -->|runs tests & lint| Vercel
    Vercel -->|hosts| UI
    Vercel -->|hosts| API

    click CI "https://github.com/theolalande/pin-it/blob/main/.github/workflows/ci.yml"
    click Vercel "https://github.com/theolalande/pin-it/tree/main/Dockerfile"

    %% Service Worker caching flows
    UI -->|network request| SW
    SW -->|caches assets & API| UI

    %% Styles
    classDef client fill:#D0E8FF,stroke:#006BB3,color:#003E7E;
    classDef frontend fill:#DFF7DF,stroke:#2C662D,color:#1B3F1B;
    classDef api fill:#E7F4E4,stroke:#4B8F29,color:#2C5F1A;
    classDef app fill:#FFF4D9,stroke:#D69D00,color:#7A4F01;
    classDef infra fill:#F0E6FF,stroke:#8B49D1,color:#4E1C7F;
    classDef baas fill:#FFE8CC,stroke:#DA8C0D,color:#7A4D00;
    classDef external fill:#F2F2F2,stroke:#888888,color:#555555;
```
