ASP.NET Core Web API for the Diet Tracker application. This service provides REST endpoints for managing diet-tracking data, uses Entity Framework Core with PostgreSQL, and secures access with JWT bearer authentication.
- .NET 8 / ASP.NET Core Web API
- Entity Framework Core 8
- PostgreSQL via Npgsql
- JWT bearer authentication
- Swagger / OpenAPI
- Docker and docker-compose
- PowerShell migration scripts
Authorization/- authorization handlers and requirementsBusinessLayer/- application/business logicControllers/- API controllers and HTTP endpointsDataLayer/- EF Core data access and modelsExtensions/- application extension helpersFilters/- MVC/API filtersMigrations/- Entity Framework database migrationsServices/- supporting services such as token generationscripts/- migration and data import/export utilitiesProgram.cs- application startup and dependency registrationdocker-compose.template.yaml- local/container deployment templatePOSTGRESQL_MIGRATION.md- PostgreSQL migration guide
- REST API built with ASP.NET Core controllers
- JWT authentication and authorization policies
- PostgreSQL database connectivity with automatic EF Core migrations at startup
- Health check endpoint at
/health - Swagger UI for API exploration
- Docker-based local deployment template
- Data migration tooling for moving from MS SQL Server to PostgreSQL
The API expects configuration from environment variables.
Jwt:IssuerJwt:AudienceJwt:SecretKey
DB_HOSTDB_PORTDB_NAMEDB_USERNAMEDB_PASSWORD
# restore dependencies
dotnet restore
# run the API
dotnet runBy default, Swagger is enabled and the app also exposes a health endpoint at /health.
- Copy
docker-compose.template.yamlto your own compose file. - Replace placeholder values for PostgreSQL and JWT configuration.
- Start the stack:
docker compose up -dThe template includes:
postgresdiet-tracker-apidiet-tracker-ui
The application is configured to use JWT bearer authentication. Tokens are validated using issuer, audience, signing key, and lifetime checks. Authorization policies are registered for permission-based scopes such as:
write:fuelingswrite:planswrite:lean-and-greenswrite:userread:userread:user:fuelingsread:user:lean-and-greenadmin:users
- The application uses PostgreSQL as its active database provider.
- EF Core migrations are applied automatically during startup.
- See
POSTGRESQL_MIGRATION.mdfor migration and data import/export guidance.
Recent notable changes based on commit history:
- 2026-05-07 - Updated handling for user name data (
handle user name). - 2026-05-05 - Implemented native JWT authentication with refresh tokens, added refresh token and credential models, updated configuration, and removed Auth0 management dependencies.
- 2025-11-27 - Refactored controllers to remove unused logger dependencies and improved database configuration error handling.
- 2025-11-27 - Completed several PostgreSQL migration improvements, including timestamp compatibility updates, docker compose improvements, schema check/export-import scripts, and merge of the database migration work.
For additional history, see the commit list on GitHub: https://github.com/clinta74/diet-tracker-api/commits/main
POSTGRESQL_MIGRATION.md- migration steps and troubleshooting
No license file is currently defined in this repository.