Local Development Setup
This guide walks you through setting up Bookify for local development without Docker, giving you full control over each component.Prerequisites
Before you begin, ensure you have the following installed:.NET 9 SDK
Download from dotnet.microsoft.com
PostgreSQL 16+
Download from postgresql.org
Redis
Download from redis.io
Git
Download from git-scm.com
Optional but Recommended
- Keycloak - For authentication (can run in Docker even if API runs locally)
- Seq - For structured logging (optional, logs will go to console otherwise)
- Your favorite IDE - Visual Studio 2022, JetBrains Rider, or VS Code
Installation Steps
Restore NuGet Packages
Restore all dependencies for the solution:This will download all required NuGet packages:
- MediatR (12.4.1) - CQRS implementation
- FluentValidation (11.11.0) - Request validation
- Npgsql.EntityFrameworkCore.PostgreSQL (9.0.2) - PostgreSQL provider
- Serilog.AspNetCore (9.0.0) - Structured logging
- StackExchange.Redis (9.0.2) - Redis caching
- And more…
The restore command analyzes dependencies across all four projects:
Bookify.ApiBookify.ApplicationBookify.InfrastructureBookify.Domain
Set Up PostgreSQL Database
Create a new PostgreSQL database:
The default connection string expects PostgreSQL on
localhost:4001. If you’re using the default port 5432, update the connection string in the next step.Configure Application Settings
Update the connection strings in
src/Bookify.Api/appsettings.Development.json:Using User Secrets (Recommended)
For better security, use .NET User Secrets instead:Run Database Migrations
Apply Entity Framework Core migrations to set up the database schema:This creates all necessary tables:You should see all the tables listed.
apartments- Apartment listingsbookings- Booking recordsusers- User accountsreviews- Apartment reviews- And supporting tables for value objects and relationships
Migrations are automatically applied when running in Development mode, but running manually gives you more control.
Verify Migration Success
Start Keycloak (Optional)
For authentication to work, start Keycloak:
Import Bookify Realm
If you have the realm configuration file:Run the Application
Start the Bookify API:You should see output like:
The application will automatically:
- Apply pending migrations
- Seed sample data (in Development mode)
- Configure Serilog logging
- Register health checks
Project Structure
Understanding the solution structure:Configuration Reference
Key configuration sections inappsettings.Development.json:
Development Workflow
Adding a New Migration
When you modify domain entities:Running Tests
Watching for Changes
Use the watch command for automatic rebuilds:IDE Setup
Visual Studio 2022
- Open
Bookify.sln - Set
Bookify.Apias the startup project - Press F5 to run with debugging
JetBrains Rider
- Open
Bookify.sln - Run configuration is auto-detected
- Use the Run button or Shift+F10
Visual Studio Code
- Install C# Dev Kit extension
- Open the project folder
- Use the Run and Debug panel (Ctrl+Shift+D)
Troubleshooting
Migration fails with 'relation already exists'
Migration fails with 'relation already exists'
Drop the database and recreate:
Cannot connect to PostgreSQL
Cannot connect to PostgreSQL
Verify PostgreSQL is running:
Redis connection failed
Redis connection failed
Verify Redis is running:If using WSL, ensure Redis is started in the WSL environment.
Package restore fails
Package restore fails
Clear NuGet cache and retry:
Keycloak authentication errors
Keycloak authentication errors
Ensure:
- Keycloak is running on port 18080
- The realm is properly imported
- Client secrets match your configuration
RequireHttpsMetadatais set tofalsefor local development
Application won't start
Application won't start
Check the logs in the console output. Common issues:
- Connection string is incorrect
- Database doesn’t exist
- Redis is not running
- Port conflicts (default ports: 5000, 7001)
Environment Variables
You can override configuration using environment variables:Next Steps
Now that you have Bookify running locally:- Explore the Architecture to understand the codebase
- Learn about CQRS Implementation using MediatR
- Study the Domain Model and business rules
- Review Authentication with Keycloak
- Check out Caching Strategies with Redis