# jacobarrow/spejderbogen architecture

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

- Interactive diagram: https://gitdiagram.com/jacobarrow/spejderbogen
- Repository: https://github.com/jacobarrow/spejderbogen

## Overview

##### Main Application Architecture

a. Client Layer
- SvelteKit Frontend Components (src/lib/components)
- Client-side Routes (src/routes)
- Service Worker (for PWA functionality)

b. Server Layer
- API Routes (src/routes/api)
- Data Layer (src/lib/data)

##### Component Structure

a. Core Components Section
- Header & Navbar
- Footer
- Card Components
- Search Components
- Modal & Drawer

b. Feature Components Section
- Related components:
- Song-related (SongCard, PopularSongs)
- Management (AddToList, PaginatedList)
- UI Elements (Carousel, FAB, Like)

##### Routing Structure
- Main routes (/sange, /kategorier, /forfattere, /lister, /favoritter)
- Dynamic routes ([slug] based routes)
- API endpoints structure

##### Technical Implementation Details
- Build tools (Vite, PostCSS, Tailwind)
- TypeScript integration
- Service Worker implementation

##### Components
- Use rectangles for components
- Use rounded rectangles for pages
- Use hexagons for API endpoints

##### Relationships
- Double lines: Data flow

##### Labels
- Component names
- Route paths
- API endpoint URLs
- Function names for key utilities

Key Architectural Patterns to Highlight:

##### Utility function organization

Additional Notes:
- Notes about the build process
- PWA aspects (manifest.webmanifest and service-worker)
- Relationship between API routes and their corresponding implementation files

Level of Detail:

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        direction TB
        FC["Frontend Components"]
        RT["Routes"]
        SW["Service Worker"]:::pwa
        
        subgraph Components["Component Structure"]
            direction TB
            HC["Header Component"]:::component
            NC["Navbar Component"]:::component
            FC1["Footer Component"]:::component
            CC["Card Components"]:::component
            SC["Search Components"]:::component
            MD["Modal & Drawer"]:::component
        end

        subgraph Routes["Route Structure"]
            direction TB
            ML["Main Layout"]:::route
            SR["Songs Route"]:::route
            CR["Categories Route"]:::route
            AR["Authors Route"]:::route
            LR["Lists Route"]:::route
            FR["Favorites Route"]:::route
        end
    end

    subgraph Server["Server Layer"]
        direction TB
        API["API Routes"]
        DL["Data Layer"]

        subgraph APIRoutes["API Implementations"]
            direction TB
            SA["Songs API"]:::api
            AA["Authors API"]:::api
            CA["Categories API"]:::api
        end

        subgraph DataLayer["Data Management"]
            direction TB
            DB["Database Interface"]:::data
        end
    end

    subgraph Build["Build & Config"]
        direction TB
        VC["Vite Config"]:::config
        TC["Tailwind Config"]:::config
        TSC["TypeScript Config"]:::config
        PC["PostCSS Config"]:::config
    end

    subgraph Utils["Utility Functions"]
        direction TB
        SF["Search Function"]:::util
        UH["URL Handler"]:::util
        PG["Pagination"]:::util
    end

    %% Relationships
    Client --> Server
    Components --> Routes
    Routes --> APIRoutes
    APIRoutes --> DataLayer
    Utils --> Components
    Utils --> Routes

    %% Click Events
    click HC "https://github.com/JacobArrow/spejderbogen/blob/master/src/lib/components/Header.svelte"
    click NC "https://github.com/JacobArrow/spejderbogen/blob/master/src/lib/components/Navbar.svelte"
    click FC1 "https://github.com/JacobArrow/spejderbogen/blob/master/src/lib/components/Footer.svelte"
    click CC "https://github.com/JacobArrow/spejderbogen/blob/master/src/lib/components/Card.svelte"
    click SC "https://github.com/JacobArrow/spejderbogen/blob/master/src/lib/components/Search.svelte"
    click MD "https://github.com/JacobArrow/spejderbogen/blob/master/src/lib/components/Modal.svelte"
    click ML "https://github.com/JacobArrow/spejderbogen/blob/master/src/routes/+layout.svelte"
    click SR "https://github.com/JacobArrow/spejderbogen/blob/master/src/routes/sange/+page.svelte"
    click CR "https://github.com/JacobArrow/spejderbogen/blob/master/src/routes/kategorier/+page.svelte"
    click AR "https://github.com/JacobArrow/spejderbogen/blob/master/src/routes/forfattere/+page.svelte"
    click LR "https://github.com/JacobArrow/spejderbogen/blob/master/src/routes/lister/+page.svelte"
    click FR "https://github.com/JacobArrow/spejderbogen/blob/master/src/routes/favoritter/+page.svelte"
    click SA "https://github.com/JacobArrow/spejderbogen/blob/master/src/routes/api/songs/api.js"
    click AA "https://github.com/JacobArrow/spejderbogen/blob/master/src/routes/api/authors/api.js"
    click CA "https://github.com/JacobArrow/spejderbogen/blob/master/src/routes/api/categories/api.js"
    click DB "https://github.com/JacobArrow/spejderbogen/blob/master/src/lib/data/db.js"
    click SW "https://github.com/JacobArrow/spejderbogen/blob/master/src/service-worker/index.ts"
    click SF "https://github.com/JacobArrow/spejderbogen/blob/master/src/lib/functions/search.ts"
    click UH "https://github.com/JacobArrow/spejderbogen/blob/master/src/lib/functions/convertUrl.ts"
    click PG "https://github.com/JacobArrow/spejderbogen/blob/master/src/lib/functions/pagination.ts"
    click VC "https://github.com/JacobArrow/spejderbogen/blob/master/vite.config.js"
    click TC "https://github.com/JacobArrow/spejderbogen/blob/master/tailwind.config.cjs"
    click TSC "https://github.com/JacobArrow/spejderbogen/blob/master/tsconfig.json"
    click PC "https://github.com/JacobArrow/spejderbogen/blob/master/postcss.config.cjs"

    %% Styling
    classDef component fill:#3498db,stroke:#2980b9,color:white
    classDef route fill:#2ecc71,stroke:#27ae60,color:white
    classDef api fill:#e74c3c,stroke:#c0392b,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:white
    classDef config fill:#9b59b6,stroke:#8e44ad,color:white
    classDef util fill:#1abc9c,stroke:#16a085,color:white
    classDef pwa fill:#e67e22,stroke:#d35400,color:white
```
