A modern, fully-featured blogging platform built with Clean Architecture, ASP.NET Core, and Entity Framework Core. DevPulse demonstrates enterprise-grade API design with authentication, authorization, and comprehensive blog management capabilities.
DevPulse is a RESTful blogging platform that enables users to create, manage, and discover blog posts. The application leverages Clean Architecture principles to ensure separation of concerns, maintainability, and scalability. It is showcasing modern .NET development practices and design patterns.
Key Highlights:
- ποΈ Clean Architecture with clear separation of concerns
- π JWT-based authentication and role-based authorization
- π Full blog lifecycle management (Create, Read, Update, Delete)
- π·οΈ Category-based blog organization and filtering
- π User ownership authorization for blog content
- π οΈ Enterprise design patterns (Generic Repository, Unit of Work, Dependency Injection)
- π Global exception handling with standardized responses
- π Automatic data seeding and database migrations
- User Registration & Login - Secure account creation with email verification
- JWT Authentication - Token-based authentication for protected endpoints
- Role-Based Authorization - Admin and User roles with granular access control
- User Ownership Validation - Users can only modify their own blogs
- Create Blogs - Authenticated users can publish blogs with title, content, category, and optional images
- Read Blogs - Public access to browse all blogs or filter by category
- Update Blogs - Users can edit only their own published blogs
- Delete Blogs - Users can delete only their own blogs
- User Blog Retrieval - Authenticated users can view their own blog collection
- Browse Categories - Public access to view all available categories
- Admin Management - Admin users can create, update, and delete categories and update, delete any blog for any user
- Input Validation - Data Annotations for comprehensive validation rules
- Global Exception Handling - Centralized error handling middleware
- Standardized API Responses - Consistent response format across all endpoints
DevPulse follows Clean Architecture principles with a layered approach:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DevPulseApp (API Layer) β
β Controllers | Middleware | WebConfig β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββ
β Application (Business Logic) β
β Services | DTOs | Interfaces | Dependency Setup β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββ
β Infrastructure (Data Access) β
β UnitOfWork | Repositories | DbContext | Services β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββ
β Domain (Core Entities) β
β ApplicationUser | Blog | Category β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Pattern | Purpose |
|---|---|
| Generic Repository Pattern | Centralized data access logic with reusable CRUD operations |
| Unit of Work Pattern | Transaction management and coordinated repository operations |
| Dependency Injection | Loose coupling and easy testability |
| DTO Pattern | Clean separation between API contracts and domain models |
| Middleware Pattern | Cross-cutting concerns (exception handling, authentication) |
| Factory Pattern | Service registration through extension methods |
DevPulse/
βββ DevPulseApp/ # API Layer (ASP.NET Core Web API)
β βββ Controllers/
β β βββ AccountController.cs # Authentication endpoints
β β βββ BlogController.cs # Blog CRUD and filtering
β β βββ CategoryController.cs # Category management
β βββ Middlewares/
β β βββ GlobalExceptionMiddleware.cs # Centralized error handling
β βββ ExtensionMethods/
β β βββ WebApplicationRegister.cs # App configuration extensions
β βββ Program.cs # Application entry point
β βββ appsettings.json # Configuration
β βββ Properties/
β βββ launchSettings.json
β
βββ Application/ # Business Logic Layer
β βββ Services/
β β βββ BlogService.cs
β β βββ CategoryService.cs
β βββ Interfaces/
β β βββ Services/
β β β βββ IAccountService.cs
β β β βββ IBlogService.cs
β β β βββ ICategoryService.cs
β β β βββ IJwtService.cs
β β βββ Repositories/
β β β βββ IGenericRepository.cs
β β βββ UnitOfWork/
β β β βββ IUnitOfWork.cs
β β βββ DataSeeding/
β β βββ IDataInitializer.cs
β βββ DTOs/
β β βββ AccountDTOs/
β β β βββ RegisterDto.cs
β β β βββ LoginDto.cs
β β βββ BlogDTOs/
β β β βββ CreateBlogDto.cs
β β β βββ GetBlogDto.cs
β β β βββ UpdateBlogDto.cs
β β βββ CategoryDTOs/
β β β βββ CreateCategoryDto.cs
β β β βββ GetCategoryDto.cs
| | | βββ GetCategoryWithoutBlogsDto.cs
β β β βββ UpdateCategoryDto.cs
β β βββ JwtDTOs/
β β βββ JwtDto.cs
β βββ Mapper/
β β βββ DomainProfile.cs # AutoMapper configuration
β βββ DependencyInjection/
β βββ ApplicationServiceRegistration.cs
β
βββ Infrastructure/ # Data Access Layer
β βββ Database/
β β βββ ApplicationDbContext.cs # Entity Framework Core context
β β βββ Migrations/
β βββ Configurations/
β β βββ ApplicationUserConfiguration.cs
β β βββ BlogConfiguration.cs
β β βββ CategoryConfiguration.cs
β βββ Repositories/
β β βββ GenericRepository.cs
β βββ Services/
β β βββ AccountService.cs
β β βββ JwtService.cs
β βββ UnitOfWork/
β β βββ UnitOfWork.cs
β βββ DataSeeding/
β β βββ DataInitializer.cs
β βββ DependencyInjection/
β βββ InfrastructureServiceRegistration.cs
β
βββ Domain/ # Core Domain Layer
βββ Entities/
β βββ BaseEntity.cs # Base entity with generic Id
β βββ ApplicationUser.cs # User with Identity
β βββ Blog.cs # Blog entity
β βββ Category.cs # Category entity
βββ Domain.csproj
Extends ASP.NET Core Identity User with profile information:
FirstName,LastName- User profileBlogs- Collection of user's published blogs
Core blog entity with rich content:
Title- Blog title (3-200 characters)Content- Blog body (20-10,000 characters)ImageUrl- Optional featured image URLCategoryId- Foreign key to CategoryUserId- Foreign key to ApplicationUser (owner)CreatedAt- Publication timestamp
Content organization:
Name- Category nameBlogs- Collection of blogs in this category
- Token Generation - Issued upon successful login
- Token Validation - Custom claims and signature verification
- Configuration - Issuer, Audience, and expiration settings in
appsettings.json - Duration - Configurable token lifetime (default: 30 days)
- Admin Role - Category management, administrative operations
- User Role - Default role for registered users
- Public Access - Endpoints for anonymous users (blog browsing, category listing)
[AllowAnonymous] // Public endpoint
[Authorize] // Authenticated
[Authorize(Roles = "Admin")] // Admin users only- ASP.NET Core 9 - High-performance web framework
- .NET 9 - Latest .NET runtime
- Entity Framework Core - Object-relational mapping
- SQL Server - Relational database
- LINQ - Data queries and operations
- ASP.NET Core Identity - User management and authentication
- JWT Bearer Authentication - Token-based security
- SymmetricSecurityKey - Token encryption/decryption
- Microsoft Dependency Injection - Service registration and resolution
- AutoMapper - Object-to-object mapping for DTOs
- Swagger/OpenAPI - Interactive API documentation
- Swagger UI - Web-based API testing interface
- System.ComponentModel.DataAnnotations - Declarative validation rules
- Custom Validation - Email, StringLength, Required attributes
- Global Exception Middleware - Centralized error handling
- Custom Response Format - Standardized API responses
- .NET 9 SDK - Download
- SQL Server - Any version (LocalDB, Developer Edition, or Express)
- Visual Studio 2022 or VS Code with C# extension
-
Clone the Repository
git clone https://github.com/Gargera/DevPulse-WebAPI.git cd DevPulse
-
Configure Database Connection
- Open
DevPulseApp/appsettings.json - Update
ConnectionStrings:DefaultConnectionwith your SQL Server connection string:"ConnectionStrings": { "DefaultConnection": "Server=.;Database=DevPulseDb;Trusted_Connection=true;TrustServerCertificate=true;" }
- Open
-
Configure JWT Settings
- Update JWT settings in
appsettings.json:"JWT": { "Key": "your-secret-key-here-minimum-64-characters", "Issuer": "DevPulseAPI", "Audience": "DevPulseClient", "DurationInDays": 30 }
- Security Note: Use
dotnet user-secretsfor sensitive configuration in production
- Update JWT settings in
-
Restore Dependencies
dotnet restore
-
Apply Migrations
dotnet ef database update --project Infrastructure --startup-project DevPulseApp
-
Run the Application
dotnet run --project DevPulseApp -
Access the API
- API:
https://localhost:5001 - Swagger UI:
https://localhost:5001/swagger
- API:
Instead of hardcoding sensitive data in appsettings.json, use User Secrets:
# Initialize user secrets
dotnet user-secrets init --project DevPulseApp
# Set connection string
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Your_Connection_String" --project DevPulseApp
# Set JWT key
dotnet user-secrets set "JWT:Key" "Your_JWT_Secret_Key" --project DevPulseAppPOST /api/account/register- Create new user accountPOST /api/account/login- Authenticate and receive JWT token
GET /api/blog- Get all blogs (public)GET /api/blog/{id}- Get blog by ID (public)GET /api/blog/category/{categoryId}- Filter blogs by category (public)GET /api/blog/my-blogs- Get current user's blogs (authenticated)POST /api/blog- Create new blog (authenticated)PUT /api/blog/{id}- Update blog (authenticated, owner and admins only)DELETE /api/blog/{id}- Delete blog (authenticated, owner and admins only)
GET /api/category- Get all categories (public)GET /api/category/{id}- Get category by ID (admin)POST /api/category- Create category (admin)PUT /api/category/{id}- Update category (admin)DELETE /api/category/{id}- Delete category (admin)
Gargera
- GitHub: @Gargera
- Repository: DevPulse-WebAPI
DevPulse Β© 2024. modern ASP.NET Core development practices and Clean Architecture principles.