Skip to content

Latest commit

ย 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ GameStore API

A production-ready ASP.NET Core 9 Web API built with modern backend best practices, featuring JWT authentication, role- and policy-based authorization, and secure configuration management.


๐Ÿš€ Project Overview

GameStore API is a backend service for managing games and genres with secure access control.
It demonstrates real-world backend architecture, emphasizing scalability, maintainability, and security.
The API uses Entity Framework Core for data access, AutoMapper for DTO mapping, and Scalar for API exploration.


โœจ Key Features

๐Ÿ” Authentication & Authorization

  • JWT-based authentication
  • Access & refresh token implementation
  • Role-based authorization (Admin, User)
  • Policy-based authorization
  • Admin-only protected endpoints
  • Secure token validation and lifecycle management

๐Ÿ‘ค User Management

  • User registration
  • Login
  • Refresh token
  • Admin registration (accessible only by Admins)
  • Automatic first admin seeding on initial run (if no admin exists)

๐ŸŽฎ Game & Genre Management

  • Full CRUD operations for Games
  • Full CRUD operations for Genres
  • One-to-many relationship (Genre โ†’ Games)
  • Only authenticated users can Create and Update
  • Only Admin users can Delete

๐Ÿงฑ Architecture & Code Quality

  • Clean separation of concerns: Controllers โ†’ Interfaces โ†’ Services
  • Business logic and database access handled exclusively in services
  • Dedicated DTOs for requests and responses
  • AutoMapper for entity โ†” DTO mapping and update operations
  • Centralized global exception handling
  • Configuration logic extracted into extension methods

๐Ÿ› ๏ธ Tech Stack

  • .NET 9
  • ASP.NET Core Web API
  • Entity Framework Core
  • SQL Server
  • JWT Authentication
  • Policy-based Authorization
  • AutoMapper
  • Unit & Integration Testing (XUnit,Moq and FluentAssertion)
  • Scalar (used instead of Swagger)
  • User Secrets (for secure local development)

๐Ÿ—„๏ธ Database Design

  • Genre โ†’ Games (One-to-Many)
  • Code-first approach using Entity Framework Core
  • Automatic admin seeding during first application run

๐Ÿ”‘ Security Practices

  • Secrets never committed to source control
  • JWT Secret Key stored securely using User Secrets
  • Database connection string hidden
  • Environment-based configuration
  • Role and policy checks enforced at API level

โš™๏ธ Configuration

appsettings.json (Commit-safe)

{
  "Jwt": {
    "Issuer": "GameStoreApi",
    "Audience": "GameStoreClient",
    "AccessTokenExpirationMinutes": 15,
    "RefreshTokenExpirationDays": 7
  },
  "ConnectionStrings": {
    "GameStore": ""
  }
}

User Secrets (Development)

dotnet user-secrets init
dotnet user-secrets set "Jwt:SecretKey" "YOUR_SUPER_SECURE_SECRET_KEY"
dotnet user-secrets set "ConnectionStrings:GameStore" "YOUR_DB_CONNECTION_STRING"

โ–ถ๏ธ Running the Project

  1. Clone the repository

  2. Configure User Secrets

  3. Update the database (if migrations exist)

  4. Run the application

dotnet run

๐Ÿงช Testing

API Testing

  • Scalar UI is enabled for API exploration
  • JWT Bearer authentication supported
  • Role & policy restrictions enforced at endpoint level

Automated Testing

  • Unit Testing: Covers services using xUnit, Moq, and FluentAssertions (GameStore.Test).
  • Integration Testing: Uses WebApplicationFactory with an isolated in-memory SQLite database provider for end-to-end endpoint verification (GameStore.IntegrationTests).

๐Ÿ“‚ Project Structure

GameStore
โ”‚
โ”œโ”€โ”€ GameStore.Api                 # Main API Project
โ”‚   โ”œโ”€โ”€ Controllers
โ”‚   โ”œโ”€โ”€ Services
โ”‚   โ”œโ”€โ”€ Interfaces
โ”‚   โ”œโ”€โ”€ DTOs
โ”‚   โ”œโ”€โ”€ Entities
โ”‚   โ”œโ”€โ”€ Mappings
โ”‚   โ”œโ”€โ”€ Extensions
โ”‚   โ”œโ”€โ”€ Middleware
โ”‚   โ”œโ”€โ”€ Data
โ”‚   โ””โ”€โ”€ Program.cs
โ”‚
โ”œโ”€โ”€ GameStore.Test                # Unit Tests (xUnit, Moq)
โ””โ”€โ”€ GameStore.IntegrationTests    # Integration Tests (SQLite, WebApplicationFactory)

๐Ÿ“„ License

This project is for learning and demonstration purposes.

๐Ÿ™Œ Author

GameStore API

Built with โค๏ธ using ASP.NET Core 9

About

๐Ÿš€ A production-ready ASP.NET Core 9 Web API featuring JWT Auth, Role/Policy authorization, Clean Architecture, EF Core, and Scalar API documentation,Implemented Unit & Integration Testing..

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages