Skip to content

mgierschdev/dotnet-angular-crud-reference

Repository files navigation

WebApiAngularTask

1. What this repository is

A sample full-stack CRUD application with a .NET 6 Web API backend and an Angular frontend UI; it is a demo project, not production-hardened. Evidence: Backend/UserBackend/API/Program.cs, Frontend/src/app/app.component.ts, Backend/UserBackend/API/API.csproj, Frontend/package.json.

2. Why it exists

To demonstrate a layered backend (API/Domain/Infrastructure) and a simple Angular Material UI that consumes the API, intended as a CRUD reference implementation. Evidence: Backend/UserBackend/UserBackend.sln, Backend/UserBackend/Domain, Backend/UserBackend/Infrastructure, Frontend/src/app.

3. Quickstart

Prerequisites:

  • .NET SDK 6.0 (from Backend/UserBackend/API/API.csproj).
  • Node.js 16 (from Frontend/Dockerfile).
  • Docker (optional, from docker-compose.yml, Backend/Dockerfile, Frontend/Dockerfile).

Run locally:

  • Backend: cd Backend/UserBackend/API && dotnet run.
  • Frontend: cd Frontend && npm install && npm start.

Run tests:

  • Frontend: cd Frontend && npm test (Karma). Evidence: Frontend/package.json.
  • Backend: Unknown; no test project found.

Troubleshooting:

  • docker-compose.yml uses FrontEnd/ but the folder is Frontend/; update the path if Docker builds fail. Evidence: docker-compose.yml, Frontend/.
  • Frontend API URLs are hard-coded to http://localhost:7066, which will not resolve inside Docker without network configuration. Evidence: Frontend/src/app/app.component.ts.

4. Architecture at a glance

flowchart TD
  Frontend[Angular Frontend] --> API[.NET 6 Web API]
  API --> Domain[Domain Validation]
  API --> Infra[Infrastructure]
  Infra --> InMemoryDB[EF Core InMemory DB]
Loading

The frontend calls API endpoints, which delegate validation to Domain and persistence to Infrastructure using an in-memory EF Core database. Evidence: Frontend/src/app/app.component.ts, Backend/UserBackend/API/Controllers/UserController.cs, Backend/UserBackend/Domain/Validator/UserValidator.cs, Backend/UserBackend/Infrastructure/ApiContext.cs.

5. Core components

  • Backend/UserBackend/API: Web API entrypoint and controllers.
  • Backend/UserBackend/Domain: DTOs, validation, and utilities.
  • Backend/UserBackend/Infrastructure: EF Core models, repository, and context.
  • Frontend/src/app: Angular components and dialogs.
  • docker-compose.yml, Backend/Dockerfile, Frontend/Dockerfile: container orchestration and runtime.

6. Interfaces

API endpoints (ASP.NET Core):

  • GET /User/All
  • GET /User/Posts
  • GET /User/Posts/{id}
  • POST /User/Create
  • POST /User/Update
  • DELETE /User/Delete Evidence: Backend/UserBackend/API/Controllers/UserController.cs.

Swagger UI (dev):

  • Launch URL swagger with application URLs http://0.0.0.0:7066 and http://0.0.0.0:5233 (from Backend/UserBackend/API/Properties/launchSettings.json).

Sample request bodies: Unknown; would be confirmed by API examples or documentation (none found).

7. Configuration

  • Backend app settings: Backend/UserBackend/API/appsettings.json, Backend/UserBackend/API/appsettings.Development.json.
  • Backend launch profiles: Backend/UserBackend/API/Properties/launchSettings.json.
  • Frontend API base URLs: Frontend/src/app/app.component.ts.
  • Docker composition: docker-compose.yml.
  • CORS policy: WithOrigins("*") in Backend/UserBackend/API/Program.cs.
  • No .env files are present.

Secrets and injection:

  • No secret injection configured; no credential values present in appsettings*.json.

8. Dependencies and external services

Backend packages:

  • Swashbuckle (Swagger) in Backend/UserBackend/API/API.csproj.
  • FluentValidation in Backend/UserBackend/Domain/Domain.csproj.
  • EF Core + EF Core InMemory in Backend/UserBackend/Infrastructure/Infrastructure.csproj.

Frontend packages:

  • Angular 15, Angular Material, RxJS, fluentvalidation-ts in Frontend/package.json.

