{"id":28089309,"url":"https://github.com/domoar/northwind-api","last_synced_at":"2025-07-22T08:31:21.230Z","repository":{"id":288932685,"uuid":"969590984","full_name":"domoar/Northwind-Api","owner":"domoar","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-14T01:50:31.000Z","size":1873,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-14T04:34:17.931Z","etag":null,"topics":["aspnet-core","aspnet-core-webapi","csharp","docker","jaeger","northwind","postgres","seq","serilog","testcontainers","xunit"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/domoar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-20T13:58:06.000Z","updated_at":"2025-05-07T14:56:19.000Z","dependencies_parsed_at":"2025-05-13T12:56:17.897Z","dependency_job_id":"48f81819-a3b5-4430-9a8a-bcfa0a1d43f5","html_url":"https://github.com/domoar/Northwind-Api","commit_stats":null,"previous_names":["domoar/northwind-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/domoar/Northwind-Api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domoar%2FNorthwind-Api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domoar%2FNorthwind-Api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domoar%2FNorthwind-Api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domoar%2FNorthwind-Api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/domoar","download_url":"https://codeload.github.com/domoar/Northwind-Api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domoar%2FNorthwind-Api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266456245,"owners_count":23931383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnet-core","aspnet-core-webapi","csharp","docker","jaeger","northwind","postgres","seq","serilog","testcontainers","xunit"],"created_at":"2025-05-13T12:56:14.346Z","updated_at":"2025-07-22T08:31:21.200Z","avatar_url":"https://github.com/domoar.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Northwind\n\n[![CI - Build, Format, Test](https://github.com/domoar/Northwind-Api/actions/workflows/build.yml/badge.svg)](https://github.com/domoar/Northwind-Api/actions/workflows/build.yml) [![Generate documentation](https://github.com/domoar/Northwind-Api/actions/workflows/documentation.yml/badge.svg)](https://github.com/domoar/Northwind-Api/actions/workflows/documentation.yml) [![Generate Code Coverage](https://github.com/domoar/Northwind-Api/actions/workflows/codecoverage.yml/badge.svg)](https://github.com/domoar/Northwind-Api/actions/workflows/codecoverage.yml)\n\nThis project was created using the template from [Clean Architecture Template](https://github.com/domoar/CleanArchitectureTemplate), and will be redone once github templates allows variable names in templates. [Discussion](https://github.com/orgs/community/discussions/5336)\n\n## ToC\n\n 1. [Api](#api)\n 2. [Docker](#dockerfile-and-dockercompose-for-the-project)\n 3. [Database](#postgresql-database-setup-with-docker-compose)\n 4. [Migration](#migration)\n 5. [Architecture](#architecture)\n 6. [CI/CD](#continuous-integration-und-continuous-deployment-cicd)\n 7. [Tools](#tools)\n 8. [Git Hooks](#git-hooks)\n\n## Api\n\nTo debug or run the api locally use\n\n```bash\ndotnet watch run --launch-profile \"https\"\n```\n\n### Curl\n\ne.g.\n\n```bash\ncurl -X 'GET' \\\n  'https://localhost:7104/api/Employee/GetEmployee?employeeId=1' \\\n  -H 'accept: application/json'\n```\n\n### Swagger\n\n[Swagger UI - localhost DBG](https://localhost:7104/swagger/index.html)\n\n## DockerFile and DockerCompose for the project\n\nThere is a Dockerfile and a docker-compose.yml in the root directory. The DockerFile can be build with:\n\n```bash\ndocker build .\n```\n\nThe compose file starts five services:\n\n- api – ASP.NET Core application.\n- db – PostgreSQL 17 with SSL.\n- pgadmin – Web UI for Postgres.\n- seq – Centralised structured log server.\n- jaeger – Distributed tracing system.\n\nStart / Shutdown these services with\n\n```bash\ndocker compose up -d \ndocker compose down\n```\n\n### Seq for Logging\n\nSeq captures and can query structures logs.\n\n#### How to setup Seq\n\n### Jaeger for Tracing\n\nJaeger displays distributed traces.\n\n#### How to setup Jaeger\n\n##### Additonal compose files for different purposes (.dcproj)\n\n- `docker-compose.yml` + `docker-compose.override.yml` – default local-dev stack (override is loaded automatically).\n- `docker-compose.dev.yml` – adds optional developer tooling (e.g. ).\n- `docker-compose.prod.yml` – production-only tweaks (harder restart policies, resource limits, etc.).\n\n```bash\n# development \ndocker compose -f docker-compose.yml -f docker-compose.prod.yml up -d\n\n# production\ndocker compose -f docker-compose.yml -f docker-compose.dev.yml up -d\n```\n\nto run the developement stack.\n\n[Docker merge strategies](https://docs.docker.com/compose/how-tos/multiple-compose-files/merge/)\n\n## Testing\n\nAll Tests can be run by chaning the working directory of the unit or integration tests and then using the command:\nApplying the `[Trait]` attribute at the **class** level allows, that every test method in that class can be run seperatly.\n\nExample to run individual test parts:\n\n```bash\ndotnet test --filter \"category=application\"\n```\n\n### IntegrationTests\n\n```bash\ncd tests/IntegrationTests\ndotnet test --logger \"console;verbosity=detailed\"\n```\n\n### UnitTests\n\n```bash\ncd tests/UnitTests\ndotnet test --logger \"console;verbosity=detailed\"\n```\n\n### Code Coverage\n\nCode Coverage is generated from unittests and integrationtests and merged into a report via GitHub Actions using the [ReportGenerator](https://github.com/danielpalme/ReportGenerator) tool.\n\n[View Full Coverage Report](https://domoar.github.io/Northwind-Api/codecoverage/index.html)\n\n### Postman\n\nThe testsuite contains a postman collection that can be used via the postman application or its vscode extension. In `.extras/postman`.\n\n### Testsuite client\n\nThe testsuite also contains a .http file with environments pre configured. In `.extras/client` you can either use the vscode extension [Rest-Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) or the built in feature from VS2022.\n\n## Third-Party Content Notice\n\nThis project includes data derived from:\n\n- **Northwind PostgreSQL SQL Dump**\n  - Original source: [Northwind PostgreSQL Sample on GitHub](https://github.com/pthom/northwind_psql)\n  - License: MIT\n  - Author: [Pierre THOMAS](https://github.com/pthom)\n\n## PostgreSQL Database Setup with Docker Compose\n\nThis project supports a dual-mode setup for PostgreSQL using Docker Compose:\n\n- **Setup Mode** (with root access): Use this to perform initial configuration, set permissions, and prepare mounted volumes.\n- **Production Mode** (with TLS and `postgres` user): Use this mode for secure, day-to-day database operations.\n\nBefore starting the container for the first time:\n\n1. Create the directory `C:/DockerVolumes/postgres/tls`\n\n    ```bash\n    mkdir C:\\DockerVolumes\\postgres\\tls\n    ```\n\n2. Place your SSL certificate and key inside:\n   - `certificate.crt`\n   - `key.pem`\n\n    ```bash\n    copy .\\.extras\\tls\\certificate.crt C:\\DockerVolumes\\postgres\\tls\\\n    copy .\\.extras\\tls\\key.pem C:\\DockerVolumes\\postgres\\tls\\\n    ```\n\n3. Create the directory `C:/DockerVolumes/postgres/sql/northwind`\n\n    ```bash\n    mkdir C:\\DockerVolumes\\postgres\\tls\n    ```\n\n4. Place the .sql files from `.extras/db/postgres/sql` inside:\n   - `create-db-northwind.sql`\n   - `create-schema-northwind.sql`\n   - `northwind.sql`\n\n    ```bash\n    copy .\\.extras\\db\\postgres\\sql\\create-db-northwind.sql C:\\DockerVolumes\\postgres\\sql\\northwind\\\n    copy .\\.extras\\db\\postgres\\sql\\create-schema-northwind.sql C:\\DockerVolumes\\postgres\\sql\\northwind\\\n    copy .\\.extras\\db\\postgres\\sql\\northwind.sql C:\\DockerVolumes\\postgres\\sql\\northwind\\\n    ```\n\nThese files are mounted read-only into the container and required for PostgreSQL to start with SSL.\n\nAll configuration files are located under:\n\n`.extras/db/postgres/`\n\n### Setup Mode – Root Access, No TLS\n\nUse this mode to fix file ownership and permissions. This runs the container without TLS and as the root user.\n\n#### Start the Container in Setup Mode\n\n```bash\ncd .extras/db/postgres/\ndocker compose up --build\n```\n\nThis uses only docker-compose.yml and ignores docker-compose.override.yml.\n\nOpen a Shell Inside the Container\n\n```bash\ndocker compose exec db bash\n```\n\nYou should now see a root@postgres prompt.\n\nRun Setup Commands\n\n```bash\nchown postgres:postgres /var/lib/postgresql/tablespace\nchown postgres:postgres /var/lib/postgresql/tablespace/northwind\nchown postgres:postgres /var/lib/postgresql/key.pem\nchown postgres:postgres /var/lib/postgresql/certificate.crt\nchmod 400 /var/lib/postgresql/key.pem\nchmod 400 /var/lib/postgresql/certificate.crt\nexit\n```\n\nStop the Container\n\n```bash\ndocker compose down\n```\n\n### Production Mode – Secure, With TLS\n\nNow that setup is complete, start the database securely using TLS and the postgres user.\n\nStart the Container in Production Mode\n\n```bash\ndocker compose -f docker-compose.yml up\n```\n\nThis automatically combines docker-compose.yml and docker-compose.override.yml.\n\nOpen a Shell Inside the Container\n\n```bash\ndocker compose exec db bash\n```\n\nYou should now be logged in as postgres@postgres.\n\nRun SQL Initialization Scripts\n\n```bash\npsql --dbname=postgres --username=postgres --file=/sql/create-db-northwind.sql\npsql --dbname=northwind --username=postgres --file=/sql/create-schema-northwind.sql\npsql --dbname=northwind --username=postgres --file=/sql/northwind.sql\nexit\n```\n\nStop the Container When Done\n\n```bash\ndocker compose down\n```\n\nSwitching Modes\nSetup Mode:\nUse --no-override to ignore the secure config:\n\n```bash\ndocker compose up\n```\n\nProduction Mode:\nJust run:\n\n```bash\ndocker compose -f docker-compose.yml up\n```\n\nThis flexible dual-mode approach allows for secure database operations while preserving the ability to make low-level system changes when necessary.\n\n## Migration\n\nAfter setting up the database dotnet ef migrations can be generated using these commands\n\n```bash\ndotnet ef database update --project src/Infrastructure --startup-project src/Api\n```\n\n```bash\ndotnet ef dbcontext scaffold \\\n  Npgsql.EntityFrameworkCore.PostgreSQL \\\n  --output-dir Entities \\\n  --context-dir Context \\\n  --context NorthwindContext \\\n  --project src/Infrastructure \\\n  --startup-project src/Api \\\n  --namespace Infrastructure.entity \\\n  --context-namespace Infrastructure.context \\\n  --schema northwind \\\n  --use-database-names \\\n  --no-onconfiguring \\\n  --force\n```\n\n## Architecture\n\n## Continuous Integration und Continuous Deployment (CI/CD)\n\nCI/CD is handled with Github Actions see the workflows in `.github/workflows`.\n\n## Tools\n\nUsing the .editorconfig file all projects can be formatted using\n\n```bash\ncd dotnet format .\\__Northwind__.sln --verbosity diagnostic\n```\n\n## Git Hooks\n\nThis repo ships with a pre-commit hook in **`.githooks/pre-commit`**. Enable it once per clone by running\n\n```bash\ngit config core.hooksPath .githooks\n```\n\nto enable the hook after cloning the project.\n[Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks)\nThe pre-commit checks for formatting/ linting and also if the solution compiles and can be build without errors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomoar%2Fnorthwind-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdomoar%2Fnorthwind-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomoar%2Fnorthwind-api/lists"}