Skip to main content

Local Development

Guide for setting up and running the FishingLog API locally for development.

Quick Start​

# Start database
docker-compose up -d db

# Run migrations
dotnet ef database update --project FishingLog.Infrastructure --startup-project FishingLog.API

# Start API
dotnet run --project FishingLog.API/FishingLog.API.csproj

Running the Application​

# From the solution root
dotnet run --project FishingLog.API/FishingLog.API.csproj

The API will be available at:

  • HTTPS: https://localhost:5100
  • HTTP: http://localhost:5101
  • Swagger UI: https://localhost:5100/swagger

Option 2: Run with Docker Compose​

# Build and start all services (API + Database)
docker-compose -f docker-compose.override.yml up --build

# Or run in detached mode
docker-compose -f docker-compose.override.yml up -d --build

Option 3: Run API Only (Database Already Running)​

# If database is already running via Docker
docker-compose up -d db
dotnet run --project FishingLog.API/FishingLog.API.csproj

Development Workflow​

Making Code Changes​

  1. Make your changes to the codebase
  2. The API will automatically reload (hot reload enabled in Development)
  3. Test your changes using Swagger UI or Insomnia

Database Changes​

When you modify entities:

  1. Create a migration:

    dotnet ef migrations add MigrationName --project FishingLog.Infrastructure --startup-project FishingLog.API
  2. Apply the migration:

    dotnet ef database update --project FishingLog.Infrastructure --startup-project FishingLog.API
  3. Remove last migration (if needed):

    dotnet ef migrations remove --project FishingLog.Infrastructure --startup-project FishingLog.API

Testing Changes​

  • Swagger UI: Test endpoints interactively at /swagger
  • Insomnia: Use the provided workspace (see Testing Guide)
  • Unit Tests: Add unit tests for new features

Environment Configuration​

Development Settings​

The appsettings.Development.json file contains development-specific settings:

{
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Port=5432;Database=fishinglog_db;Username=fishinglog_user;Password=supersecurepassword"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

HTTPS Configuration​

For local HTTPS development:

  1. Trust the certificate:

    dotnet dev-certs https --trust
  2. Create certificate for Docker:

    mkdir -p ~/.aspnet/https
    dotnet dev-certs https -ep ~/.aspnet/https/aspnetapp.pfx -p password123

Debugging​

Using Visual Studio / Rider​

  1. Set FishingLog.API as the startup project
  2. Set breakpoints in your code
  3. Press F5 to start debugging

Using VS Code​

  1. Install the C# extension
  2. Open the project folder
  3. Press F5 and select ".NET Core" debugger

Logging​

Logs are written to the console in Development mode. Check the console output for:

  • Request/response information
  • Database queries (if enabled)
  • Error messages and stack traces

Common Development Tasks​

Seed Initial Data​

The application includes seeders for reference data. These run automatically on first startup or can be triggered manually.

Reset Database​

⚠️ WARNING: This will delete all data!

# Windows
.\scripts\reset-migrations.ps1

# macOS/Linux
./scripts/reset-migrations.sh

View Database​

Connect to PostgreSQL:

# Using psql
psql -h localhost -U fishinglog_user -d fishinglog_db

# Or using Docker
docker exec -it fishinglog_postgres psql -U fishinglog_user -d fishinglog_db

Next Steps​