https://github.com/nemanja87/gameservice
A microservices architecture for a simple game built using .NET 8. This project features GameService, ComputerService, and ScoreboardService to handle game logic, computer choices, and scoreboard management respectively. Includes unit tests.
https://github.com/nemanja87/gameservice
csharp dotnet microservices-architecture polly
Last synced: about 1 year ago
JSON representation
A microservices architecture for a simple game built using .NET 8. This project features GameService, ComputerService, and ScoreboardService to handle game logic, computer choices, and scoreboard management respectively. Includes unit tests.
- Host: GitHub
- URL: https://github.com/nemanja87/gameservice
- Owner: nemanja87
- Created: 2024-10-19T10:04:33.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-24T06:57:12.000Z (over 1 year ago)
- Last Synced: 2025-03-30T17:23:41.638Z (over 1 year ago)
- Topics: csharp, dotnet, microservices-architecture, polly
- Language: C#
- Homepage:
- Size: 97.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SimpleGame Microservices
## Description
This repository contains three microservices for a simple game built using .NET. Each microservice performs a specific role in the system, and they communicate via HTTP.
### Microservices:
1. **GameService**: Handles the core game logic (e.g., Rock-Paper-Scissors) and interacts with the other services.
2. **ComputerService**: Provides the computer's choice in the game.
3. **ScoreboardService**: Manages the game results, keeping track of the last 10 games.
## Table of Contents
1. [Technologies Used](#technologies-used)
2. [Microservices](#microservices)
3. [Prerequisites](#prerequisites)
4. [Running the Project Locally](#running-the-project-locally)
5. [Testing](#testing)
6. [Contributing](#contributing)
7. [License](#license)
## Technologies Used
- **.NET 8**
- **MediatR** for CQRS implementation
- **Moq** for unit testing
- **Swagger** for API documentation
- **Docker** for containerization
- **xUnit** for unit tests
## Microservices
### GameService
The `GameService` is the core service that allows players to play the game by comparing their choice to the computer's choice. The game logic is implemented using `IGameLogicService`, and the service also interacts with `ComputerService` to get the computer's move and `ScoreboardService` to record the game result.
### ComputerService
The `ComputerService` randomly selects a game move (e.g., Rock, Paper, Scissors, etc.) for the computer. It provides this choice to the `GameService` whenever a game is played.
### ScoreboardService
The `ScoreboardService` manages the game results. It keeps track of the last 10 games and stores the results in memory (future work can include adding persistent storage).
## Prerequisites
- [.NET SDK 8](https://dotnet.microsoft.com/download/dotnet/8.0)
- [Docker](https://www.docker.com/) (if you plan to run the services inside containers)
## Running the Project Locally
### Step 1: Clone the Repository
``bash
git clone https://github.com/nemanja87/SimpleGame.git
cd SimpleGame
### Step 2: Solution setup
- Make sure that all three services are up and running with https option in Visual Studio.
- Adjust appSettings with the proper localhost values if needed.
- Use `GameService` and its `play` endpoint to initiate the game. (this service makes http calls to both `Computer` and `Scoreboard` services)
- Results of 10 last games should be visible when calling `last-results` endpoint of `ScoreboardService`