graph TD
A[Client Browser] -->|HTTP/HTTPS| B[Flask App]
A -->|WebSocket| S[Socket.IO]
B -->|Blueprints| R1[auth]
B --> R2[main]
B --> R3[dashboard]
B --> R4[dungeon_api]
B --> R5[seed_api]
B --> R6[config_api]
B -->|ORM| DB[(SQLite / SQLAlchemy)]
S --> B
subgraph Generation
G1[Dungeon Pipeline\n(seed -> grid)] --> G2[Door Repair & Invariants]
end
R4 -->|uses| G1
R4 -->|uses| G2
- Flask Blueprints: Modular route grouping (auth, main site, dashboard UI, dungeon APIs, seed management, config exposure).
- Socket.IO: Real-time events (lobby/gameplay expansion) sharing app context.
- Dungeon Generation: Deterministic multi-phase pipeline (see Dungeon Generation) producing cached
Dungeoninstances keyed by (seed,size). - Persistence:
DungeonInstancestores seed and player position; other models hold user & progression data. - Pre-Commit Tooling: Enforces frontend hygiene (no inline styles/scripts, cache-busting helper usage) to keep diffs clean.
- Client calls
/api/dungeon/seed(POST) to set or regenerate a seed. - Client retrieves
/api/dungeon/map. - Server loads or creates
DungeonInstance, fetches cachedDungeon, applies entrance relocation if needed. - Returns 2D grid + player position + seed.
- Client optionally calls
/api/dungeon/stateto populate description & exits before movement.
- Client posts
/api/dungeon/movewith direction. - Server validates walkable cell; updates
DungeonInstancecoordinates. - Returns new position, description, exits.
- Seed hashing (string -> first 8 bytes of SHA-256) ensures reproducibility.
- In-process cache stores recent Dungeon objects (LRU-ish manual cap) minimizing regeneration cost.
- Feature Assignment Phase can inject encounter hooks, loot tables, biome theming.
- Socket.IO channels for party chat, combat events, live admin monitoring.
- Additional blueprints for stats, leaderboards, content authoring.
- Login required for all dungeon/seed routes.
- Future: rate-limit movement, sanitize user-generated content, add CSRF tokens for form endpoints.
See docs/DEVELOPMENT.md and docs/DUNGEON_GENERATION.md for invariant coverage (door rules, seed persistence) and regeneration determinism.