TheMarketplace is a .NET 8 web API backend for a community-based buy/sell/trade platform. The system provides a structured approach to marketplace operations using a hierarchical model: Listings contain Cards, which contain Products with detailed information.
- Listings: Top-level collections that organise trading items
- Cards: Visual containers within listings that group related products
- Products: Individual items/services with detailed specifications
- Product Details: Extended information including media and documents
- User Management: JWT-based authentication with role-based access
- .NET 8 - Modern C# runtime with minimal API architecture
- WolverineFx - Message bus for CQRS pattern implementation
- Entity Framework Core 8 - Data access layer with Code First approach
- ASP.NET Core Identity - User authentication and authorisation
- JWT Authentication - Secure token-based authentication with refresh tokens
- SQL Server 2022 - Primary database (containerised)
- FluentValidation - Input validation framework
- MailKit - Email service implementation
- MailHog - Email testing service (containerised)
- Swagger/OpenAPI - API documentation and testing
- xUnit & Alba - Unit and integration testing framework
- Docker & Docker Compose - Containerisation for development
-
Authentication System
- Enhanced User Registration: Streamlined single-step registration with email confirmation
- Email Confirmation: Robust token-based email verification with MailHog integration
- Configuration Management: Frontend URL configuration with fallback to constants
- Age Validation: Enforced minimum age requirement (13+ years)
- JWT Authentication: Secure token-based authentication with refresh tokens
- Token Management: Proper token refresh and revocation with validation
- Role-Based Authorization: Complete role-based access control
- Email Service: MailKit implementation for reliable email delivery
-
Core Data Models
- Complete entity relationship mapping
- Base entity with audit fields
- User profiles and roles
- Media and document support
-
API Endpoints
- Complete CRUD operations for all entities (Listings, Cards, Products, ProductDetails, Media, Documents, Tags, UserProfiles)
- Authentication endpoints (login, register, token management)
- Comprehensive endpoint coverage with proper HTTP verbs
- Swagger documentation with security schemes
-
Infrastructure
- Docker containerisation for SQL Server with proper volume management
- EF Core migrations setup with .NET 8 compatibility
- Automated database initialisation for tests
- Comprehensive test structure with Alba integration testing
- Scenario-based testing with proper database isolation
- CORS configuration
- Proper dependency injection configuration
- ✅ All tests passing (229 total) - Recent fixes to registration tests and cleanup of legacy mocks
- Registration Flow Enhancement: Fixed and streamlined single-step registration process
- Email Confirmation: Resolved email confirmation links to use correct frontend URLs
- Configuration Management: Added
FrontendSettings.BaseUrlconfiguration in appsettings - Constants Enhancement: Added
ApiConstants.DefaultFrontendBaseUrlfor consistent fallback - Test Suite Fixes: Updated all registration tests to work with new configuration pattern
- MailHog Integration: Improved email testing workflow with proper URL routing
- Frontend Integration: Email confirmation links now correctly point to frontend (http://localhost:3000)
- Advanced search and filtering functionality
- File upload and media handling optimisation
- Real-time notifications
- Performance optimisations
- .NET 8 SDK
- Docker Desktop
- SQL Server Management Studio (optional)
-
Start the database
docker compose up -d
-
Run migrations
dotnet ef database update --project Marketplace.Data --startup-project Marketplace.Api
-
Start the API
dotnet run --project Marketplace.Api
-
Access Swagger UI
- Navigate to:
https://localhost:5001/swagger - Database connection:
Server=127.0.0.1,1433;User=sa;Password=P@ssw0rd!
- Navigate to:
-
Start the Frontend (Optional - for full registration testing)
cd TheMarketplace.Frontend npm install npm run dev- Frontend will be available at:
http://localhost:3000
- Frontend will be available at:
The registration system includes email confirmation with MailHog integration for testing. Here's how to test the complete flow:
- Backend API running on port 5212
- Frontend running on port 3000 (optional, can test via API only)
- MailHog running in Docker container (port 8025)
-
Start all services:
# Start database and MailHog docker compose up -d # Start backend API dotnet run --project Marketplace.Api # Start frontend (in separate terminal) cd TheMarketplace.Frontend npm run dev
-
Register a new user:
- Navigate to
http://localhost:3000/register - Fill out the registration form:
- First Name:
John - Last Name:
Doe - Email:
john.doe@example.com - Password:
SecurePass123! - Date of Birth: Any date making the user 13+ years old
- First Name:
- Click "Register"
- Navigate to
-
Check registration response:
- Should see success message
- User account created but not yet confirmed
- Confirmation email sent to MailHog
-
View confirmation email in MailHog:
- Open
http://localhost:8025in your browser - Click on the latest email to
john.doe@example.com - Subject should be "Confirm your registration"
- Email contains a clickable confirmation link
- Open
-
Complete registration:
- Click the confirmation link in the email
- Link format:
http://localhost:3000/api/auth/confirm-email?userId=...&token=...&email=... - Should see JSON response:
{"registrationCompleted": true, "confirmationCode": "RegistrationComplete"} - User account is now fully activated
-
Test login:
- Navigate to
http://localhost:3000/login - Use the registered credentials
- Should successfully log in and receive JWT token
- Navigate to
-
Register via API:
curl -X POST http://localhost:5212/api/auth/register \ -H "Content-Type: application/json" \ -d '{ "firstName": "Jane", "lastName": "Smith", "email": "jane.smith@example.com", "password": "SecurePass123!", "dateOfBirth": "1990-01-01" }'
-
Check MailHog for confirmation email:
- Visit
http://localhost:8025 - Find email to
jane.smith@example.com - Copy the confirmation URL from the email
- Visit
-
Confirm email via API:
# Extract userId, token, and email from the confirmation URL curl "http://localhost:3000/api/auth/confirm-email?userId=<USER_ID>&token=<TOKEN>&email=jane.smith%40example.com"
-
Test login:
curl -X POST http://localhost:5212/api/auth/login \ -H "Content-Type: application/json" \ -d '{ "email": "jane.smith@example.com", "password": "SecurePass123!" }'
-
Access Swagger UI:
- Navigate to
http://localhost:5212/swagger
- Navigate to
-
Test registration:
- Find
POST /api/auth/registerendpoint - Click "Try it out"
- Fill in the request body with user details
- Execute the request
- Find
-
Check MailHog:
- Visit
http://localhost:8025to view the confirmation email
- Visit
-
Test email confirmation:
- Find
GET /api/auth/confirm-emailendpoint in Swagger - Enter the
userId,token, andemailparameters from the email - Execute the request
- Find
- Registration Success: Returns user ID and confirmation link
- Email Delivery: Confirmation email appears in MailHog within seconds
- Email Content: Contains clickable link pointing to frontend URL
- Confirmation Success: Returns
{"registrationCompleted": true} - Login Success: User can authenticate with confirmed credentials
- Email not appearing: Check MailHog container is running (
docker ps) - Confirmation link fails: Ensure frontend is running on port 3000
- Database errors: Run migrations (
dotnet ef database update) - Port conflicts: Check no other services are using ports 5212, 3000, or 8025
The solution follows a clean architecture pattern with four main projects:
- Marketplace.Api - Web API layer with endpoints and configuration
- Marketplace.Core - Business logic and shared utilities
- Marketplace.Data - Data access layer with EF Core
- Marketplace.Test - Comprehensive unit and integration tests
- Priority: High
- ✅ Complete CRUD operations for all entities (COMPLETED)
- File upload and media handling optimisation
- Advanced search and filtering functionality
- Email notifications system
- Input validation and error handling enhancements
- Performance optimisation and caching
- Priority: High
- Advanced search with filters and sorting
- Real-time notifications (SignalR)
- Messaging system between users
- Transaction history tracking
- Wishlist/favorites functionality
- Mobile-responsive web interface
- Priority: Medium
- Payment integration (Stripe/PayPal)
- Rating and review system
- Escrow service for secure transactions
- Admin dashboard for platform management
- Reporting and analytics
- API rate limiting and monitoring
- Priority: Medium
- AI-powered product recommendations
- Automated content moderation
- Multi-language support
- Mobile app (React Native/Flutter)
- Advanced analytics dashboard
- Integration with external marketplaces
- Priority: Low
- Microservices architecture migration
- Redis caching implementation
- CDN for media delivery
- Advanced security features (2FA, audit logging)
- Machine learning for fraud detection
- White-label solution for other organisations
- Follow SOLID principles and clean architecture
- Use the mediator pattern via WolverineFx
- Implement comprehensive unit and integration tests
- Maintain API documentation via Swagger
- Follow conventional commits for version control
- JWT tokens with refresh mechanism
- Input validation and sanitisation
- SQL injection prevention via EF Core
- CORS configuration for frontend integration
- Role-based access control
- Use async/await for all database operations
- Implement pagination for large data sets
- Consider caching strategies for frequently accessed data
- Optimise database queries with proper indexing
For detailed development instructions, navigate to individual project README.md files:
Marketplace.Api/README.md- API development guidelines and technology stackMarketplace.Core/README.md- Business logic, validation, and domain servicesMarketplace.Data/README.md- Database, migrations, and repository patternsMarketplace.Test/README.md- Testing strategies, factories, and infrastructure
Marketplace.Api/Endpoints/README.md- Complete endpoint reference and patternsMarketplace.Data/Configurations/README.md- Entity configuration patternsMarketplace.Data/Repositories/README.md- Repository implementation detailsMarketplace.Test/Factories/README.md- Test factories and infrastructure setup
The project includes Docker support for the SQL Server database:
# Start database container
docker compose up -d
# Stop and remove containers
docker compose down
# View logs
docker compose logs -fDatabase Connection Details:
- Server:
127.0.0.1,1433 - Authentication: SQL Server Authentication
- Username:
sa - Password:
P@ssw0rd!(change in docker-compose.yaml)
The solution includes comprehensive testing:
# Run all tests
dotnet test
# Run with verbose output
dotnet test --verbosity normal
# Run with coverage
dotnet test --collect:"XPlat Code Coverage"
# Run specific test project
dotnet test Marketplace.Test
# Run tests with Alba integration testing
dotnet test --logger "console;verbosity=detailed"