# imadeusf/jeux-bingo architecture

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

- Interactive diagram: https://gitdiagram.com/imadeusf/jeux-bingo
- Repository: https://github.com/imadeusf/jeux-bingo

## Overview

##### Project type and purpose
- This is a full‑stack web application built with Next.js (App Router) that hosts an online bingo game.

##### File structure
- Top‑level:
- prisma/ → database schema (schema.prisma) and migration scripts
- public/ → static assets (images, 90+ sound files)
- src/app/ → Next.js pages & server components (game, logs, API routes)
- src/components/, src/context/, src/hooks/ → React client components, context providers, custom hooks
- Configuration: next.config.ts, tsconfig.json, eslint.config.mjs
- API layer: src/app/api/logs/route.ts – Next.js Route Handler for logging draws
- Front‑end styling & logic: TypeScript + styled‑components + SCSS + React Context + hooks

##### README for additional insights
- Frontend: Next.js, TypeScript, styled‑components, SCSS, HTML5
- Backend: Neon (PostgreSQL), Prisma ORM, deployed on Vercel

a. Main components
1. Client Browser (UI)
2. Next.js Application
- Server Components (SSR/SSG)
- Client Components (GameBody, GameHeader, GameFooter, Button, etc.)
- React Context (GameContext) + Custom Hooks (useGameStart, useGameLogs)
3. Static Asset Server (public/images, public/sounds)
4. API Layer (/api/logs)
5. Prisma Client
6. Database (PostgreSQL on Neon)
7. Hosting Platforms (Vercel for Next.js, Neon for DB)

b. Relationships and interactions
- UI requests static sound file → served from public/sounds via Next.js static server
- If logging enabled → Client → POST /api/logs → Next.js Route Handler → Prisma Client → writes to Postgres
- Logs page (src/app/logs/page.tsx) → SSR fetch GET /api/logs → displays history
- Prisma migrations manage schema changes, run at deployment via Vercel hooks

c. Architectural patterns
- Next.js App Router with server+client components
- React Context for state management
- Custom hooks for encapsulating business logic
- API routes as thin controllers
- ORM (Prisma) as model layer
- Static assets served via Next.js “public” directory

d. Key technologies & libraries
- Next.js 13 (App Router)
- React + TypeScript
- styled‑components + SCSS
- Prisma ORM (schema.prisma + migrations)
- PostgreSQL (Neon)
- Vercel (hosting CI/CD)

