Work in progress. See Roadmap for the current state.
A REST API inspired by Stack Overflow, built with ASP.NET Core and Entity Framework Core. The goal is to practice production-grade backend development: layered architecture, data integrity, testing and CI. This project started as a practice exercise in an Entity Framework Core course. It has since been redesigned (Clean Architecture, soft delete, auditing) and extended well beyond the original scope.
This project is not affiliated with Stack Overflow.
Foundation
- Domain model and database schema with EF Core migrations
- Soft delete and automatic timestamps
- API documentation (OpenAPI + Scalar)
- Browsing tags (
GET /api/tags) - User registration (
POST /api/users) - Login with JWT (
POST /api/auth/login) - Current user profile (
GET /api/users/me) - Account deletion with personal data anonymization (GDPR) (
POST /api/users/me/delete)
Planned
- Questions, answers and comments
- Upvotes and downvotes
- Tagging questions and filtering by tag
- Accepting answers
- Pagination and sorting
- .NET 10, C# 14
- ASP.NET Core Web API (controllers)
- Entity Framework Core 10
- SQL Server (LocalDB for development)
- OpenAPI (
Microsoft.AspNetCore.OpenApi) + Scalar - FluentValidation
- JWT bearer authenticationgit ls
The solution follows Clean Architecture. Dependencies point inwards:
Api ──► Application ──► Domain
│ ▲
└──► Infrastructure ─────┘
- Domain – entities and core rules. No external dependencies.
- Application – use cases, DTOs and validation.
- Infrastructure – EF Core:
DbContext, migrations, interceptors, seed data. - Api – controllers, configuration and dependency injection setup.
- Soft delete – questions, answers, comments and users are never physically deleted. A
DeletedAttimestamp is set instead, and named global query filters hide deleted records. - Restricted deletes – foreign keys use
Restrictinstead of cascade, so the database blocks accidental hard deletes. - Auditing via interceptor – a
SaveChangesInterceptorsetsCreatedAt,UpdatedAtandDeletedAtin one place, usingTimeProviderfor testability. - Comment integrity – a check constraint guarantees that a comment belongs to exactly one parent: a question or an answer.
- No lazy loading – related data is loaded explicitly to avoid N+1 queries.
Detailed reasoning is recorded as Architecture Decision Records in docs/decisions.
- .NET 10 SDK
- SQL Server LocalDB (Windows; installed with Visual Studio or SQL Server Express)
- Clone the repository:
git clone https://github.com/aDDOS12/StackOverflowClone.git
cd StackOverflowClone
- Configure the JWT signing key (stored outside the repository with User Secrets).
Generate a random key (PowerShell):
$bytes = New-Object byte[] 64; [System.Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes); [Convert]::ToBase64String($bytes)
Then save it:
dotnet user-secrets set "Jwt:SigningKey" "<generated-key>" --project src/StackOverflowClone.Api
-
Create the database by applying migrations, using one of the options below.
Visual Studio (Package Manager Console) – set Default project to
StackOverflowClone.Infrastructure, then run:
Update-Database
.NET CLI:
dotnet tool install --global dotnet-ef
dotnet ef database update --project src/StackOverflowClone.Infrastructure --startup-project src/StackOverflowClone.Api
- Run the API:
dotnet run --project src/StackOverflowClone.Api --launch-profile https
- Open the API reference at
https://localhost:7266/scalar/v1.
The connection string is configured in src/StackOverflowClone.Api/appsettings.Development.json.
If the browser warns about the certificate, trust the .NET development certificate once:
dotnet dev-certs https --trust
- Phase 0 – Data model fixes, Clean Architecture structure, README
- Phase 1 – API foundation: first endpoints, error handling, validation
- Phase 2 – Users and security: registration, JWT, authorization, account deletion (GDPR)
- Phase 3 – Questions, answers, comments, tags, pagination
- Phase 4 – Business logic: voting, accepting answers
- Phase 5 – Unit and integration tests
- Phase 6 – Docker and GitHub Actions CI
This project is licensed under the MIT License – see LICENSE.txt.