# spike04/friday-futsal architecture

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

- Interactive diagram: https://gitdiagram.com/spike04/friday-futsal
- Repository: https://github.com/spike04/friday-futsal

## Overview

##### Project type and purpose
- This is a full‑stack single‑page web application.
- Frontend: React + TypeScript + Vite + Tailwind CSS.
- Backend: json‑server serving db.json (REST API on port 3000).
- Purpose: generate, save, and share Friday Futsal match lineups (players, teams, match info).

##### File structure
- Top‑level:
– package.json, vite.config.ts, tsconfig*.json, tailwind.config.js, postcss.config.js → build & tooling.
– db.json + json‑server usage → simple REST backend.
– public/index.html, src/index.css → static assets.
- src:
– main.tsx, App.tsx → application entry point & root component.
– api.ts → abstraction over REST calls to json‑server.
– assets → logos or images.
– components/ui → atomic UI elements (Button, Input, Card, etc.).
– components → feature‑level UI (nav‑bar, player-item, team-item, match-info).
– pages → route‑driven components (home-page, match-generate-page).
– lib/utils.ts → shared utility functions.
– types → TypeScript type definitions.

##### README for additional insights
- Features: generate & share matches, CRUD operations on players, teams, match data, share via URL.
- Dev setup: run `json-server --watch db.json --port 3000`; run Vite via `npm run dev`.

a. Main components
1. Browser / Client
2. Vite Dev Server (serves the SPA, bundles code)
3. React SPA
– UI Layer (components/ui, components)
– Page/Route Layer (pages)
– API client (src/api.ts)
4. JSON‑Server REST API
5. db.json (persistent data store)
b. Relationships & interactions
- Browser sends HTTP GET/POST/PUT/DELETE to Vite Dev Server → serves index.html & JS bundle.
- React SPA renders UI, calls api.ts → issues AJAX calls to JSON‑Server endpoints (e.g., /players, /teams, /matches).
- JSON‑Server reads/writes db.json and returns JSON responses.
c. Architectural patterns & design principles
- Component‑based UI (atomic → feature → pages).
- Single Responsibility: api.ts abstracts HTTP calls; utils.ts has pure helpers.
- RESTful backend (json‑server as mock backend).
- Separation of concerns: build tooling isolated, static assets in public, type definitions centralized.
d. Key technologies/frameworks
- React + TypeScript + Vite + Tailwind CSS
- json‑server (mock REST API)
- PostCSS, ESLint, TSConfig

