# aman-devcode1/ems architecture

> Architecture diagram of the GitHub repository aman-devcode1/ems, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aman-devcode1/ems
- Repository: https://github.com/aman-devcode1/ems

## Overview

EMS is an employee-management application with an Angular client and a .NET Clean Architecture API. Users register or sign in, complete OTP verification where required, receive tokens, and then use role-protected employee, admin, manager, and master-data capabilities. The backend also supports refresh-token rotation, account recovery, and email OTP delivery. The graph includes documented flows and source-index-supported dependencies; unsampled frontend/API wiring and some OTP implementation details are not asserted as direct calls.

Main entry points: [`Backend/EMS.Services/Services/AuthService.cs`](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Services/Services/AuthService.cs) (Authentication), [`Backend/EMS.Infrastructure/Repositories/EmployeeRepository.cs`](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Infrastructure/Repositories/EmployeeRepository.cs) (Repositories), [`Frontend/src/app/app.routes.ts`](https://github.com/aman-devcode1/ems/blob/main/Frontend/src/app/app.routes.ts) (Routes and Guards), [`Backend/EMS.API/Controllers/AdminController.cs`](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.API/Controllers/AdminController.cs) (Admin Endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Angular Client"]
  node_authui["Auth Screens<br/>[login.ts]"]
  node_otpui["OTP Screens<br/>[verify-otp.ts]"]
  node_employeeui["Employee Workspace<br/>[employee-list.ts]"]
  node_adminui["Admin Workspace<br/>[master-data.ts]"]
  node_routing["Routes and Guards<br/>[app.routes.ts]"]
end

subgraph group_api["API Boundary"]
  node_authapi["Auth Endpoints<br/>[AuthController.cs]"]
  node_adminapi["Admin Endpoints<br/>[AdminController.cs]"]
  node_employeeapi["Employee Endpoints"]
end

subgraph group_domain["Business Services"]
  node_auth["Authentication<br/>[AuthService.cs]"]
  node_employees["Employee Management<br/>[EmployeeService.cs]"]
  node_otp["OTP Processing<br/>[OtpService.cs]"]
  node_master["Department and Designation"]
end

subgraph group_data["Persistence"]
  node_repos["Repositories"]
  node_database[("Application Database<br/>[AppDbContext.cs]")]
end

subgraph group_integrations["Email and Cleanup"]
  node_emailqueue["Email Queue"]
  node_email["Email Delivery<br/>[EmailService.cs]"]
  node_cleanup["Employee Cleanup"]
end

node_user(("Users"))

node_user -->|"starts sign-in"| node_authui
node_authui -->|"uses routes"| node_routing
node_otpui -->|"uses routes"| node_routing
node_employeeui -->|"protected by"| node_routing
node_adminui -->|"protected by"| node_routing
node_user -->|"sends requests"| node_authapi
node_authapi -->|"delegates to"| node_auth
node_adminapi -->|"delegates to"| node_auth
node_employeeapi -->|"delegates to"| node_employees
node_adminapi -->|"delegates to"| node_master
node_auth -->|"uses OTP service"| node_otp
node_auth -->|"uses repositories"| node_repos
node_employees -->|"uses repository"| node_repos
node_master -.->|"uses repositories"| node_repos
node_repos -->|"queries and saves"| node_database
node_auth -.->|"queues OTP email"| node_emailqueue
node_emailqueue -.->|"dispatches email"| node_email
node_cleanup -.->|"cleans scheduled records"| node_database

click node_authui "https://github.com/aman-devcode1/ems/blob/main/Frontend/src/app/features/auth/login/login.ts"
click node_otpui "https://github.com/aman-devcode1/ems/blob/main/Frontend/src/app/features/auth/verify-otp/verify-otp.ts"
click node_employeeui "https://github.com/aman-devcode1/ems/blob/main/Frontend/src/app/features/employee-management/employee-list/employee-list.ts"
click node_adminui "https://github.com/aman-devcode1/ems/blob/main/Frontend/src/app/features/admin/master-data/master-data.ts"
click node_routing "https://github.com/aman-devcode1/ems/blob/main/Frontend/src/app/app.routes.ts"
click node_authapi "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.API/Controllers/AuthController.cs"
click node_adminapi "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.API/Controllers/AdminController.cs"
click node_employeeapi "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.API/Controllers/EmployeesController.cs"
click node_auth "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Services/Services/AuthService.cs"
click node_employees "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Services/Services/EmployeeService.cs"
click node_otp "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Services/Services/OtpService.cs"
click node_master "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Services/Services/DepartmentService.cs"
click node_repos "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Infrastructure/Repositories/EmployeeRepository.cs"
click node_database "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Infrastructure/Data/AppDbContext.cs"
click node_emailqueue "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Infrastructure/ExternalServices/BackgroundEmailQueue.cs"
click node_email "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Infrastructure/ExternalServices/EmailService.cs"
click node_cleanup "https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.API/BackgroundServices/EmployeeCleanupService.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_authui,node_otpui,node_employeeui,node_adminui,node_routing,node_user toneBlue
class node_authapi,node_adminapi,node_employeeapi toneAmber
class node_auth,node_employees,node_otp,node_master toneMint
class node_repos,node_database toneRose
class node_emailqueue,node_email,node_cleanup toneIndigo
```

## Components

### Angular Client

- [Auth Screens](https://github.com/aman-devcode1/ems/blob/main/Frontend/src/app/features/auth/login/login.ts): `Frontend/src/app/features/auth/login/login.ts`
- [OTP Screens](https://github.com/aman-devcode1/ems/blob/main/Frontend/src/app/features/auth/verify-otp/verify-otp.ts): `Frontend/src/app/features/auth/verify-otp/verify-otp.ts`
- [Employee Workspace](https://github.com/aman-devcode1/ems/blob/main/Frontend/src/app/features/employee-management/employee-list/employee-list.ts): `Frontend/src/app/features/employee-management/employee-list/employee-list.ts`
- [Admin Workspace](https://github.com/aman-devcode1/ems/blob/main/Frontend/src/app/features/admin/master-data/master-data.ts): `Frontend/src/app/features/admin/master-data/master-data.ts`
- [Routes and Guards](https://github.com/aman-devcode1/ems/blob/main/Frontend/src/app/app.routes.ts): `Frontend/src/app/app.routes.ts`

### API Boundary

- [Auth Endpoints](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.API/Controllers/AuthController.cs): `Backend/EMS.API/Controllers/AuthController.cs`
- [Admin Endpoints](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.API/Controllers/AdminController.cs): `Backend/EMS.API/Controllers/AdminController.cs`
- [Employee Endpoints](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.API/Controllers/EmployeesController.cs): `Backend/EMS.API/Controllers/EmployeesController.cs`

### Business Services

- [Authentication](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Services/Services/AuthService.cs): `Backend/EMS.Services/Services/AuthService.cs`
- [Employee Management](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Services/Services/EmployeeService.cs): `Backend/EMS.Services/Services/EmployeeService.cs`
- [OTP Processing](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Services/Services/OtpService.cs): `Backend/EMS.Services/Services/OtpService.cs`
- [Department and Designation](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Services/Services/DepartmentService.cs): `Backend/EMS.Services/Services/DepartmentService.cs`

### Persistence

- [Repositories](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Infrastructure/Repositories/EmployeeRepository.cs): `Backend/EMS.Infrastructure/Repositories/EmployeeRepository.cs`
- [Application Database](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Infrastructure/Data/AppDbContext.cs): `Backend/EMS.Infrastructure/Data/AppDbContext.cs`

### Email and Cleanup

- [Email Queue](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Infrastructure/ExternalServices/BackgroundEmailQueue.cs): `Backend/EMS.Infrastructure/ExternalServices/BackgroundEmailQueue.cs`
- [Email Delivery](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.Infrastructure/ExternalServices/EmailService.cs): `Backend/EMS.Infrastructure/ExternalServices/EmailService.cs`
- [Employee Cleanup](https://github.com/aman-devcode1/ems/blob/main/Backend/EMS.API/BackgroundServices/EmployeeCleanupService.cs): `Backend/EMS.API/BackgroundServices/EmployeeCleanupService.cs`

### Other components

- **Users**

## Connections

- Users → Auth Screens: starts sign-in (evidence: `README.md`)
- Auth Screens → Routes and Guards: uses routes (evidence: `Frontend/src/app/app.routes.ts`)
- OTP Screens → Routes and Guards: uses routes (evidence: `Frontend/src/app/app.routes.ts`)
- Employee Workspace → Routes and Guards: protected by (evidence: `Frontend/src/app/app.routes.ts`)
- Admin Workspace → Routes and Guards: protected by (evidence: `Frontend/src/app/app.routes.ts`)
- Users → Auth Endpoints: sends requests (evidence: `README.md`)
- Auth Endpoints → Authentication: delegates to (evidence: `Backend/EMS.API/Controllers/AuthController.cs`)
- Admin Endpoints → Authentication: delegates to (evidence: `Backend/EMS.API/Controllers/AdminController.cs`)
- Employee Endpoints → Employee Management: delegates to (evidence: `Backend/EMS.API/Controllers/EmployeesController.cs`)
- Admin Endpoints → Department and Designation: delegates to (evidence: `Backend/EMS.API/Controllers/AdminController.cs`)
- Authentication → OTP Processing: uses OTP service (evidence: `Backend/EMS.Services/Services/AuthService.cs`)
- Authentication → Repositories: uses repositories (evidence: `Backend/EMS.Services/Services/AuthService.cs`)
- Employee Management → Repositories: uses repository (evidence: `Backend/EMS.Services/Services/EmployeeService.cs`)
- Department and Designation → Repositories: uses repositories
- Repositories → Application Database: queries and saves (evidence: `Backend/EMS.Infrastructure/Repositories/EmployeeRepository.cs`)
- Authentication → Email Queue: queues OTP email
- Email Queue → Email Delivery: dispatches email
- Employee Cleanup → Application Database: cleans scheduled records (evidence: `Backend/EMS.API/BackgroundServices/EmployeeCleanupService.cs`)
