# joaovictorbarrera/assetmanagementsystem architecture

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

- Interactive diagram: https://gitdiagram.com/joaovictorbarrera/assetmanagementsystem
- Repository: https://github.com/joaovictorbarrera/assetmanagementsystem

## Overview

1. **High-level shape**
   - This repository is a two-part system: an **Angular frontend** in `client/` and an **ASP.NET Core API backend** in `server/`.
   - The frontend is the user-facing portal; the backend owns business rules, authentication, persistence, and data shaping.

2. **Frontend application shell**
   - The Angular app is organized around a root app config/routes setup (`app.config.ts`, `app.routes.ts`) and a shared main layout (`core/layout/main-layout`).
   - The layout splits into persistent navigation pieces like **navbar** and **sidebar**, with page content swapped by routing.

3. **Frontend feature pages**
   - The main user flows are separated into pages for **dashboard**, **inventory**, **requests**, **review**, **users**, **login**, and **unauthorized**.
   - Each page has its own local table/row components, which suggests the UI is table-driven and feature-specific rather than a single generic grid.

4. **Frontend reusable UI layer**
   - Shared components under `core/components` cover common interactions: drawers for create/detail forms, search bar, dropdown, submit button, table header/pagination/wrapper, page header/wrapper, and a loading spinner.
   - This indicates a design centered on reusable presentation blocks and slide-out detail/edit experiences.

5. **Frontend data contract layer**
   - The Angular client defines DTOs under `core/DTOs` for **assets**, **checkout requests**, **users**, and shared pagination structures.
   - These DTOs mirror the backend response/request shapes, making the API contract an explicit architectural boundary.

6. **Frontend state, behavior, and cross-cutting concerns**
   - API access is split into dedicated services under `core/services/api` for assets, auth, checkout requests, and users.
   - Event services (`core/services/events`) likely coordinate refresh/update signals between drawers, tables, and pages; utility services handle drawers and page loading.
   - Guards (`auth.guard.ts`, `role.guard.ts`) and the HTTP interceptor enforce authentication and role-based access on the client side.

7. **Backend API boundary**
   - The backend exposes REST-style controllers for **assets**, **auth**, **checkout requests**, **users**, plus an `EchoController` for basic connectivity/testing.
   - `ApiControllerBase` suggests a shared controller foundation for consistent routing or response handling.

8. **Backend application/services layer**
   - Business logic is centralized in `Services/` with separate services for assets, checkout requests, users, and token generation.
   - `ServiceResult` indicates service methods return structured success/failure outcomes instead of throwing domain details directly through controllers.

9. **Backend repository/data access layer**
   - `Models/Repositories` provides repositories for assets, checkout requests, and users, which sit beneath the services.
   - This creates a clear separation: controllers handle HTTP, services enforce workflows, repositories handle persistence queries.

10. **Backend domain model**
   - Core entities are `Asset`, `AssetHistory`, `CheckoutRequest`, and `User`.
   - Enums define business state: asset category, condition, status; checkout request status and type; and user role.

11. **Persistence and schema management**
   - `AppDbContext`, EF Core migrations, and seed data show a database-backed system with versioned schema evolution.
   - Seed migrations populate initial users, assets, and requests, so the app likely boots with meaningful demo/operational data.

12. **Auth and authorization flow**
   - Authentication is API-backed via `AuthController`, `LoginRequest`, and `TokenDto`, with token generation handled by `TokenService`.
   - Authorization is role-aware on both sides: backend roles/enforcement helpers and frontend auth/role guards ensure restricted areas like user/admin workflows are protected.

13. **Primary business flows**
   - **Assets**: list, create, update fields/status/category/condition, view detail and history, and fetch available assets.
   - **Checkout requests**: create requests, list/filter them, assign assets, and inspect request detail.
   - **Users**: create users, list users, and update active/role state.
   - The dashboard/inventory/review pages are likely different views over these same domain objects and states.

14. **Data flow between tiers**
   - User actions start in Angular pages/components, invoke API services, pass DTOs to the backend, and receive paginated or detail responses.
   - The backend transforms entities into response DTOs/projections, applies business rules, persists through EF Core, and returns shaped data for table/drawer rendering.

15. **Deployment/runtime boundaries**
   - The frontend is deployed on **Vercel** and the API on **Railway**, per the README links.
   - The backend is an ASP.NET Core application with Swagger exposed for API exploration, while the client is an Angular app built and served separately.

