# handikatriarlan/our-beautiful-summer-api architecture

> Architecture diagram of the GitHub repository handikatriarlan/our-beautiful-summer-api, 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/handikatriarlan/our-beautiful-summer-api
- Repository: https://github.com/handikatriarlan/our-beautiful-summer-api

## Overview

##### Main Components

A. Client Layer
- External clients (Mobile/Web applications)
- Interaction through REST API endpoints

B. API Layer (NestJS)
- Controllers (MemoriesController)
- Services (MemoriesService, AppService)
- DTOs (Memory DTOs)
- Modules organization (AppModule, DatabaseModule, MemoriesModule)

C. Storage Layer
- Supabase Database
- Supabase Storage (for photos)

**┌─ Client Layer ─────────────────────┐**
- Mobile/Web Clients                 │
- (Consuming REST API)               │
- ┬───────────────────┘
- ↓
**┌─ API Layer ────────────────────────┐**
- ┌─ NestJS Application ───────────┐ │
- ┌─ Controllers ──────────────┐ │ │
- MemoriesController      │ │ │
- ┬────────────┘ │ │
- ↓              │ │
- ┌─ Services ───────────────┐  │ │
- MemoriesService       │  │ │
- SupabaseService       │  │ │
- ┬──────────┘  │ │
- ┼─────────────┘ │
- ┼───────────────┘
- ↓
**┌─ Storage Layer ──────────────────┐**
- ┌─ Supabase ─────────────────┐   │
- Database (memories table) │   │
- Storage (photos bucket)   │   │
- ┘    │
- ┘

##### Important Relationships to Highlight

- REST API endpoints from MemoriesController:
- POST /api/memories
- GET /api/memories
- GET /api/memories/:id
- /api/memories/:id
- DELETE /api/memories/:id

- Service Layer Interactions:
- MemoriesService → SupabaseService
- SupabaseService → Supabase Database/Storage

##### Additional Elements

- API endpoint details in a side panel
- Validation flow through DTOs
- Error handling paths
- Security boundaries (Supabase RLS)

##### Technical Details

- NestJS Modules structure
- Supabase integration points
- File upload flow for photos
- Database schema reference
- Environment configuration dependencies

##### Implementation Notes

- Separation of concerns between modules
- TypeScript integration
- Testing boundaries
- Deployment-specific components (Vercel configuration)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style definitions
    classDef client fill:#a8d1f0,stroke:#000
    classDef api fill:#90EE90,stroke:#000
    classDef storage fill:#FFB347,stroke:#000
    classDef controller fill:#98FB98,stroke:#000
    classDef service fill:#90EE90,stroke:#000
    classDef module fill:#98FB98,stroke:#000
    classDef dto fill:#98FB98,stroke:#000

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        Client["Mobile/Web Clients"]:::client
    end

    %% API Layer
    subgraph APILayer["API Layer (NestJS)"]
        subgraph Modules["NestJS Modules"]
            AppMod["AppModule"]:::module
            DBMod["DatabaseModule"]:::module
            MemMod["MemoriesModule"]:::module
        end

        subgraph Controllers["Controllers"]
            MemController["MemoriesController"]:::controller
        end

        subgraph Services["Services"]
            MemService["MemoriesService"]:::service
            SupaService["SupabaseService"]:::service
            AppServ["AppService"]:::service
        end

        subgraph DTOs["Data Transfer Objects"]
            MemoryDTO["Memory DTOs"]:::dto
        end

        Entry["Application Entry Point"]:::api
    end

    %% Storage Layer
    subgraph StorageLayer["Storage Layer"]
        subgraph Supabase["Supabase"]
            SupaDB[(Database)]:::storage
            SupaStorage[("Storage\n(Photos)")]:::storage
        end
    end

    %% Relationships
    Client --> MemController
    MemController --> MemService
    MemService --> MemoryDTO
    MemService --> SupaService
    SupaService --> SupaDB
    SupaService --> SupaStorage
    
    %% Module relationships
    AppMod --> DBMod
    AppMod --> MemMod
    MemMod --> MemController
    DBMod --> SupaService

    %% Click events
    click MemController "https://github.com/handikatriarlan/our-beautiful-summer-api/blob/main/src/memories/memories.controller.ts"
    click MemService "https://github.com/handikatriarlan/our-beautiful-summer-api/blob/main/src/memories/memories.service.ts"
    click SupaService "https://github.com/handikatriarlan/our-beautiful-summer-api/blob/main/src/database/supabase.service.ts"
    click AppServ "https://github.com/handikatriarlan/our-beautiful-summer-api/blob/main/src/app.service.ts"
    click MemoryDTO "https://github.com/handikatriarlan/our-beautiful-summer-api/blob/main/src/memories/dto/memory.dto.ts"
    click AppMod "https://github.com/handikatriarlan/our-beautiful-summer-api/blob/main/src/app.module.ts"
    click DBMod "https://github.com/handikatriarlan/our-beautiful-summer-api/blob/main/src/database/database.module.ts"
    click MemMod "https://github.com/handikatriarlan/our-beautiful-summer-api/blob/main/src/memories/memories.module.ts"
    click SupaDB "https://github.com/handikatriarlan/our-beautiful-summer-api/blob/main/supabase/migrations/0001_memories.sql"
    click Entry "https://github.com/handikatriarlan/our-beautiful-summer-api/blob/main/src/main.ts"

    %% Legend
    subgraph Legend["Legend"]
        L_Client["Client Component"]:::client
        L_API["API Component"]:::api
        L_Storage["Storage Component"]:::storage
    end
```
