Overview
The Social Media Activity Feed API is built using ASP.NET Core Minimal APIs, a lightweight approach to building HTTP APIs without the overhead of traditional MVC controllers. This architecture emphasizes simplicity, performance, and clarity in organizing domain logic.ASP.NET Core Minimal APIs Approach
Minimal APIs provide a streamlined way to create HTTP endpoints with minimal ceremony. Instead of controller classes, endpoints are defined as lambda expressions or local functions, registered directly with the application’s routing system. Key benefits:- Reduced boilerplate: No need for controller attributes or action methods
- Performance: Less abstraction means faster startup and request processing
- Simplicity: Endpoints are co-located with their domain logic
Feature-Module Organization
Rather than organizing code by technical layers (controllers, services, repositories), this API uses a feature-module structure. Each feature owns its routes, logic, and data access.Directory Structure
Thefeatures/ directory contains domain-organized modules:
Benefits of Feature Modules
From the README:- Routing close to behavior: Each feature owns its routes, making it easy to understand what endpoints exist and what they do
- Compile-time discoverability: Simple navigation inside the repository - if you want to understand how follows work, everything is in
features/follow/ - Thin composition root:
Program.csremains minimal, simply wiring together features
Endpoint Registration Pattern
Features expose extension methods onWebApplication to register their endpoints. This keeps Program.cs clean and delegates routing logic to feature modules.
Program.cs Structure
Extension Method Pattern
Each feature module implements a static extension method:- Encapsulates feature-specific routing logic
- Supports dependency injection through endpoint parameters
- Allows features to be added/removed by simply calling or not calling their extension method
- Keeps
Program.csfocused on configuration, not implementation
Tech Stack
Backend Framework
- ASP.NET Core: Cross-platform, high-performance web framework
- Minimal APIs: Lightweight routing without MVC overhead
Authentication
- JWT Bearer Authentication: Stateless authentication via signed tokens
- ASP.NET Core Identity PasswordHasher: Secure password hashing (PBKDF2)
Data Access
- Entity Framework Core: Modern object-relational mapper (ORM)
- LINQ: Expressive, type-safe queries
- Projection with
.Select(): Avoids N+1 queries and shapes API responses .AsNoTracking(): Optimizes read-only queries by disabling change tracking
Database
- SQLite: Lightweight, file-based database for development
- Future-ready for PostgreSQL migration in production
Query Optimization Patterns
From the README:N+1 Query Prevention
The API uses several strategies to avoid the N+1 query problem:- Projection (
.Select()): Shapes API responses and fetches only needed columns .AsNoTracking(): Applied to read-only queries to reduce change-tracker overhead- Targeted
.Include(): Used sparingly when entity graphs must be materialized
- Predictable DB round-trips
- Controlled memory usage
- Intentional response payloads
Atomic Operations
Where correctness matters (unfollow, unlike), operations use explicit transactions:Key Design Principles
- Simplicity over abstraction: Use minimal APIs and feature modules instead of layered architecture
- Performance by default: Leverage projections, no-tracking queries, and cursor pagination
- Data integrity: Use composite primary keys and transactions where correctness matters
- Type safety: Leverage C# and LINQ for compile-time validation
- Explicit over implicit: Extension methods make feature registration visible and controllable