# manuel-heav/built architecture

> Architecture diagram of the GitHub repository manuel-heav/built, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manuel-heav/built
- Repository: https://github.com/manuel-heav/built

## Overview

##### Main Components Structure

a) Client Layer (Frontend)
- Next.js 14 application structure
- Main routes: Home, Projects, Auth, Project Form, and Edit Form
- Components directory with shared UI elements

b) API Layer (Backend)
- API routes structure using Hono.js
- Authentication flow with Better-Auth
- Project and comments endpoints

c) Data Layer
- Supabase and PostgreSQL
- Authentication storage
- Project and user data storage

##### Component Relationships

- Client-to-API interactions with RESTful endpoints
- API-to-Database flows
- Authentication flows between all layers

##### Specific Implementation Details

**Frontend Components:**
- Pages (/, /projects, /project/[id], etc.)
- Shared Components (UI components)
- Layout Components
- Theme Provider

**API Routes:**
- Auth Routes (/api/auth/[...all])
- Project Routes (/api/projects/*)
- Comments Routes (/api/comments/*)

**Database:**
- User Tables
- Project Tables
- Comments Tables

##### Detailed Elements

Frontend Layer:
- Next.js app router structure
- ProviderWrapper component
- Shared UI components
- Theme management system

API Layer:
- API endpoints grouped by feature
- Authentication middleware
- Protected routes

Database Layer:
- Supabase integration
- Main data models
- Authentication tables

##### Flow Indicators

- User authentication flow
- Project creation/editing flow
- Comment submission flow
- Data fetching patterns

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[Frontend Layer]
        HP["Home Page"]:::page
        PP["Projects Page"]:::page
        PDP["Project Detail Page"]:::page
        PFP["Project Form Page"]:::page
        EFP["Edit Form Page"]:::page
        AP["Auth Pages"]:::page
        
        UI["UI Components"]:::component
        TC["Theme Components"]:::component
        LW["Layout Wrapper"]:::component
        SC["Shared Components"]:::component
        
        PC["Project Cards"]:::component
        PF["Project Filter"]:::component
        PCN["Project Container"]:::component
        CM["Comments System"]:::component
    end
    
    subgraph API
        AR["Auth Routes"]:::api
        PR["Projects Routes"]:::api
        CR["Comments Routes"]:::api
        PLR["Project Likes Routes"]:::api
    end
    
    subgraph Data
        SC_DB["Supabase Client"]:::db
        AL["Auth Logic"]:::db
        DS["Database Schema"]:::db
        
        subgraph Tables
            UT["User Tables"]:::table
            PT["Project Tables"]:::table
            CT["Comments Tables"]:::table
        end
    end
    
    %% Frontend Connections
    FE --> HP & PP & PDP & PFP & EFP & AP
    FE --> UI & TC & LW & SC
    SC --> PC & PF & PCN & CM
    
    %% API Connections
    HP & PP & PDP --> PR
    CM --> CR
    PC --> PLR
    AP --> AR
    
    %% Data Connections
    AR & PR & CR & PLR --> SC_DB
    SC_DB --> UT & PT & CT
    AR --> AL
    
    %% Styling
    classDef page fill:#4a9eff,stroke:#333,stroke-width:2px
    classDef component fill:#66b3ff,stroke:#333,stroke-width:2px
    classDef api fill:#4CAF50,stroke:#333,stroke-width:2px
    classDef db fill:#9C27B0,stroke:#333,stroke-width:2px
    classDef table fill:#7B1FA2,stroke:#333,stroke-width:2px
    
    %% Click Events
    click HP "https://github.com/manuel-heav/built/blob/main/app/page.tsx"
    click PP "https://github.com/manuel-heav/built/blob/main/app/projects/page.tsx"
    click AP "https://github.com/manuel-heav/built/tree/main/app/auth/"
    click PFP "https://github.com/manuel-heav/built/tree/main/app/project-form/"
    click EFP "https://github.com/manuel-heav/built/tree/main/app/edit-form/"
    click PDP "https://github.com/manuel-heav/built/tree/main/app/project/[id]/"
    click UI "https://github.com/manuel-heav/built/tree/main/components/ui/"
    click TC "https://github.com/manuel-heav/built/tree/main/components/theme/"
    click LW "https://github.com/manuel-heav/built/blob/main/app/(ProviderWrapper)/layout.tsx"
    click SC "https://github.com/manuel-heav/built/tree/main/components/"
    click AR "https://github.com/manuel-heav/built/blob/main/app/api/auth/[...all]/route.ts"
    click PR "https://github.com/manuel-heav/built/tree/main/app/api/projects/"
    click CR "https://github.com/manuel-heav/built/tree/main/app/api/comments/"
    click PLR "https://github.com/manuel-heav/built/blob/main/app/api/projects/[id]/like/route.ts"
    click SC_DB "https://github.com/manuel-heav/built/blob/main/lib/supabaseClient.ts"
    click AL "https://github.com/manuel-heav/built/blob/main/lib/auth.ts"
    click DS "https://github.com/manuel-heav/built/blob/main/schema/index.ts"
    click CM "https://github.com/manuel-heav/built/blob/main/components/comments.tsx"
    click PC "https://github.com/manuel-heav/built/blob/main/components/project-card.tsx"
    click PF "https://github.com/manuel-heav/built/blob/main/components/project-filter.tsx"
    click PCN "https://github.com/manuel-heav/built/blob/main/components/projects-container.tsx"
```
