# midudev/esland-web architecture

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

- Interactive diagram: https://gitdiagram.com/midudev/esland-web
- Repository: https://github.com/midudev/esland-web

## Overview

##### Main System Components

a) Frontend Layer
- Static Site Generation (Astro)
- Client-side Components (React/Astro)
- Internationalization System
- Asset Management

b) API Layer
- REST Endpoints (/api/*)
- Voting System
- Gallery Management
- Candidates Management

c) External Services
- Twitch Integration
- Database Connection (for voting system)

##### Specific Component Details

Frontend Components:
- Pages Module (src/pages/*)
- Components Module (src/components/*)
- i18n System (src/i18n/*)
- Hooks Layer (src/hooks/*)
- Layout System (src/layouts/*)

API Components:
- Voting API (src/pages/api/vote.ts)
- Gallery API (src/pages/api/gallery.json.ts)
- Candidates API (src/pages/api/candidates.json.ts)

Data Management:
- Database Client (src/db/client.ts)
- Schema Definitions (src/schemas/*)
- Type Definitions (src/types/*)

##### Relationships and Data Flow

- Client-side routing flows
- API request/response paths
- Data flow between components
- i18n content distribution
- Asset loading paths

##### Technical Stack Indicators

- Astro
- TypeScript
- Tailwind CSS
- Bun/PNPM
- Database system

##### Additional Elements

- Build Configuration (astro.config.mjs, tailwind.config.mjs)
- Environment Configuration (.env)
- Script Utilities
- Public Assets Management

Remember to highlight the multi-language support as it's a key feature, showing how content flows through the i18n system to different language versions of the pages.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        Pages["Pages"]:::frontend
        Components["Components"]:::frontend
        Layouts["Layouts"]:::frontend
        Hooks["Hooks"]:::frontend
        i18n["Internationalization"]:::i18n
        Assets["Asset Management"]:::assets
    end

    subgraph API
        VoteAPI["Vote API"]:::api
        GalleryAPI["Gallery API"]:::api
        CandidatesAPI["Candidates API"]:::api
    end

    subgraph DataManagement
        DBClient["Database Client"]:::database
        Schemas["Schemas"]:::database
        Types["Types"]:::types
    end

    subgraph Components
        VoteSystem["Vote System UI"]:::frontend
        VoteFinal["Vote Final UI"]:::frontend
        Gallery["Gallery UI"]:::frontend
        GalleryHook["Gallery Hook"]:::frontend
    end

    subgraph Config
        AstroConfig["Astro Config"]:::config
        TailwindConfig["Tailwind Config"]:::config
    end

    subgraph i18nSystem
        LangCA["Catalan"]:::i18n
        LangEN["English"]:::i18n
        LangES["Spanish"]:::i18n
        i18nUtils["i18n Utils"]:::i18n
    end

    Pages --> Components
    Components --> Hooks
    Components --> Layouts
    Components --> i18n
    
    VoteSystem --> VoteAPI
    VoteFinal --> VoteAPI
    Gallery --> GalleryAPI
    GalleryHook --> GalleryAPI
    
    VoteAPI --> DBClient
    GalleryAPI --> DBClient
    CandidatesAPI --> DBClient
    
    DBClient --> Schemas
    DBClient --> Types

    i18n --> LangCA
    i18n --> LangEN
    i18n --> LangES
    i18n --> i18nUtils

    %% Click events for component mapping
    click Pages "https://github.com/midudev/esland-web/tree/main/src/pages"
    click Components "https://github.com/midudev/esland-web/tree/main/src/components"
    click Layouts "https://github.com/midudev/esland-web/tree/main/src/layouts"
    click Hooks "https://github.com/midudev/esland-web/tree/main/src/hooks"
    click VoteAPI "https://github.com/midudev/esland-web/blob/main/src/pages/api/vote.ts"
    click GalleryAPI "https://github.com/midudev/esland-web/blob/main/src/pages/api/gallery.json.ts"
    click CandidatesAPI "https://github.com/midudev/esland-web/blob/main/src/pages/api/candidates.json.ts"
    click DBClient "https://github.com/midudev/esland-web/blob/main/src/db/client.ts"
    click Schemas "https://github.com/midudev/esland-web/blob/main/src/schemas/votes.ts"
    click Types "https://github.com/midudev/esland-web/tree/main/src/types"
    click i18n "https://github.com/midudev/esland-web/tree/main/src/i18n"
    click i18nUtils "https://github.com/midudev/esland-web/blob/main/src/i18n/utils.ts"
    click Assets "https://github.com/midudev/esland-web/tree/main/public"
    click AstroConfig "https://github.com/midudev/esland-web/blob/main/astro.config.mjs"
    click TailwindConfig "https://github.com/midudev/esland-web/blob/main/tailwind.config.mjs"
    click VoteSystem "https://github.com/midudev/esland-web/blob/main/src/components/VoteSystem.tsx"
    click VoteFinal "https://github.com/midudev/esland-web/blob/main/src/components/VoteFinal.tsx"
    click Gallery "https://github.com/midudev/esland-web/blob/main/src/components/Galeria.tsx"
    click GalleryHook "https://github.com/midudev/esland-web/blob/main/src/hooks/useGallery.ts"

    classDef frontend fill:#3b82f6,color:white
    classDef api fill:#22c55e,color:white
    classDef database fill:#a855f7,color:white
    classDef assets fill:#f97316,color:white
    classDef config fill:#6b7280,color:white
    classDef i18n fill:#eab308,color:black
    classDef types fill:#ec4899,color:white
```
