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
Option 1: Run Locally (Recommended for Development)
# 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
- Make your changes to the codebase
- The API will automatically reload (hot reload enabled in Development)
- Test your changes using Swagger UI or Insomnia
Database Changes
When you modify entities:
-
Create a migration:
dotnet ef migrations add MigrationName --project FishingLog.Infrastructure --startup-project FishingLog.API -
Apply the migration:
dotnet ef database update --project FishingLog.Infrastructure --startup-project FishingLog.API -
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:
-
Trust the certificate:
dotnet dev-certs https --trust -
Create certificate for Docker:
mkdir -p ~/.aspnet/https
dotnet dev-certs https -ep ~/.aspnet/https/aspnetapp.pfx -p password123
Debugging
Using Visual Studio / Rider
- Set
FishingLog.APIas the startup project - Set breakpoints in your code
- Press F5 to start debugging
Using VS Code
- Install the C# extension
- Open the project folder
- 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
- API Documentation - Learn about API endpoints
- Testing Guide - Set up API testing
- Docker Setup - Run with Docker