Main entry points: [`client/src/app/app.config.ts`](https://github.com/joaovictorbarrera/assetmanagementsystem/blob/main/client/src/app/app.config.ts) (App shell), [`client/src/app/core/services`](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/services) (API services), [`client/src/app/core/components`](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/components) (Shared UI), [`server/Services`](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/Services) (Services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Angular client"]
  node_client_app["App shell<br/>angular bootstrap<br/>[app.config.ts]"]
  node_client_layout["Main layout<br/>shell layout"]
  node_client_pages_dashboard["Dashboard<br/>feature page"]
  node_client_pages_inventory["Inventory<br/>feature page"]
  node_client_pages_requests["Requests<br/>feature page"]
  node_client_pages_review["Review<br/>feature page"]
  node_client_pages_users["Users<br/>feature page"]
  node_client_auth_pages["Login & access<br/>auth pages"]
  node_client_shared_ui["Shared UI<br/>reusable components"]
  node_client_contracts["DTOs<br/>api contracts"]
  node_client_services["API services<br/>service layer"]
  node_client_security{{"Guards & auth<br/>client security"}}
end

subgraph group_backend["ASP.NET Core API"]
  node_server_controllers["Controllers<br/>rest endpoints"]
  node_server_services["Services<br/>business logic"]
  node_server_repos["Repositories<br/>data access"]
  node_server_domain["Domain model<br/>entities & enums"]
  node_server_dtos["Server DTOs<br/>request/response models"]
  node_server_auth{{"Auth flow<br/>token auth"}}
  node_server_db[("Db context<br/>ef core persistence<br/>[AppDbContext.cs]")]
  node_server_runtime["Hosting setup<br/>app host<br/>[Program.cs]"]
end

node_client_app -->|"renders"| node_client_layout
node_client_app -->|"routes to"| node_client_pages_dashboard
node_client_app -->|"routes to"| node_client_pages_inventory
node_client_app -->|"routes to"| node_client_pages_requests
node_client_app -->|"routes to"| node_client_pages_review
node_client_app -->|"routes to"| node_client_pages_users
node_client_app -->|"routes to"| node_client_auth_pages
node_client_layout -->|"uses"| node_client_shared_ui
node_client_pages_dashboard -->|"loads data via"| node_client_services
node_client_pages_inventory -->|"loads data via"| node_client_services
node_client_pages_requests -->|"loads data via"| node_client_services
node_client_pages_review -->|"loads data via"| node_client_services
node_client_pages_users -->|"loads data via"| node_client_services
node_client_pages_dashboard -->|"composes"| node_client_shared_ui
node_client_pages_inventory -->|"composes"| node_client_shared_ui
node_client_pages_requests -->|"composes"| node_client_shared_ui
node_client_pages_review -->|"composes"| node_client_shared_ui
node_client_pages_users -->|"composes"| node_client_shared_ui
node_client_services -->|"uses"| node_client_contracts
node_client_security -->|"protects routes"| node_client_app
node_server_runtime -->|"wires"| node_server_controllers
node_server_controllers -->|"delegates to"| node_server_services
node_server_services -->|"queries"| node_server_repos
node_server_repos -->|"persists via"| node_server_db
node_server_services -->|"operates on"| node_server_domain
node_server_controllers -->|"accepts/returns"| node_server_dtos
node_server_services -->|"issues tokens"| node_server_auth
node_client_services -.->|"calls API"| node_server_controllers
node_client_auth_pages -.->|"authenticates against"| node_server_auth

click node_client_app "https://github.com/joaovictorbarrera/assetmanagementsystem/blob/main/client/src/app/app.config.ts"
click node_client_layout "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/layout/main-layout"
click node_client_pages_dashboard "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/dashboard"
click node_client_pages_inventory "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/inventory"
click node_client_pages_requests "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/requests"
click node_client_pages_review "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/review"
click node_client_pages_users "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/users"
click node_client_auth_pages "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/login"
click node_client_shared_ui "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/components"
click node_client_contracts "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/DTOs"
click node_client_services "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/services"
click node_client_security "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/guards"
click node_server_controllers "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/Controllers"
click node_server_services "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/Services"
click node_server_repos "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/Models/Repositories"
click node_server_domain "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/Models/Entities"
click node_server_dtos "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/DTOs"
click node_server_auth "https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/DTOs/Auth"
click node_server_db "https://github.com/joaovictorbarrera/assetmanagementsystem/blob/main/server/Data/AppDbContext.cs"
click node_server_runtime "https://github.com/joaovictorbarrera/assetmanagementsystem/blob/main/server/Program.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_client_app,node_client_layout,node_client_pages_dashboard,node_client_pages_inventory,node_client_pages_requests,node_client_pages_review,node_client_pages_users,node_client_auth_pages,node_client_shared_ui,node_client_contracts,node_client_services,node_client_security toneBlue
class node_server_controllers,node_server_services,node_server_repos,node_server_domain,node_server_dtos,node_server_auth,node_server_db,node_server_runtime toneAmber
```

## Components

### Angular client

User-facing SPA, shared UI, page flows, and API contract/services.

- [App shell](https://github.com/joaovictorbarrera/assetmanagementsystem/blob/main/client/src/app/app.config.ts): angular bootstrap · Root app config, routes, and global shell entrypoints. · `client/src/app/app.config.ts`
- [Main layout](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/layout/main-layout): shell layout · Persistent navbar/sidebar frame around routed pages. · `client/src/app/core/layout/main-layout`
- [Dashboard](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/dashboard): feature page · Asset overview and summary table view. · `client/src/app/pages/dashboard`
- [Inventory](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/inventory): feature page · Asset inventory browsing and row actions. · `client/src/app/pages/inventory`
- [Requests](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/requests): feature page · Checkout request list and management flow. · `client/src/app/pages/requests`
- [Review](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/review): feature page · Request review/approval workflow view. · `client/src/app/pages/review`
- [Users](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/users): feature page · User administration and role/active-state management. · `client/src/app/pages/users`
- [Login & access](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/pages/login): auth pages · Login and unauthorized access screens. · `client/src/app/pages/login`
- [Shared UI](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/components): reusable components · Drawers, tables, headers, pagination, search, dropdowns, and loading states. · `client/src/app/core/components`
- [DTOs](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/DTOs): api contracts · Client-side request/response models for assets, checkout requests, users, and pagination. · `client/src/app/core/DTOs`
- [API services](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/services): service layer · Typed API clients plus event/util services for refresh, drawer, and loading coordination. · `client/src/app/core/services`
- [Guards & auth](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/client/src/app/core/guards): client security · Route guards and HTTP interceptor enforcing authentication and roles. · `client/src/app/core/guards`

### ASP.NET Core API

REST API, business services, repositories, and persistence.

- [Controllers](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/Controllers): rest endpoints · HTTP boundary for assets, auth, checkout requests, users, and echo. · `server/Controllers`
- [Services](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/Services): business logic · Workflow and validation layer for assets, checkout requests, users, and tokens. · `server/Services`
- [Repositories](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/Models/Repositories): data access · Persistence-focused repositories for domain entities. · `server/Models/Repositories`
- [Domain model](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/Models/Entities): entities & enums · Core entities and business states for assets, requests, and users. · `server/Models/Entities`
- [Server DTOs](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/DTOs): request/response models · API request, response, and projection shapes used at the HTTP boundary. · `server/DTOs`
- [Auth flow](https://github.com/joaovictorbarrera/assetmanagementsystem/tree/main/server/DTOs/Auth): token auth · Login request handling and token generation/role claims. · `server/DTOs/Auth`
- [Db context](https://github.com/joaovictorbarrera/assetmanagementsystem/blob/main/server/Data/AppDbContext.cs): ef core persistence · EF Core context, migrations, and seed data for schema and initial records. · `server/Data/AppDbContext.cs`
- [Hosting setup](https://github.com/joaovictorbarrera/assetmanagementsystem/blob/main/server/Program.cs): app host · Program startup and service/web app extensions wiring the API runtime. · `server/Program.cs`

## Connections

- App shell → Main layout: renders · The routed app is framed by the persistent main layout.
- App shell → Dashboard: routes to · Root routes include the dashboard page.
- App shell → Inventory: routes to · Root routes include the inventory page.
- App shell → Requests: routes to · Root routes include the requests page.
- App shell → Review: routes to · Root routes include the review page.
- App shell → Users: routes to · Root routes include the users page.
- App shell → Login & access: routes to · Root routes include login and unauthorized screens.
- Main layout → Shared UI: uses · Layout composes shared navigation and page primitives.
- Dashboard → API services: loads data via · Dashboard page fetches assets and refresh signals through services.
- Inventory → API services: loads data via · Inventory page uses asset API and UI coordination services.
- Requests → API services: loads data via · Requests page uses checkout request API and events services.
- Review → API services: loads data via · Review page uses checkout request API and events services.
- Users → API services: loads data via · Users page uses user API and events services.
- Dashboard → Shared UI: composes · Feature pages assemble shared table and page components.
- Inventory → Shared UI: composes · Feature pages assemble shared table and page components.
- Requests → Shared UI: composes · Feature pages assemble shared table and page components.
- Review → Shared UI: composes · Feature pages assemble shared table and page components.
- Users → Shared UI: composes · Feature pages assemble shared table and page components.
- API services → DTOs: uses · API services serialize and deserialize typed DTOs.
- Guards & auth → App shell: protects routes · Guards and interceptor enforce authenticated and role-aware access.
- Hosting setup → Controllers: wires · Startup config exposes the HTTP endpoints.
- Controllers → Services: delegates to · Controllers pass requests into application services.
- Services → Repositories: queries · Services use repositories for persistence and retrieval.
- Repositories → Db context: persists via · Repositories run through the EF Core context.
- Services → Domain model: operates on · Business rules are centered on entities and enums.
- Controllers → Server DTOs: accepts/returns · HTTP endpoints shape inputs and outputs with DTOs.
- Services → Auth flow: issues tokens · Token service supports login and authorization flow.
- API services → Controllers: calls API · Angular API clients communicate with the backend REST endpoints.
- Login & access → Auth flow: authenticates against · Login UI uses the auth endpoint and token response.
