A .NET 8 Bookmark Manager backend solution with Clean Architecture, CQRS pattern using MediatR, and Entity Framework Core.
This solution follows Clean Architecture principles with the following layers:
- BookmarkManager.Api - Web API layer with RESTful endpoints
- BookmarkManager.Application - Application layer with CQRS (Commands/Queries), DTOs, and business logic
- BookmarkManager.Domain - Domain layer with entities and interfaces
- BookmarkManager.Infrastructure - Infrastructure layer with EF Core, repositories, and external services
- BookmarkManager.Migration - Database migration scripts (private)
- .NET 8 SDK
- SQL Server (LocalDB, Express, or full version)
- Visual Studio 2022 or VS Code
-
Clone the repository
git clone <your-repo-url> cd BookmarkManager.BE
-
Configure Database Connection (User Secrets)
For API Project:
cd BookmarkManager.Api dotnet user-secrets init dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Server=YOUR_SERVER;Database=YOUR_DATABASE;Trusted_Connection=true;TrustServerCertificate=true;MultipleActiveResultSets=true" cd ..
For Migration Project:
cd BookmarkManager.Migration dotnet user-secrets init dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Server=YOUR_SERVER;Database=YOUR_DATABASE;Trusted_Connection=true;TrustServerCertificate=true;MultipleActiveResultSets=true" cd ..
-
Run Database Migrations
cd BookmarkManager.Migration dotnet run cd ..
-
Run the API
dotnet run --project BookmarkManager.Api
-
Test the API
The API will be available at
https://localhost:7001(or the port shown in the console)Available Endpoints:
GET /api/collections- Get all collectionsPOST /api/collections- Create a new collectionGET /api/bookmarks/all- Get all bookmarksPOST /api/bookmarks- Create a new bookmark
This repository is configured to protect sensitive information:
- Database Connection Strings - Not committed to the repository; use user secrets
- Migration Scripts - Excluded from public repository (contains database structure)
- Environment-specific Configurations - Development/Production settings are ignored
appsettings.Development.jsonappsettings.Production.jsonappsettings.Local.jsonMigration/directory (contains database scripts)bin/andobj/directories- User-specific files (
.user,.suo) .secret.json(user secrets)
When setting up the project:
- Never commit your local secrets or environment-specific config files
- Use user secrets for all sensitive values
- Keep migration scripts private - they contain sensitive database structure information
BookmarkManager.BE/
├── BookmarkManager.Api/ # Web API layer
│ ├── Controllers/ # API controllers
│ ├── Configuration/ # Startup configuration
│ └── appsettings.json # Default config (empty values)
├── BookmarkManager.Application/ # Application layer
│ ├── Commands/ # CQRS Commands
│ ├── Queries/ # CQRS Queries
│ ├── Dto/ # Data Transfer Objects
│ └── Extensions/ # Service extensions
├── BookmarkManager.Domain/ # Domain layer
│ ├── Entities/ # Domain entities
│ └── Interfaces/ # Repository interfaces
├── BookmarkManager.Infrastructure/ # Infrastructure layer
│ ├── Database/ # EF Core configuration
│ │ ├── EntityTypeConfiguration/ # Entity configurations
│ │ └── Repository/ # Repository implementations
│ └── ServiceCollectionExtension.cs # DI configuration
├── BookmarkManager.Migration/ # Database migrations (PRIVATE)
│ ├── Migration/ # SQL scripts (excluded from repo)
│ └── appsettings.json # Default config (empty values)
└── README.md # This file
- Domain Layer - Add entities and interfaces
- Infrastructure Layer - Implement repositories and configurations
- Application Layer - Add commands/queries and DTOs
- API Layer - Add controllers and endpoints
- Create Migration Scripts - Add SQL scripts to
BookmarkManager.Migration/Migration/YYYY/M/ - Update Entity Configurations - Modify configurations in Infrastructure layer
- Run Migrations - Execute migration project to apply changes
# Build the solution
dotnet build
# Run tests (when added)
dotnet testGet All Collections
GET /api/collectionsCreate Collection
POST /api/collections
Content-Type: application/json
{
"name": "My Collection",
"icon": "📚",
"isFav": false
}Get All Bookmarks
GET /api/bookmarks/allCreate Bookmark
POST /api/bookmarks
Content-Type: application/json
{
"collectionId": 1,
"name": "Google",
"url": "https://www.google.com",
"icon": "🔍",
"isFav": false
}- Fork the repository
- Create a feature branch
- Make your changes
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Migration scripts are private and not included in the public repository
- Connection strings must be configured locally using user secrets
- Never commit sensitive information like database credentials
- Use environment variables for production deployments
-
Connection String Errors
- Ensure user secrets are set up and have correct connection string
- Verify SQL Server is running and accessible
-
Migration Errors
- Check that migration scripts are in the correct directory
- Ensure database exists and is accessible
-
Build Errors
- Run
dotnet restoreto restore packages - Ensure .NET 8 SDK is installed
- Run
If you encounter issues:
- Check the console output for error messages
- Verify your connection strings are correct
- Ensure all prerequisites are installed
- Create an issue in the repository