##### Diagramming recommendations
- user actions → React Context → API calls
- API calls → DB operations
- asset requests → static server
- Frontend (blue)
- API/Server (green)
- Database (orange)
- Static Assets (gray)
- Rectangles for services/modules
- Clouds for hosting platforms

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser/UI Layer
    subgraph "Browser/UI Layer"
        Browser["Client Browser"]:::frontend
    end

    %% Next.js Application on Vercel
    subgraph "Next.js Application (Hosted on Vercel)"
        subgraph "Server Components & Routing"
            Layout["layout.tsx"]:::serverComp
            Page["page.tsx"]:::serverComp
            NotFound["not-found.tsx"]:::serverComp
            GamePage["game/page.tsx"]:::serverComp
            LogsPage["logs/page.tsx"]:::serverComp
        end
        subgraph "Client Components"
            GameHeader["GameHeader.tsx"]:::frontend
            GameBody["GameBody.tsx"]:::frontend
            GameFooter["GameFooter.tsx"]:::frontend
            Button["Button.tsx"]:::frontend
        end
        Context["GameContext.tsx"]:::state
        HooksStart["useGameStart.tsx"]:::state
        HooksLogs["useGameLogs.tsx"]:::state
        ApiLogs["/api/logs Route Handler"]:::api
    end

    %% ORM & Database Layer on Neon
    subgraph "ORM & Database"
        Prisma["Prisma Client"]:::server
        DB["PostgreSQL Database"]:::db
    end

    %% Static Assets
    subgraph "Static Asset Server"
        Images["public/images"]:::static
        Sounds["public/sounds"]:::static
    end

    %% Configuration & Tooling
    subgraph "Configuration & Tooling"
        NextConfig["next.config.ts"]:::config
        TSConfig["tsconfig.json"]:::config
        ESLint["eslint.config.mjs"]:::config
    end

    %% Hosting Platforms
    subgraph "Hosting Platforms"
        Vercel["Vercel"]:::cloud
        Neon["Neon"]:::cloud
    end

    %% Data Flows
    Browser -->|renders| GameHeader
    Browser -->|renders| GameBody
    Browser -->|renders| GameFooter
    GameBody -->|onClick Draw| HooksStart
    HooksStart -->|updates| Context
    GameBody -->|uses context| Context
    Context -->|provides state| GameBody
    GameFooter -->|uses logs| HooksLogs
    HooksLogs -->|POST JSON| ApiLogs
    LogsPage -->|GET JSON| ApiLogs
    ApiLogs -->|executes queries| Prisma
    Prisma -->|reads/writes| DB
    GameBody -->|fetches audio| Sounds
    GameBody -->|fetches images| Images

    %% Deployment Relationships
    Layout -->|deployed on| Vercel
    Prisma -->|connects to| Neon
    DB -->|hosted on| Neon

    %% Click Events
    click Layout "https://github.com/imadeusf/jeux-bingo/blob/main/src/app/layout.tsx"
    click Page "https://github.com/imadeusf/jeux-bingo/blob/main/src/app/page.tsx"
    click NotFound "https://github.com/imadeusf/jeux-bingo/blob/main/src/app/not-found.tsx"
    click GamePage "https://github.com/imadeusf/jeux-bingo/blob/main/src/app/game/page.tsx"
    click LogsPage "https://github.com/imadeusf/jeux-bingo/blob/main/src/app/logs/page.tsx"
    click GameHeader "https://github.com/imadeusf/jeux-bingo/blob/main/src/app/game/GameHeader.tsx"
    click GameBody "https://github.com/imadeusf/jeux-bingo/blob/main/src/app/game/GameBody.tsx"
    click GameFooter "https://github.com/imadeusf/jeux-bingo/blob/main/src/app/game/GameFooter.tsx"
    click Button "https://github.com/imadeusf/jeux-bingo/blob/main/src/components/Button.tsx"
    click Context "https://github.com/imadeusf/jeux-bingo/blob/main/src/context/GameContext.tsx"
    click HooksStart "https://github.com/imadeusf/jeux-bingo/blob/main/src/hooks/useGameStart.tsx"
    click HooksLogs "https://github.com/imadeusf/jeux-bingo/blob/main/src/hooks/useGameLogs.tsx"
    click ApiLogs "https://github.com/imadeusf/jeux-bingo/blob/main/src/app/api/logs/route.ts"
    click Images "https://github.com/imadeusf/jeux-bingo/tree/main/public/images/"
    click Sounds "https://github.com/imadeusf/jeux-bingo/tree/main/public/sounds/"
    click Prisma "https://github.com/imadeusf/jeux-bingo/blob/main/prisma/schema.prisma"
    click DB "https://github.com/imadeusf/jeux-bingo/blob/main/prisma/migrations/20250320102431_init/migration.sql"
    click DB "https://github.com/imadeusf/jeux-bingo/blob/main/prisma/migrations/20250320103159_init/migration.sql"
    click DB "https://github.com/imadeusf/jeux-bingo/blob/main/prisma/migrations/20250320103300_init/migration.sql"
    click DB "https://github.com/imadeusf/jeux-bingo/blob/main/prisma/migrations/migration_lock.toml"
    click NextConfig "https://github.com/imadeusf/jeux-bingo/blob/main/next.config.ts"
    click TSConfig "https://github.com/imadeusf/jeux-bingo/blob/main/tsconfig.json"
    click ESLint "https://github.com/imadeusf/jeux-bingo/blob/main/eslint.config.mjs"

    %% Styles
    classDef frontend fill:#DAE8FC,stroke:#6C8EBF,color:#1A1A1A
    classDef serverComp fill:#E1D5E7,stroke:#9673A6,color:#1A1A1A
    classDef state fill:#F8CECC,stroke:#B85450,color:#1A1A1A
    classDef api fill:#D5E8D4,stroke:#82B366,color:#1A1A1A
    classDef server fill:#FFF2CC,stroke:#D6B656,color:#1A1A1A
    classDef db fill:#F5F0C6,stroke:#E2DDA6,color:#1A1A1A
    classDef static fill:#E8E8E8,stroke:#BFBFBF,color:#1A1A1A
    classDef config fill:#FFF7E6,stroke:#E3C07C,color:#1A1A1A
    classDef cloud fill:#E1F5FE,stroke:#81D4FA,color:#1A1A1A
```