Database:

  • EF Core InMemory provider (no external DB). Evidence: Backend/UserBackend/Infrastructure/ApiContext.cs.

External services:

  • None configured.

9. Quality and safety

Tests:

  • Angular tests via Karma (npm test). Evidence: Frontend/package.json, Frontend/src/app/*.spec.ts.
  • Backend tests: None found.

CI:

  • None found.

Linting/formatting:

  • None configured (no eslint, prettier, or dotnet format configs found).

Static analysis/security:

  • None found.

Verification:

  • test -f WebApiAngularTask/docker-compose.yml

10. Sensitive information review

Status: Clean

Reviewed areas:

  • Backend/UserBackend/API/Program.cs
  • Backend/UserBackend/API/Controllers/UserController.cs
  • Backend/UserBackend/API/appsettings.json
  • Backend/UserBackend/API/appsettings.Development.json
  • Backend/UserBackend/API/Properties/launchSettings.json
  • Backend/UserBackend/Domain/Model/APIUser.cs
  • Backend/UserBackend/Domain/Validator/UserValidator.cs
  • Backend/UserBackend/Domain/Util/APIResponse.cs
  • Backend/UserBackend/Domain/Util/Enums.cs
  • Backend/UserBackend/Domain/Util/Util.cs
  • Backend/UserBackend/Infrastructure/ApiContext.cs
  • Backend/UserBackend/Infrastructure/IUserRepository.cs
  • Backend/UserBackend/Infrastructure/UserRepository.cs
  • Backend/UserBackend/Infrastructure/Model/User.cs
  • Backend/UserBackend/Infrastructure/Model/Post.cs
  • Backend/UserBackend/Infrastructure/Util/Util.cs
  • Frontend/src/app/app.component.ts
  • Frontend/src/app/grid-component/grid-component.component.ts
  • Frontend/src/app/table-component/table-component.component.ts
  • Frontend/src/app/view-dialog/view-dialog.component.ts
  • docker-compose.yml
  • Backend/Dockerfile
  • Frontend/Dockerfile
  • Frontend/angular.json
  • Frontend/tsconfig.json
  • Frontend/tsconfig.app.json
  • Frontend/tsconfig.spec.json
  • Frontend/package.json
  • README.md

Findings:

  • None.

Actions taken:

  • None.

Notes:

  • Binary images in img/ were not inspected.

11. What’s missing

Documentation:

  • P1/S: Docker networking and API base URL guidance. Next action: document how to configure frontend API URLs for Docker.

Tests:

  • P1/M: Backend unit/integration tests. Next action: add a test project and dotnet test instructions.

Security:

  • P1/S: CORS policy is permissive. Next action: restrict origins in Backend/UserBackend/API/Program.cs for non-demo use.

Reliability:

  • P2/M: Persistence beyond in-memory DB. Next action: add a real database provider and configuration.

Operations:

  • P2/M: CI pipeline for build/test. Next action: add a GitHub Actions workflow for backend and frontend builds.

Developer experience:

  • P2/S: No linting/formatting scripts. Next action: add eslint/prettier and dotnet format guidance.

12. How this repository is useful

It provides a working reference for a .NET 6 Web API with layered architecture and an Angular Material frontend consuming CRUD endpoints. Evidence: Backend/UserBackend/UserBackend.sln, Frontend/src/app/view-dialog/view-dialog.component.ts.

13. Automation hooks

Project type: Full-stack demo (ASP.NET Core + Angular) Primary domain: User and post CRUD Core entities: Users, Posts (Backend/UserBackend/Infrastructure/Model/User.cs, Backend/UserBackend/Infrastructure/Model/Post.cs) Extension points: Validation rules (Backend/UserBackend/Domain/Validator/UserValidator.cs), API endpoints (Backend/UserBackend/API/Controllers/UserController.cs), UI dialogs and tables (Frontend/src/app/view-dialog, Frontend/src/app/table-component). Areas safe to modify: Domain validation and UI components. Areas requiring caution and why: Backend/UserBackend/Infrastructure/ApiContext.cs (database provider selection), Frontend/src/app/app.component.ts (hard-coded API URLs). Canonical commands:

  • build: cd Frontend && npm run build; cd Backend/UserBackend/API && dotnet build
  • run: cd Frontend && npm start; cd Backend/UserBackend/API && dotnet run; docker compose up
  • test: cd Frontend && npm test; backend tests not defined

About

WebApi (.Net6) and a Angular CRUD Task

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published