# carlinhao/crud-employee architecture

> Architecture diagram of the GitHub repository carlinhao/crud-employee, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/carlinhao/crud-employee
- Repository: https://github.com/carlinhao/crud-employee

## Overview

This repository is an employee-management REST API with an MVC web client. The main workflow is a user browsing or changing employees: the web controller calls its HTTP client, which is configured against the API; API controllers invoke application use cases, which handle domain operations backed by Dapper repositories. The API also exposes department and occupation management, authentication and token refresh, and CSV export. Several implementation files are not excerpted, so unverified application-to-repository links are dashed; edges cite only shown calls or documented/configured relationships.

Main entry points: [`src/employers.application/UseCases/UserAuth`](https://github.com/carlinhao/crud-employee/tree/master/src/employers.application/UseCases/UserAuth) (Auth use cases), [`src/employers.api/Controllers/Employer/EmployerController.cs`](https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Controllers/Employer/EmployerController.cs) (Employee endpoints), [`src/Emp.Web/Controllers/Employee/EmployeeController.cs`](https://github.com/carlinhao/crud-employee/blob/master/src/Emp.Web/Controllers/Employee/EmployeeController.cs) (Employee screens), [`src/Emp.Web/Clients`](https://github.com/carlinhao/crud-employee/tree/master/src/Emp.Web/Clients) (HTTP clients)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web client"]
  node_employee_ui["Employee screens"]
  node_web_http["HTTP clients<br/>[Clients]"]
end

subgraph group_api["REST API"]
  node_api_host["API host<br/>[Program.cs]"]
  node_employee_api["Employee endpoints"]
  node_department_api["Department endpoints"]
  node_occupation_api["Occupation endpoints"]
  node_auth_api["Authentication endpoints<br/>[AuthController.cs]"]
  node_user_api["User creation<br/>[UserController.cs]"]
end

subgraph group_app["Application"]
  node_employee_cases["Employee use cases<br/>[Employers]"]
  node_department_cases["Department use cases<br/>[Departament]"]
  node_occupation_cases["Occupation use cases<br/>[Occupation]"]
  node_auth_cases["Auth use cases<br/>[UserAuth]"]
  node_token_generator["Token generation<br/>[TokenGenerate.cs]"]
  node_csv_export["CSV export<br/>[ExportCsvAsync.cs]"]
end

subgraph group_domain["Domain model"]
  node_domain_entities["Domain entities<br/>[Entities]"]
  node_domain_requests["Request models<br/>[Requests]"]
end

subgraph group_infra["Persistence"]
  node_employee_repo["Employee repository"]
  node_department_repo["Department repository"]
  node_occupation_repo["Occupation repository"]
  node_auth_repo["Auth repository"]
end

node_user(("Web user"))
node_sql_db[("SQL database")]

node_user -->|"uses"| node_employee_ui
node_employee_ui -->|"calls"| node_web_http
node_web_http -.->|"HTTP requests"| node_api_host
node_api_host -.->|"routes"| node_employee_api
node_employee_api -->|"invokes"| node_employee_cases
node_department_api -->|"invokes"| node_department_cases
node_occupation_api -->|"invokes"| node_occupation_cases
node_auth_api -->|"invokes"| node_auth_cases
node_user_api -->|"invokes"| node_auth_cases
node_employee_cases -.->|"uses repository"| node_employee_repo
node_department_cases -.->|"uses repository"| node_department_repo
node_occupation_cases -.->|"uses repository"| node_occupation_repo
node_auth_cases -->|"validates credentials"| node_auth_repo
node_auth_cases -.->|"generates tokens"| node_token_generator
node_employee_api -->|"requests export"| node_csv_export
node_employee_repo -->|"queries"| node_sql_db
node_department_repo -.->|"queries"| node_sql_db
node_occupation_repo -.->|"queries"| node_sql_db
node_auth_repo -->|"queries"| node_sql_db

click node_employee_ui "https://github.com/carlinhao/crud-employee/blob/master/src/Emp.Web/Controllers/Employee/EmployeeController.cs"
click node_web_http "https://github.com/carlinhao/crud-employee/tree/master/src/Emp.Web/Clients"
click node_api_host "https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Program.cs"
click node_employee_api "https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Controllers/Employer/EmployerController.cs"
click node_department_api "https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Controllers/Department/DepartmentController.cs"
click node_occupation_api "https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Controllers/Occupation/OccupationController.cs"
click node_auth_api "https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Controllers/Auth/AuthController.cs"
click node_user_api "https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Controllers/CreateUser/UserController.cs"
click node_employee_cases "https://github.com/carlinhao/crud-employee/tree/master/src/employers.application/UseCases/Employers"
click node_department_cases "https://github.com/carlinhao/crud-employee/tree/master/src/employers.application/UseCases/Departament"
click node_occupation_cases "https://github.com/carlinhao/crud-employee/tree/master/src/employers.application/UseCases/Occupation"
click node_auth_cases "https://github.com/carlinhao/crud-employee/tree/master/src/employers.application/UseCases/UserAuth"
click node_token_generator "https://github.com/carlinhao/crud-employee/blob/master/src/employers.application/UseCases/Token/TokenGenerate.cs"
click node_csv_export "https://github.com/carlinhao/crud-employee/blob/master/src/employers.application/UseCases/ExportReport/ExportCsvAsync.cs"
click node_domain_entities "https://github.com/carlinhao/crud-employee/tree/master/src/employers.domain/Entities"
click node_domain_requests "https://github.com/carlinhao/crud-employee/tree/master/src/employers.domain/Requests"
click node_employee_repo "https://github.com/carlinhao/crud-employee/blob/master/src/employers.infrastructure/Repositories/Employer/EmployerRepository.cs"
click node_department_repo "https://github.com/carlinhao/crud-employee/blob/master/src/employers.infrastructure/Repositories/Departament/DepartmentRepository.cs"
click node_occupation_repo "https://github.com/carlinhao/crud-employee/blob/master/src/employers.infrastructure/Repositories/Occupation/OccupationRepository.cs"
click node_auth_repo "https://github.com/carlinhao/crud-employee/blob/master/src/employers.infrastructure/Repositories/UserAuth/UserAuthRepository.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_employee_ui,node_web_http,node_user toneBlue
class node_api_host,node_employee_api,node_department_api,node_occupation_api,node_auth_api,node_user_api,node_sql_db toneAmber
class node_employee_cases,node_department_cases,node_occupation_cases,node_auth_cases,node_token_generator,node_csv_export toneMint
class node_domain_entities,node_domain_requests toneRose
class node_employee_repo,node_department_repo,node_occupation_repo,node_auth_repo toneIndigo
```

## Components

### Web client

- [Employee screens](https://github.com/carlinhao/crud-employee/blob/master/src/Emp.Web/Controllers/Employee/EmployeeController.cs): `src/Emp.Web/Controllers/Employee/EmployeeController.cs`
- [HTTP clients](https://github.com/carlinhao/crud-employee/tree/master/src/Emp.Web/Clients): `src/Emp.Web/Clients`

### REST API

- [API host](https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Program.cs): `src/employers.api/Program.cs`
- [Employee endpoints](https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Controllers/Employer/EmployerController.cs): `src/employers.api/Controllers/Employer/EmployerController.cs`
- [Department endpoints](https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Controllers/Department/DepartmentController.cs): `src/employers.api/Controllers/Department/DepartmentController.cs`
- [Occupation endpoints](https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Controllers/Occupation/OccupationController.cs): `src/employers.api/Controllers/Occupation/OccupationController.cs`
- [Authentication endpoints](https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Controllers/Auth/AuthController.cs): `src/employers.api/Controllers/Auth/AuthController.cs`
- [User creation](https://github.com/carlinhao/crud-employee/blob/master/src/employers.api/Controllers/CreateUser/UserController.cs): `src/employers.api/Controllers/CreateUser/UserController.cs`

### Application

- [Employee use cases](https://github.com/carlinhao/crud-employee/tree/master/src/employers.application/UseCases/Employers): `src/employers.application/UseCases/Employers`
- [Department use cases](https://github.com/carlinhao/crud-employee/tree/master/src/employers.application/UseCases/Departament): `src/employers.application/UseCases/Departament`
- [Occupation use cases](https://github.com/carlinhao/crud-employee/tree/master/src/employers.application/UseCases/Occupation): `src/employers.application/UseCases/Occupation`
- [Auth use cases](https://github.com/carlinhao/crud-employee/tree/master/src/employers.application/UseCases/UserAuth): `src/employers.application/UseCases/UserAuth`
- [Token generation](https://github.com/carlinhao/crud-employee/blob/master/src/employers.application/UseCases/Token/TokenGenerate.cs): `src/employers.application/UseCases/Token/TokenGenerate.cs`
- [CSV export](https://github.com/carlinhao/crud-employee/blob/master/src/employers.application/UseCases/ExportReport/ExportCsvAsync.cs): `src/employers.application/UseCases/ExportReport/ExportCsvAsync.cs`

### Domain model

- [Domain entities](https://github.com/carlinhao/crud-employee/tree/master/src/employers.domain/Entities): `src/employers.domain/Entities`
- [Request models](https://github.com/carlinhao/crud-employee/tree/master/src/employers.domain/Requests): `src/employers.domain/Requests`

### Persistence

- [Employee repository](https://github.com/carlinhao/crud-employee/blob/master/src/employers.infrastructure/Repositories/Employer/EmployerRepository.cs): `src/employers.infrastructure/Repositories/Employer/EmployerRepository.cs`
- [Department repository](https://github.com/carlinhao/crud-employee/blob/master/src/employers.infrastructure/Repositories/Departament/DepartmentRepository.cs): `src/employers.infrastructure/Repositories/Departament/DepartmentRepository.cs`
- [Occupation repository](https://github.com/carlinhao/crud-employee/blob/master/src/employers.infrastructure/Repositories/Occupation/OccupationRepository.cs): `src/employers.infrastructure/Repositories/Occupation/OccupationRepository.cs`
- [Auth repository](https://github.com/carlinhao/crud-employee/blob/master/src/employers.infrastructure/Repositories/UserAuth/UserAuthRepository.cs): `src/employers.infrastructure/Repositories/UserAuth/UserAuthRepository.cs`

### Other components

- **Web user**
- **SQL database**

## Connections

- Web user → Employee screens: uses (evidence: `src/Emp.Web/Controllers/Employee/EmployeeController.cs`)
- Employee screens → HTTP clients: calls (evidence: `src/Emp.Web/Controllers/Employee/EmployeeController.cs`)
- HTTP clients → API host: HTTP requests
- API host → Employee endpoints: routes (evidence: `src/employers.api/Program.cs`)
- Employee endpoints → Employee use cases: invokes (evidence: `src/employers.api/Controllers/Employer/EmployerController.cs`)
- Department endpoints → Department use cases: invokes (evidence: `src/employers.api/Controllers/Department/DepartmentController.cs`)
- Occupation endpoints → Occupation use cases: invokes (evidence: `src/employers.api/Controllers/Occupation/OccupationController.cs`)
- Authentication endpoints → Auth use cases: invokes (evidence: `src/employers.api/Controllers/Auth/AuthController.cs`)
- User creation → Auth use cases: invokes (evidence: `src/employers.api/Controllers/CreateUser/UserController.cs`)
- Employee use cases → Employee repository: uses repository
- Department use cases → Department repository: uses repository
- Occupation use cases → Occupation repository: uses repository
- Auth use cases → Auth repository: validates credentials (evidence: `src/employers.application/UseCases/UserAuth/UserAuthUseCaseAsync.cs`)
- Auth use cases → Token generation: generates tokens
- Employee endpoints → CSV export: requests export (evidence: `src/employers.api/Controllers/Employer/EmployerController.cs`)
- Employee repository → SQL database: queries (evidence: `src/employers.infrastructure/Repositories/Employer/EmployerRepository.cs`)
- Department repository → SQL database: queries
- Occupation repository → SQL database: queries
- Auth repository → SQL database: queries (evidence: `src/employers.infrastructure/Repositories/UserAuth/UserAuthRepository.cs`)
