# pieterseinen/fantasy_leaflet architecture

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

- Interactive diagram: https://gitdiagram.com/pieterseinen/fantasy_leaflet
- Repository: https://github.com/pieterseinen/fantasy_leaflet

## Overview

##### Project Type Analysis
This is a Shiny web application (indicated by the classic Shiny structure with global.R, server.R, and ui.R files) that extends Leaflet functionality for custom map creation.

##### Key Components

A. Core Application Components:
- UI Layer (ui.R)
- Server Logic (server.R)
- Global Configurations (global.R)
- Static Assets (www folder)

B. External Dependencies:
- Leaflet.js Integration
- Custom Styling (www/custom.css)

##### Client Tier (Top)
- Leaflet.js client-side component
- Custom CSS styling integration

##### Application Tier (Middle)
- Create three connected components:
- UI Component (ui.R)
- Server Logic (server.R)
- Global State (global.R)
- Bidirectional data flow between these components

##### Asset Tier (Bottom)
- Static file serving (www directory)
- Custom styling

Use the following visual elements:

- Rectangles: Main components

- Blue: Core Shiny components
- Green: External libraries (Leaflet)
- Orange: Static assets
- Gray: Client browser

c) Connection Types:

##### Input Processing Flow
- User interaction → UI Layer → Server Logic
- Custom background image upload flow
- Marker placement mechanism

##### Output Generation Flow
- Server processing → Leaflet map generation
- HTML export functionality
- Custom styling application

##### Asset Management
- CSS integration
- Static file serving

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]:::client
        LeafletClient["Leaflet.js Client"]:::external
        Browser --> LeafletClient
    end

    subgraph "Application Layer"
        UI["UI Component"]:::core
        Server["Server Logic"]:::core
        Global["Global Config"]:::core

        UI <--> Server
        Server <--> Global
        UI <--> Global
    end

    subgraph "Asset Layer"
        WWW["Static Assets"]:::asset
        Icons["Font Awesome Icons"]:::asset
        CSS["Custom Styling"]:::asset
    end

    Browser <-.->|HTTP/WebSocket| UI
    LeafletClient <-.->|Map Rendering| Server
    WWW --> UI
    Icons --> UI
    CSS --> Browser

    %% Click Events
    click UI "https://github.com/pieterseinen/fantasy_leaflet/blob/main/ui.R"
    click Server "https://github.com/pieterseinen/fantasy_leaflet/blob/main/server.R"
    click Global "https://github.com/pieterseinen/fantasy_leaflet/blob/main/global.R"
    click WWW "https://github.com/pieterseinen/fantasy_leaflet/tree/main/www/"
    click Icons "https://github.com/pieterseinen/fantasy_leaflet/blob/main/fontawesome_icons.txt"
    click CSS "https://github.com/pieterseinen/fantasy_leaflet/blob/main/www/custom.css"

    %% Styles
    classDef client fill:#gray,stroke:#333,stroke-width:2px
    classDef external fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef asset fill:#FFA500,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Client Components"]:::client
        L2["External Libraries"]:::external
        L3["Core Components"]:::core
        L4["Static Assets"]:::asset
    end
```
