# skearya/wordplay architecture

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

- Interactive diagram: https://gitdiagram.com/skearya/wordplay
- Repository: https://github.com/skearya/wordplay

## Overview

##### Project type and purpose
- This is a full-stack multiplayer word-games platform (“wordplay”) with a SolidJS/TypeScript single-page frontend and a Rust/axum backend. It supports real-time game interactions (via WebSocket), REST endpoints (e.g. auth, info), persistent storage (SQL), and offline prompt generation.

##### File structure
- Top-level:
- compose.yml, Caddyfile, Dockerfiles – indicates Docker Compose deployment with a reverse proxy (Caddy).
- client/ – SolidJS app built with Vite and Tailwind.
- server/ – Rust service using axum, SQLx (migrations, query files), organizes code into routes, state, utils.
- prompt-gen/ – Rust binary to generate “word bomb” prompts offline.
- stresser/ – TS script to load-test the server via its APIs/WebSockets.
- Key patterns:
- client/src/lib/components – reusable UI, pages, routing.
- server/src/routes + server/src/state – MVC-like separation (handlers vs. in-memory/game state).
- migrations/ + .sqlx – schema & compile-time SQL validation.

##### README for additional insights
- Features: chat, rate limiting, spectating, game rejoining.
- Tech stack summary: SolidJS, Vite, Rust, axum, Docker Compose.
- prompt-gen is a supporting tool, not in hot path.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Client
    Browser["SolidJS SPA"]:::frontend
    click Browser "https://github.com/skearya/wordplay/tree/main/client/"

    %% Deployment Layer
    subgraph "Docker Compose Deployment"
        direction TB
        Compose["Docker Compose"]:::infra
        click Compose "https://github.com/skearya/wordplay/blob/main/compose.yml"
        Caddy["Caddy Reverse Proxy"]:::infra
        click Caddy "https://github.com/skearya/wordplay/tree/main/Caddyfile"
        ServerApp["axum API + WS Server"]:::backend
        click ServerApp "https://github.com/skearya/wordplay/blob/main/server/src/main.rs"
        DB["PostgreSQL"]:::db
    end

    %% Supporting Services
    PromptGen["Prompt-Gen Offline Service"]:::tool
    click PromptGen "https://github.com/skearya/wordplay/blob/main/prompt-gen/src/main.rs"
    StaticPrompts["Static Prompts File"]:::backend
    click StaticPrompts "https://github.com/skearya/wordplay/blob/main/server/src/static/prompts.txt"
    Stresser["Load-Test Script"]:::tool
    click Stresser "https://github.com/skearya/wordplay/blob/main/stresser/index.ts"

    %% Server Internal Modules
    subgraph "Server Code" 
        direction TB
        Routes["Routes Handlers"]:::backend
        click Routes "https://github.com/skearya/wordplay/blob/main/server/src/routes.rs"
        State["In-Memory Game State"]:::backend
        click State "https://github.com/skearya/wordplay/tree/main/server/src/state/"
        Migrations["DB Migrations"]:::db
        click Migrations "https://github.com/skearya/wordplay/tree/main/server/migrations/"
    end

    %% Data Flow
    Browser -->|"HTTPS (REST & WS)"| Caddy
    Stresser -->|"HTTP/WS Load Testing"| Caddy
    Caddy -->|"Proxy /api/*"| ServerApp
    Caddy -->|"Proxy /ws"| ServerApp
    Caddy -->|"Serve Static Files"| Browser
    ServerApp -->|"SQL Queries"| DB
    ServerApp -->|"WS Save Events"| DB
    PromptGen -->|"Generate Prompts"| StaticPrompts

    %% Internal Links
    ServerApp --> Routes
    ServerApp --> State
    ServerApp --> Migrations

    %% Styles
    classDef frontend fill:#88CCFF,stroke:#333,stroke-width:1px
    classDef backend fill:#AAFFAA,stroke:#333,stroke-width:1px
    classDef infra fill:#FFCC88,stroke:#333,stroke-width:1px
    classDef db fill:#FF8888,stroke:#333,stroke-width:1px
    classDef tool fill:#FFAAFF,stroke:#333,stroke-width:1px
```