##### Detail without over‑splitting
- Just enough detail to convey how data flows and how modules depend on each other.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Entry
    Browser["Browser / Client"]:::frontend
    Vite["Vite Dev Server"]:::infra
    Browser -->|"GET index.html & bundle"| Vite
    Vite -->|"serves index.html & JS"| Browser

    %% SPA Bootstrap
    subgraph "SPA Bootstrap"
        direction TB
        Main["src/main.tsx"]:::frontend
        App["src/App.tsx"]:::frontend
    end
    Browser -->|"loads bundle"| Main
    Main -->|"mounts App"| App

    %% SPA Architecture
    subgraph "React SPA Architecture"
        direction TB

        subgraph "Routing Layer"
            direction TB
            Home["home-page.tsx"]:::frontend
            MatchGen["match-generate-page.tsx"]:::frontend
        end

        subgraph "Feature Components"
            direction TB
            NavBar["nav-bar.tsx"]:::frontend
            PlayerItem["player-item.tsx"]:::frontend
            PlayerItemMin["player-item-min.tsx"]:::frontend
            TeamItem["team-item.tsx"]:::frontend
            MatchInfo["match-info.tsx"]:::frontend
        end

        subgraph "UI Layer (Atomic)"
            direction TB
            Button["button.tsx"]:::frontend
            Input["input.tsx"]:::frontend
            Card["card.tsx"]:::frontend
            Alert["alert.tsx"]:::frontend
            Label["label.tsx"]:::frontend
            Separator["separator.tsx"]:::frontend
            Sonner["sonner.tsx"]:::frontend
        end

        CSS["src/index.css"]:::neutral
        ApiClient["src/api.ts"]:::neutral
        Utils["src/lib/utils.ts"]:::neutral
        Types["src/types/index.d.ts"]:::neutral

        App -->|"route to"| Home
        App -->|"route to"| MatchGen
        App -->|"imports styles"| CSS

        Home -->|"uses"| NavBar
        Home -->|"uses"| PlayerItem
        Home -->|"uses"| TeamItem

        MatchGen -->|"uses"| NavBar
        MatchGen -->|"uses"| PlayerItemMin
        MatchGen -->|"uses"| TeamItem
        MatchGen -->|"uses"| MatchInfo

        NavBar -->|"uses"| Button
        PlayerItem -->|"uses"| Card
        PlayerItemMin -->|"uses"| Card
        TeamItem -->|"uses"| Card
        MatchInfo -->|"uses"| Card

        FeatureComponents_and_UI --> ApiClient
        App -->|"calls"| ApiClient
        ApiClient -->|"calls REST endpoints"| BackendAPI

        NavBar -->|"calls util"| Utils
        PlayerItem -->|"calls util"| Utils
        Types -.-> Home
        Types -.-> MatchGen
    end

    %% Backend
    BackendAPI["json-server REST API"]:::backend
    DB["db.json"]:::db

    ApiClient -->|"GET/POST/PUT/DELETE /players,/teams,/matches"| BackendAPI
    BackendAPI -->|"reads/writes"| DB
    BackendAPI --> ApiClient

    %% Click Events
    click Browser "https://github.com/spike04/friday-futsal/blob/main/public/index.html"
    click Vite "https://github.com/spike04/friday-futsal/blob/main/vite.config.ts"
    click Main "https://github.com/spike04/friday-futsal/blob/main/src/main.tsx"
    click App "https://github.com/spike04/friday-futsal/blob/main/src/App.tsx"
    click ApiClient "https://github.com/spike04/friday-futsal/blob/main/src/api.ts"
    click Button "https://github.com/spike04/friday-futsal/blob/main/src/components/ui/button.tsx"
    click Input "https://github.com/spike04/friday-futsal/blob/main/src/components/ui/input.tsx"
    click Card "https://github.com/spike04/friday-futsal/blob/main/src/components/ui/card.tsx"
    click Alert "https://github.com/spike04/friday-futsal/blob/main/src/components/ui/alert.tsx"
    click Label "https://github.com/spike04/friday-futsal/blob/main/src/components/ui/label.tsx"
    click Separator "https://github.com/spike04/friday-futsal/blob/main/src/components/ui/separator.tsx"
    click Sonner "https://github.com/spike04/friday-futsal/blob/main/src/components/ui/sonner.tsx"
    click NavBar "https://github.com/spike04/friday-futsal/blob/main/src/components/nav-bar.tsx"
    click PlayerItem "https://github.com/spike04/friday-futsal/blob/main/src/components/player-item.tsx"
    click PlayerItemMin "https://github.com/spike04/friday-futsal/blob/main/src/components/player-item-min.tsx"
    click TeamItem "https://github.com/spike04/friday-futsal/blob/main/src/components/team-item.tsx"
    click MatchInfo "https://github.com/spike04/friday-futsal/blob/main/src/components/match-info.tsx"
    click Home "https://github.com/spike04/friday-futsal/blob/main/src/pages/home-page.tsx"
    click MatchGen "https://github.com/spike04/friday-futsal/blob/main/src/pages/match-generate-page.tsx"
    click Utils "https://github.com/spike04/friday-futsal/blob/main/src/lib/utils.ts"
    click Types "https://github.com/spike04/friday-futsal/blob/main/src/types/index.d.ts"
    click CSS "https://github.com/spike04/friday-futsal/blob/main/src/index.css"
    click DB "https://github.com/spike04/friday-futsal/blob/main/db.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#D5E8D4,stroke:#82B366,color:#82B366;
    classDef db fill:#E1D5E7,stroke:#9673A6,color:#9673A6;
    classDef infra fill:#FFE6CC,stroke:#D18B00,color:#D18B00;
    classDef neutral fill:#F2F2F2,stroke:#999,color:#333;
```
