REST API for GameNest — a web application for browsing a video game catalog and managing your personal game library.
- Frontend (Cloudflare): https://gamenest.pp.ua — repository GameNest_FrontEnd
- API (Render, planned):
https://api.gamenest.pp.ua
- Google sign-in / sign-up (Google ID token → GameNest JWT) — the public flow for the MVP
- Email/password registration with email confirmation (kept in the code, off by default in production)
- JWT authentication (HS256, configurable lifetime, 30 days by default) and BCrypt password hashing
- Role-based authorization (
User,Admin); the role is re-read from the database on every request, so promotions apply immediately - Game catalog, game titles and versions
- Personal library (status, purchased flag) and user-created games
- Game submissions with admin moderation (approve, reject, edit pending)
- User profile and privacy settings
- Rate limiting on authentication endpoints
- Health check endpoint; Swagger UI in Development
| Area | Technology |
|---|---|
| Framework | C# / ASP.NET Core Web API, .NET 10 |
| Database | PostgreSQL via Entity Framework Core 10 + Npgsql |
| Auth | JWT Bearer, BCrypt.Net-Next, Google.Apis.Auth |
Resend REST API (plain HttpClient, no SDK) |
|
| API docs | Swagger / OpenAPI (Swashbuckle) |
| Tests | xUnit, in-memory SQLite |
| Deployment | Docker (multi-stage), Render, Neon |
Requirements: .NET SDK 10, PostgreSQL, and the EF tool (dotnet tool install --global dotnet-ef).
# 1. Clone
git clone https://github.com/GameNestProject/GameNest_BackEnd.git
cd GameNest_BackEnd
# 2. Create an empty database
psql -U postgres -c "CREATE DATABASE gamenest;"# 3. Store secrets with User Secrets (PowerShell). Every developer generates their own JWT key.
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Host=localhost;Port=5432;Database=gamenest;Username=<user>;Password=<password>"
$bytes = New-Object byte[] 64
[System.Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes)
dotnet user-secrets set "Jwt:Key" ([Convert]::ToBase64String($bytes))
Remove-Variable bytes# 4. Apply migrations and run
dotnet ef database update
dotnet run --launch-profile http- API: http://localhost:5096
- Swagger UI: http://localhost:5096/swagger (Development only)
- CORS in Development allows
http://localhost:3000. For another frontend port setCORS_ALLOWED_ORIGINS, e.g.$env:CORS_ALLOWED_ORIGINS="http://localhost:5173".
In Development, email/password registration is enabled and confirmation links are printed to the console, so you can try the API without Google or Resend. Google sign-in needs a real
Google__ClientId— see Authentication.
The tests use an isolated in-memory SQLite database and never connect to PostgreSQL:
dotnet test ./Tests/GameNest_BackEnd.Tests.csprojA few PostgreSQL-specific concurrency tests are opt-in and reported as skipped by default. To run them, set GAMENEST_TEST_POSTGRES to a connection string of a server where the tests may create (and drop) databases, e.g. Host=localhost;Port=5432;Username=postgres;Password=.... Never point it at production.
Interactive documentation is available in Swagger UI when running in Development. Protected endpoints expect Authorization: Bearer <GameNest JWT>.
| Area | Endpoint | Access |
|---|---|---|
| Health | GET /api/health |
public |
| Auth | POST /api/Auth/google |
public (rate limited) |
POST /api/Auth/google/link |
signed in (rate limited) | |
POST /api/Auth/login, /register, /resend-confirmation, /confirm-email |
public; login and registration are off by default in production | |
| Catalog | GET /api/Games, GET /api/Games/{id} |
public |
GET /api/GameTitles/{id}/versions |
public | |
POST /api/Games, PUT /api/Games/{id}, DELETE /api/Games/{id} (archives) |
Admin | |
| Library | GET /api/Library, POST/PUT/DELETE /api/Library/{gameId} |
signed in |
| My games | GET/POST /api/UserGames, GET/PUT/DELETE /api/UserGames/{id} |
signed in (own records only) |
| Profile | GET/PUT /api/Profile |
signed in |
GET /api/Profile/{username} |
public (only if the profile is public) | |
GET/PUT /api/Profile/privacy |
signed in | |
| Submissions | POST /api/Submissions, GET /api/Submissions/mine, GET /api/Submissions/{id}, PUT/DELETE /api/Submissions/{id} |
signed in (own pending submissions) |
GET /api/Submissions, PUT /api/Submissions/{id}/approve, PUT /api/Submissions/{id}/reject |
Admin |
Library statuses: Planned, Playing, Completed, Dropped, OnHold. Submission types: NewGame, Correction. Errors come as {"code": "..."} (see Authentication for the auth codes).
Secrets are never committed. Environment variables override appsettings.json; use __ instead of : in names. The app refuses to start if a required setting is missing or invalid.
Minimum for production:
| Variable | Description |
|---|---|
ConnectionStrings__DefaultConnection |
PostgreSQL connection string (secret) |
Jwt__Key |
JWT signing key, ≥ 32 bytes, 64 random bytes recommended (secret) |
Google__ClientId |
OAuth 2.0 Web client ID (no client secret needed) |
CORS_ALLOWED_ORIGINS |
Comma-separated exact origins, e.g. https://gamenest.pp.ua |
All variables (JWT, Resend, feature switches, rate limits): docs/configuration.md.
GameNest_BackEnd/
├── Controllers/ # API endpoints (Auth, Games, GameTitles, Library, Profile, Submissions, UserGames)
├── Data/ # GameNestDbContext
├── DTOs/ # Request/response models and validation
├── Migrations/ # EF Core migrations (do not edit or delete)
├── Models/ # Entities
├── Cli/ # Operator command: admin promote
├── Services/ # Email senders (Resend, development), rate limiting, CORS
├── Properties/ # launchSettings.json (local profiles)
├── scripts/ # One-time operational SQL scripts
├── Tests/ # xUnit tests (not part of the API build)
├── Dockerfile # Production image
├── .env.example # Environment variable names with placeholders
└── Program.cs # Configuration, middleware pipeline, health endpoint
| Topic | File |
|---|---|
| Environment variables | docs/configuration.md |
| Docker, Render, Neon, migrations, CORS | docs/deployment.md |
| Google sign-in, email/password flow, email confirmation, Resend | docs/authentication.md |
| Promoting the first administrator | docs/admin.md |
| Known production limitations | docs/known-limitations.md |
- Passwords: BCrypt (8+ characters, at most 72 UTF-8 bytes, common passwords rejected).
- Login responses and timing are identical for unknown emails and wrong passwords.
- Authentication endpoints are rate limited per client IP (
429withRetry-After). - Roles can only be changed with direct database access (admin command or SQL script), never through the API. The JWT role is replaced with the current database role on every request, and tokens of deleted users are rejected.
- Swagger is available only in Development; TLS is terminated by Render / Cloudflare.
- Any secret that has ever been committed must be considered compromised and rotated.
Released under the MIT License.