How mrbogdan/monopoly works
Project Type and Purpose
• The README confirms that this is an online Monopoly game. The project is a full-stack application, with a clear separation between the client (frontend) and the service (backend/game engine).
• The purpose is to run an online version of Monopoly, managing game state, player actions, and possibly real-time interactions.
File Structure
• Two main directories:
• The “client” folder: Contains JavaScript, HTML, and CSS resources. Likely responsible for rendering the game interface (e.g., map-playground.html) and interacting with the backend via APIs or WebSockets.
• The “service” folder: Implements the backend logic in TypeScript. This folder includes modules for:
▪ Game Logic: Components inside “src/game”, “src/action”, “src/tile”, and “src/tiles” that define how the game works, player actions, and board tiles (including specialized files for different types of tiles like Airlines, Cars, Restaurants, etc.).
▪ User Management: Found in “src/user” with repositories and services emphasizing user configuration and persistence (using a Postgres repository).
▪ HTTP Server: Modules under “src/http” and “src/decorators” which set up routes, controllers, and related middleware for REST API endpoints (e.g., HealthController.ts, UserPublicController.ts).
▪ WebSocket Server: Located in “src/wss”, indicating support for real-time communications.
▪ Dependency Injection (DI) and Error Handling: Seen in directories “src/di” and “src/errors” to manage service configurations and fault handling.
▪ Database Migrations: Files under “src/migrations” that handle schema changes (e.g., create-user-table.sql).
• Additional files:
• Docker-related files (e.g., docker-compose.yml, Dockerfiles) indicate containerization for deployment.
• Configuration files for linting, testing (Jest), and build scripts give insight into quality control and CI/CD processes.
• An extensive “docs” folder provides guidelines on collaboration, diagramming, and project-specific documentation.
• Components to include:
• Client (Frontend): A browser-based interface built using HTML/CSS/JS. It likely interacts via HTTP REST endpoints and/or WebSockets.
• Service (Backend): A NodeJS/TypeScript application subdivided into several layers:
▪ API Layer: HTTP server components, controllers, and route handlers (REST endpoints).
▪ WebSocket Layer: For real-time communication.
▪ Business Logic Layer: Game mechanics (game logic, action processing, tile management, bank operations) and user services.
▪ Data Access Layer: Repositories (like PostgresUserRepository) and migration management, interacting with a PostgreSQL database.
▪ Dependency Injection and Error Handling: Framework-level support for managing modules (using decorators, DI container) and managing protocol vs. business errors.
• External Services/Infrastructure:
▪ Database: Though not explicitly depicted as a folder, the use of a Postgres client and migrations indicate a PostgreSQL instance.
▪ Docker/Deployment: Container architecture using docker-compose pulls in both client and service components.
• Relationships:
• The Client calls backend REST APIs and WebSocket endpoints.
• The Backend routes the requests to the game logic and user management modules.
• The backend communicates with a database for persistent storage.
• CI/CD workflows (shown in .github/workflows) provide integration testing and code quality, though these are typically abstracted from the runtime architecture.
Architectural Patterns and Design Principles
• The project structure encourages separation of concerns: separating HTTP handling from game logic and data access.