# vidombax/ludoria architecture

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

- Interactive diagram: https://gitdiagram.com/vidombax/ludoria
- Repository: https://github.com/vidombax/ludoria

## Overview

##### Project type and purpose
- This is a full-stack web application composed of:
- A Vue 3 single-page frontend (built and served by Vite)
- A Node.js (Express-style) backend exposing RESTful endpoints
- Redis for caching/session storage
- A relational database accessed via db.js
- A file uploader service (likely to S3 or equivalent)

##### File structure
- Top-level:
- start.js (server bootstrap)
- db.js (database connection)
- redis.js (cache/session client)
- logger.js (centralized logging)
- index.html & vite.config.js (Vue/Vite entry)
- Backend directories:
- routes/main/*.route.js ⇒ maps HTTP paths to controllers
- middleware/auth.js ⇒ request authentication/authorization
- handlers/main/*/handler.js ⇒ per-resource business logic
- services/*.js ⇒ shared helpers, constants, file uploader
- Frontend under src/:
- main.js & App.vue ⇒ bootstraps Vue, router, Pinia stores
- pages/*.vue ⇒ route-level views (Index, Game, Login, User, etc.)
- components/… ⇒ reusable UI building blocks
- stores/*/store.js ⇒ state management (Pinia)
- api/*.js ⇒ wrappers around axios for HTTP calls

##### README
- Confirms Vue 3 + Vite setup

a. Main components
- Client Browser (Vue 3 SPA)
- Frontend build (Vite dev/production server)
- Backend API server (Node.js/Express)
- Authentication module (middleware/auth)
- Route layer (routes/main/*.route.js)
- Controller layer (handlers/main/*/handler.js)
- Service layer (services/helpers, constants, files_uploader)
- Data stores:
– Relational Database (Postgres/MySQL) accessed by db.js
– Redis cache/session via redis.js
- External service: File storage (S3 or similar)
b. Relationships & data flows
- Browser → HTTP(S) → Frontend dev server or static host → serves index.html + JS
- Vue components/pages → call API modules → send AJAX to Backend API
- Backend API incoming request → logger → auth middleware → matching route → handler
- Handler → invokes service utils → reads/writes DB and/or Redis → returns JSON
- File upload endpoints → service/files_uploader → external file storage
c. Architectural patterns & principles
- Layered architecture (routing → controllers/handlers → services → data stores)
- Separation of concerns:
– Frontend (UI, client state, API wrappers) vs. Backend (business logic, data access)
– Services encapsulate reusable logic (helpers, constants, file I/O)
– Middleware for cross-cutting concerns (auth, logging)
- Client-side state management (Pinia stores) and componentized UI
d. Key technologies/frameworks
- Frontend: Vue 3, Vite, Vue Router, Pinia
- Backend: Node.js, Express (or similar), Redis, Relational DB
- Utilities: Axios, custom logger, file uploader
- Dev ops: npm scripts, .env config, Vite config

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend SPA
    subgraph "Browser / Vue 3 SPA"
        direction TB
        Entry["Entry: src/main.js & src/App.vue"]:::frontend
        Router["Vue Router"]:::frontend
        subgraph "Pages"
            direction TB
            Index["Index.vue"]:::frontend
            Game["Game.vue"]:::frontend
            Login["Login.vue"]:::frontend
            User["User.vue"]:::frontend
            UserList["UserList.vue"]:::frontend
        end
        subgraph "Components"
            direction TB
            ComponentsAll["src/components/"]:::frontend
            ComponentsGame["src/components/game/"]:::frontend
            ComponentsUser["src/components/user/"]:::frontend
            ComponentsMain["src/components/main/"]:::frontend
            ComponentsSkeletons["src/components/skeletons/"]:::frontend
            ComponentsUserList["src/components/user_list/"]:::frontend
        end
        subgraph "Pinia Stores"
            direction TB
            StoreGame["game store (src/stores/game/store.js)"]:::frontend
            StoreUser["user store (src/stores/user/store.js)"]:::frontend
        end
        subgraph "API Clients"
            direction TB
            APIBase["api.js"]:::frontend
            APIGame["api_game.js"]:::frontend
            APIPost["api_post.js"]:::frontend
            APIUser["api_user.js"]:::frontend
        end

        Entry --> Router
        Router --> Index
        Router --> Game
        Router --> Login
        Router --> User
        Router --> UserList
        Router --> ComponentsAll
        ComponentsAll --> ComponentsGame
        ComponentsAll --> ComponentsUser
        ComponentsAll --> ComponentsMain
        ComponentsAll --> ComponentsSkeletons
        ComponentsAll --> ComponentsUserList
        Router --> StoreGame
        Router --> StoreUser
        StoreGame --> APIBase
        StoreUser --> APIBase
        APIBase --> APIGame
        APIBase --> APIPost
        APIBase --> APIUser
    end

    %% Backend API Server
    subgraph "Backend API Server"
        direction TB
        Server["start.js"]:::backend
        Logger["logger.js"]:::backend
        Auth["auth middleware (middleware/auth.js)"]:::middleware
        subgraph "Routes"
            direction TB
            RouteGame["game.route.js"]:::backend
            RoutePost["post.route.js"]:::backend
            RouteUser["user.route.js"]:::backend
        end
        subgraph "Handlers"
            direction TB
            HGame["game handler"]:::backend
            HPost["post handler"]:::backend
            HUser["user handler"]:::backend
            HDev["developer handler"]:::backend
            HGenre["genre handler"]:::backend
        end
        subgraph "Services"
            direction TB
            Const["constants.js"]:::service
            Helpers["helpers.js"]:::service
            FileUp["files_uploader.js"]:::service
        end

        Server --> Logger --> Auth --> RouteGame
        Auth --> RoutePost
        Auth --> RouteUser
        RouteGame --> HGame
        RoutePost --> HPost
        RouteUser --> HUser
        HGame --> Helpers
        HGame --> Const
        HGame --> FileUp
        HPost --> Helpers
        HPost --> Const
        HPost --> FileUp
        HUser --> Helpers
        HUser --> Const
        HUser --> FileUp
        HDev --> Helpers
        HDev --> Const
        HGenre --> Helpers
        HGenre --> Const
        FileUp -->|"uploads"| ExternalFS
    end

    %% Data Stores and External
    subgraph "Data Stores"
        direction TB
        DB["Relational DB (db.js)"]:::database
        Redis["Redis Cache/Session (redis.js)"]:::database
    end
    ExternalFS["File Storage (S3)"]:::external

    %% Connections between Backend and Data Stores
    Helpers --> DB
    Helpers --> Redis
    Const --> DB
    Const --> Redis

    %% HTTP Flow Between Frontend and Backend
    Router -.->|AJAX / HTTP| Server

    %% Click events
    click Entry "https://github.com/vidombax/ludoria/blob/master/src/main.js"
    click Entry "https://github.com/vidombax/ludoria/blob/master/src/App.vue"
    click Index "https://github.com/vidombax/ludoria/blob/master/src/pages/Index.vue"
    click Game "https://github.com/vidombax/ludoria/blob/master/src/pages/Game.vue"
    click Login "https://github.com/vidombax/ludoria/blob/master/src/pages/Login.vue"
    click User "https://github.com/vidombax/ludoria/blob/master/src/pages/User.vue"
    click UserList "https://github.com/vidombax/ludoria/blob/master/src/pages/UserList.vue"
    click ComponentsAll "https://github.com/vidombax/ludoria/tree/master/src/components/"
    click ComponentsGame "https://github.com/vidombax/ludoria/tree/master/src/components/game/"
    click ComponentsUser "https://github.com/vidombax/ludoria/tree/master/src/components/user/"
    click ComponentsMain "https://github.com/vidombax/ludoria/tree/master/src/components/main/"
    click ComponentsSkeletons "https://github.com/vidombax/ludoria/tree/master/src/components/skeletons/"
    click ComponentsUserList "https://github.com/vidombax/ludoria/tree/master/src/components/user_list/"
    click StoreGame "https://github.com/vidombax/ludoria/blob/master/src/stores/game/store.js"
    click StoreUser "https://github.com/vidombax/ludoria/blob/master/src/stores/user/store.js"
    click APIBase "https://github.com/vidombax/ludoria/blob/master/src/api/api.js"
    click APIGame "https://github.com/vidombax/ludoria/blob/master/src/api/api_game.js"
    click APIPost "https://github.com/vidombax/ludoria/blob/master/src/api/api_post.js"
    click APIUser "https://github.com/vidombax/ludoria/blob/master/src/api/api_user.js"
    click Server "https://github.com/vidombax/ludoria/blob/master/start.js"
    click DB "https://github.com/vidombax/ludoria/blob/master/db.js"
    click Redis "https://github.com/vidombax/ludoria/blob/master/redis.js"
    click Logger "https://github.com/vidombax/ludoria/blob/master/logger.js"
    click Auth "https://github.com/vidombax/ludoria/blob/master/middleware/auth.js"
    click RouteGame "https://github.com/vidombax/ludoria/blob/master/routes/main/game.route.js"
    click RoutePost "https://github.com/vidombax/ludoria/blob/master/routes/main/post.route.js"
    click RouteUser "https://github.com/vidombax/ludoria/blob/master/routes/main/user.route.js"
    click HGame "https://github.com/vidombax/ludoria/blob/master/handlers/main/game/handler.js"
    click HPost "https://github.com/vidombax/ludoria/blob/master/handlers/main/post/handler.js"
    click HUser "https://github.com/vidombax/ludoria/blob/master/handlers/main/user/handler.js"
    click HDev "https://github.com/vidombax/ludoria/blob/master/handlers/main/developer/handler.js"
    click HGenre "https://github.com/vidombax/ludoria/blob/master/handlers/main/genre/handler.js"
    click Const "https://github.com/vidombax/ludoria/blob/master/services/constants.js"
    click Helpers "https://github.com/vidombax/ludoria/blob/master/services/helpers.js"
    click FileUp "https://github.com/vidombax/ludoria/blob/master/services/files_uploader.js"

    %% Styles
    classDef frontend fill:#D6E9FE,stroke:#3A72C4,color:#000;
    classDef backend fill:#E2F7DA,stroke:#3C8D0D,color:#000;
    classDef middleware fill:#FFF4D6,stroke:#D08C00,color:#000;
    classDef service fill:#F3E2F3,stroke:#A34CA3,color:#000;
    classDef database fill:#FFF0E0,stroke:#D97706,color:#000;
    classDef external fill:#F0F0F0,stroke:#888888,color:#000;
```
