Entry point & application
| File / path | Responsibility |
|---|---|
src/index.ts |
Minimal entry point; passes the application to Colyseus
listen().
|
src/app.config.ts |
Creates GameApplication and exports the server
definition.
|
src/app/GameApplication.ts |
Composition root for all modules, including startup and shutdown. |
src/app/GameRuntime.ts |
Builds map-dependent worlds once and enforces readiness. |
src/app/config/ServerConfig.ts |
Assembles typed server configuration from the environment. |
src/app/logging/AppLogger.ts |
Pino adapter, child loggers, and Express request logging. |
Core & game
| File / path | Responsibility |
|---|---|
src/core/GameLoop.ts |
Delegates each tick to all registered systems. |
src/core/SystemRegister.ts |
Stores and executes ISystem implementations in
registration order.
|
src/core/RommHandlerRegister.ts |
Stores and binds room message handlers. |
src/core/RoomRuntimeBuilder.ts |
Composition root for an individual room and its gameplay features. |
src/core/EventBus.ts |
Inactive local event-bus sketch; not part of the runtime. |
src/game/GameModule.ts |
Assembles GameRuntime and the map repository.
|
src/game/world/GameWorld.ts |
Container for dependencies belonging to a particular map. |
src/game/maps/FileMapRepository.ts |
Asynchronous map reading, validation, and memoization by
mapId.
|
RommHandlerRegister.ts contains a
historical typo, but its imports are consistent. Renaming it can be
handled in a separate refactor.
Rooms & Colyseus transport
| File / path | Responsibility |
|---|---|
src/rooms/GameRoom.ts |
Room lifecycle: create, auth, join, leave, and dispose. |
src/rooms/types.ts |
Auth/join options schema and color enum. |
src/rooms/RoomPlayerEatenNotifier.ts |
Sends the player-eaten event to the two affected clients. |
src/rooms/handlers/MoveHandler.ts |
Validates and buffers input after local rate limiting. |
src/rooms/handlers/ChatHandler.ts |
Validates, rate-limits, and broadcasts chat. |
src/rooms/handlers/ShootHandler.ts |
Disabled sketch; not registered. |
src/transport/colyseus/ColyseusModule.ts |
Declares the my_room room. |
src/transport/colyseus/createConfiguredGameRoom.ts
|
Injects dependencies before onCreate(). |
src/transport/colyseus/ColyseusRedisModule.ts
|
Creates Redis Presence and Driver for Colyseus. |
Movement, collision & player systems
| File / path | Responsibility |
|---|---|
features/movement/MovementInput.ts |
Consumes new sequences from the input buffer. |
features/movement/FreeMovementSystem.ts |
Continuous movement, normalization, and wall sliding. |
features/movement/GridMovementSystem.ts |
Step-based grid movement with path validation. |
features/collision/ColliderGeometry.ts |
Pure collider-geometry functions. |
features/collision/CollisionSpatialIndex.ts
|
Spatial buckets for map obstacles. |
features/collision/MapCollisionWorld.ts |
Bounds, occupancy, and traversal. |
features/collision/SpawnPositionFinder.ts
|
Safe spawn for free/grid movement. |
features/player/PlayerFactory.ts |
Creates players and selects spawn positions. |
features/player/PlayerColliderResolver.ts
|
Calculates a collider from player mass. |
features/player/PlayerPositionGuardSystem.ts
|
Restores the last legal position. |
features/player/NicknamePolicy.ts |
Nickname normalization and rules. |
Collectibles & player eating
| File / path | Responsibility |
|---|---|
features/collectibles/CollectiblesFeature.ts
|
Assembles the seed spawner and collection system. |
features/collectibles/SeedSpawner.ts |
Creates initial and replacement seeds. |
features/collectibles/SeedCollectionSystem.ts
|
Detects collection and applies safe growth. |
features/player-eating/PlayerEatingFeature.ts
|
Assembles the eating system and room notifier. |
features/player-eating/PlayerEatingSystem.ts
|
Validates mass difference, collision, growth, and respawn. |
features/tick/TimeSyncSystem.ts |
Periodically broadcasts tick and time. |
features/chat/ChatMessagePolicy.ts |
Chat normalization and length limit. |
Rate limiting & health
| File / path | Responsibility |
|---|---|
features/rate-limit/RateLimitModule.ts |
Assembles the store, service, and middleware. |
features/rate-limit/RateLimitService.ts |
Hashes identities and issues rate-limit decisions. |
features/rate-limit/SlidingWindowRateLimiter.ts
|
Local sliding window for realtime clients. |
data-access/rate-limit/RateLimitStore.ts |
Port for the shared counter. |
data-access/rate-limit/RedisRateLimitStore.ts
|
Atomic Redis Lua counter. |
features/health/HealthCheck.ts |
Shared check/readiness contracts. |
features/health/HealthModule.ts |
Assembles all health checks. |
features/health/HealthService.ts |
Aggregates readiness reports concurrently. |
features/health/GameRuntimeHealthCheck.ts
|
Checks whether the world has loaded. |
data-access/health/PostgresHealthQuery.ts
|
Executes SELECT 1. |
data-access/health/RedisHealthQuery.ts |
Executes PING. |
data-access/health/RabbitMqHealthCheck.ts
|
Reads RabbitMQ readiness. |
Data-access ports
| File / path | Responsibility |
|---|---|
data-access/SqlQueryExecutor.ts |
Minimal port for typed SQL queries. |
data-access/RedisCommandExecutor.ts |
Minimal port for Redis commands. |
data-access/EventPublisher.ts |
Port for publishing a versioned event envelope. |
Infrastructure
| File / path | Responsibility |
|---|---|
infrastructure/InfrastructureModule.ts |
Shared lifecycle and public infrastructure ports. |
infrastructure/database/PostgresDataSource.ts
|
Singleton connection pool, queries, transactions, and reconnect. |
infrastructure/redis/RedisClientFactory.ts
|
Consistent options for Redis clients. |
infrastructure/redis/RedisDataSource.ts |
Singleton application Redis and its lifecycle. |
infrastructure/rabbitmq/RabbitModule.ts |
RabbitMQ facade and public EventPublisher.
|
infrastructure/rabbitmq/RabbitMqDataSource.ts
|
AMQP connection/channel, topology, confirms, and reconnect. |
infrastructure/rabbitmq/RabbitEventPublisher.ts
|
Validates and serializes an event envelope. |
HTTP
| File / path | Responsibility |
|---|---|
transport/http/HttpModule.ts |
Configures proxy trust, middleware, and routers. |
transport/http/HttpRateLimitMiddleware.ts
|
Limits HTTP requests and exposes response headers. |
transport/http/HealthRouter.ts |
Exposes GET /api/health. |
Schema, messages & configuration
| File / path | Responsibility |
|---|---|
schema/State.ts |
Root of synchronized state. |
schema/Player.ts |
Synchronized and server-side player state. |
schema/Seed.ts |
Synchronized seed position. |
shared/messages/* |
Message names, Zod input schemas, and response types. |
shared/configs/GameConfig.ts |
Environment-dependent gameplay configuration. |
shared/configs/*Config.ts |
Validated configuration for services and rate limiting. |
shared/configs/ClientGameConfig.ts |
Client-safe subset of the configuration. |
shared/validation/ServerMapSchema.ts |
Runtime schema of a compiled map. |
shared/types/* |
Types for geometry, maps, colliders, grids, and movement. |
Files outside the server
| File / path | Responsibility |
|---|---|
map-compiler/scripts/compile-map.ts |
Validates Tiled and generates server-map JSON. |
map-compiler/tiled-source/map.json |
Editable map source. |
Dockerfile |
Builder, map compiler, development server, and production server. |
docker-compose.yml |
Local environment for all services. |
nginx/nginx.conf |
HTTP/WebSocket reverse proxy. |
.env.example |
Catalog of environment variables. |
pg/migrations/init.sql |
Initial SQL schema sketch. |
Tests
The server/test directory contains behavioral tests for
the systems listed above. Each filename identifies a regression
boundary; examples include grid-movement.test.ts,
player-eating.test.ts,
server-config.test.ts, and
rabbit-event-publisher.test.ts.
helpers.ts provides only small fixtures for maps,
state, and input.