DSGNLTest is a modern System built with .NET 8. It features a decoupled architecture with a secure Web API backend and a responsive Razor Pages frontend.
- Framework: .NET 8.0
- Backend: ASP.NET Core Web API
- Frontend: ASP.NET Core Razor Pages
- Authentication: JWT (JSON Web Tokens)
- Security: BCrypt for password hashing
- Documentation: Swagger/OpenAPI
- Testing: xUnit, Moq, Microsoft.AspNetCore.Mvc.Testing
- .NET 8.0 SDK installed.
Navigate to src/Designli.Api/appsettings.json and ensure the JWT settings are configured (default values provided for development):
"Jwt": {
"Key": "THIS_IS_A_SUPER_SECRET_KEY_123456789",
"Issuer": "DesignliIssuer",
"Audience": "DesignliAudience"
}Navigate to src/Designli.Web/appsettings.json and verify the API Base URL:
"ApiBaseUrl": "https://localhost:7063"You need to run both the API and the Web projects.
Option A: Visual Studio
- Open
DesignliApp.sln. - Configure Multiple Startup Projects: Right-click Solution -> Properties -> Startup Project -> Select "Multiple startup projects".
- Set
Designli.ApiandDesignli.Webto "Start". - Press F5.
Option B: CLI Open two terminal windows:
Terminal 1 (API):
cd src/Designli.Api
dotnet runTerminal 2 (Web):
cd src/Designli.Web
dotnet runNote: Ensure the API is running on the port expected by the Web app (default https://localhost:7063).
The solution follows a Clean Architecture approach:
- Designli.Domain: Contains core entities (
Employee,User) and repository interfaces. No external dependencies. - Designli.Infrastructure: Implements data access and services (e.g.,
EmployeeRepository,JwtTokenService). - Designli.Api: Exposes RESTful endpoints and handles JWT authentication.
- Designli.Web: A Razor Pages application that consumes the API. It uses
IHttpClientFactoryfor typed clients (AuthApiService,EmployeeApiService) and manages user sessions.
- User logs in via the Web UI.
- Web app sends credentials to the API.
- API validates credentials and issues a JWT.
- Web app stores the JWT in a secure HTTP-only cookie/session.
- Subsequent requests to the API include the JWT in the Authorization header.
The solution includes comprehensive Unit and Integration tests in src/Designli.Tests.
To run all tests:
dotnet test src/Designli.Tests- Unit Tests: Cover Controllers, Services, and Models.
- Integration Tests: Verify the full authentication flow using
WebApplicationFactory.
The API comes with Swagger UI for easy exploration and testing.
When running the API project locally, navigate to:
https://localhost:7063/swagger
POST /login: Authenticate and receive a JWT token.GET /users: List all registered users (requires authentication).
GET /: List all employees.GET /{id}: Get employee details.POST /: Create a new employee.PUT /{id}: Update an employee.DELETE /{id}: Delete an employee.
- Dashboard: A modern landing page displaying key metrics and quick actions.
- Employees CRUD: Full Create, Read, Update, and Delete functionality for employee records.
- Logout: Secure logout functionality that clears the user session and redirects to the login page.