A full-stack web application for browsing and rating video games, built with Blazor WebAssembly, ASP.NET Core Web API, and MySQL. The solution follows a clean three-project architecture: a shared class library, a REST API backend, and a Blazor frontend client.
- Overview
- Tech Stack
- Architecture
- Project Structure
- Getting Started
- Docker
- API Overview
- Contributing
- License
GameRatingApp allows users to browse a catalog of games and submit ratings. The frontend is a Blazor WebAssembly SPA communicating with a RESTful ASP.NET Core API, which reads and writes to a MySQL database. Shared data models and DTOs live in a separate ClassLibrary project referenced by both the API and the client.
| Layer | Technology |
|---|---|
| Frontend | Blazor WebAssembly (.NET) |
| Backend | ASP.NET Core Web API (.NET) |
| Database | MySQL |
| Shared Models | C# Class Library |
| Containerization | Docker |
| IDE | Visual Studio 2022 |
┌─────────────────────┐ HTTP/REST ┌──────────────────────┐
│ MyBlazorClient │ ──────────────────────► │ DatabaseApi │
│ (Blazor WASM SPA) │ ◄────────────────────── │ (ASP.NET Core API) │
└─────────────────────┘ JSON responses └──────────┬───────────┘
│ │
└──────────────┐ ┌───────────┘
▼ ▼
┌─────────────────────────────┐
│ ClassLibrary │
│ (Shared Models & DTOs) │
└──────────────┬──────────────┘
│
▼
┌───────────────┐
│ MySQL │
│ Database │
└───────────────┘
GameRatingApp/
├── MyBlazorClient/ # Blazor WebAssembly frontend
│ ├── Pages/ # Razor pages & components
│ ├── wwwroot/ # Static assets
│ └── MyBlazorClient.csproj
│
├── DatabaseApi/ # ASP.NET Core REST API
│ ├── Controllers/ # API controllers
│ ├── Services/ # Business logic / data access
│ ├── Dockerfile # Container definition for the API
│ └── DatabaseApi.csproj
│
├── ClassLibrary/ # Shared models and DTOs
│ └── ClassLibrary.csproj
│
├── MyBlazorClient.sln # Visual Studio solution file
├── .gitignore
└── .gitattributes
- .NET SDK 8.0+
- MySQL Server 8.0+
- Visual Studio 2022 or VS Code with C# extension
- (Optional) Docker for containerized deployment
- Create a MySQL database:
CREATE DATABASE GameRatingDb;- Update the connection string in
DatabaseApi/appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=GameRatingDb;User=root;Password=yourpassword;"
}
}- Apply any migrations or seed scripts located in the
DatabaseApiproject:
cd DatabaseApi
dotnet ef database updatecd DatabaseApi
dotnet runThe API will start at https://localhost:7XXX (check your terminal output for the exact port).
Open a new terminal:
cd MyBlazorClient
dotnet runThen open your browser and navigate to https://localhost:5XXX. The client will connect to the API automatically.
Tip: You can also open
MyBlazorClient.slnin Visual Studio 2022 and run both projects simultaneously using the Multiple Startup Projects setting.
The DatabaseApi project includes a Dockerfile for containerized deployment.
cd DatabaseApi
docker build -t gameratingapp-api .
docker run -p 8080:80 \
-e ConnectionStrings__DefaultConnection="Server=host.docker.internal;Database=GameRatingDb;User=root;Password=yourpassword;" \
gameratingapp-apiMake sure your MySQL server is accessible from within the container. Use
host.docker.internalto reach the host machine's MySQL from Docker on Windows/macOS, or172.17.0.1on Linux.
The DatabaseApi exposes a RESTful API consumed by the Blazor client. Typical endpoints include:
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/games |
Get all games |
GET |
/api/games/{id} |
Get a game by ID |
POST |
/api/games |
Add a new game |
POST |
/api/ratings |
Submit a rating for a game |
GET |
/api/ratings/{gameId} |
Get ratings for a game |
These are inferred from the project structure. Verify against the actual controller files for exact routes.
Contributions are welcome!
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m "Add your feature" - Push to the branch:
git push origin feature/your-feature - Open a Pull Request
This project does not currently specify a license. Please contact the author before using or distributing this work.
Built with ❤️ using Blazor, ASP.NET Core, and MySQL.