# juantintos/admin-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/juantintos/admin-frontend
- Repository: https://github.com/juantintos/admin-frontend

## Overview

1. **What this repository is**
   - This is an Angular 19 single-page frontend for a management system.
   - It does not contain backend logic; it consumes a REST API from a Laravel backend.
   - The app is organized around feature modules and a shared shell, with HTTP services handling all server communication.

2. **Top-level application structure**
   - `main.ts`, `app.module.ts`, and `app-routing.module.ts` form the bootstrap and navigation entry points.
   - `app.component` is the root host, while the real UI is composed through routed feature modules.
   - `environment.ts` likely supplies the API base URL and runtime configuration.

3. **Core architectural boundary**
   - `src/app/core` holds reusable, cross-cutting code:
     - route guards
     - HTTP interceptors
     - domain models
     - reusable services
     - shared utility pipes
   - This keeps feature modules focused on screens and user interaction, not transport/auth plumbing.

4. **Feature modules**
   - The app is split into domain modules under `src/app/modules`:
     - `auth` for login and password recovery
     - `dashboard` for KPIs and recent activity
     - `users` for user CRUD and profile assignment
     - `profiles` for profile CRUD and user counts
     - `audit-logs` for change history
     - `products` for a separate CRUD domain
   - Each module contains list/form components, which suggests standard “index + edit/create” workflows.

5. **Shared shell and navigation**
   - `core/shared/components/layout`, `header`, and `sidebar` define the authenticated application shell.
   - These components likely wrap the routed content area and provide the main navigation chrome.
   - `shared.module.ts` and `layout.module.ts` centralize reusable UI elements so feature modules don’t duplicate page scaffolding.

6. **Authentication and authorization flow**
   - `auth.service` handles login/session state.
   - `auth.guard` protects authenticated routes.
   - `permission.guard` adds finer-grained access control, likely by role or permission claims from the backend.
   - The flow is: user logs in, token/session is stored, guarded routes become available, and the shell/navigation is shown.

7. **HTTP and backend integration**
   - `auth.interceptor` attaches authentication credentials to outgoing API requests.
   - `error.interceptor` centralizes API error handling so feature components don’t each implement their own response parsing.
   - Domain services such as `user.service`, `profile.service`, `product.service`, `audit-log.service`, and `export.service` are the main bridge between UI and backend endpoints.

8. **Data model layer**
   - `core/models` defines the frontend shape of API data: users, profiles, products, auth/session state, audit logs, and pagination.
   - `pagination.model.ts` suggests server-side paging is a first-class concern across list screens.
   - These models act as the contract between REST responses and the UI components.

9. **Primary data flows**
   - List pages request paginated collections from services, render them in PrimeNG tables, and push filtering/paging parameters back to the API.
   - Form pages load entity details, submit create/update requests, and then return to list or detail views.
   - The dashboard aggregates multiple backend-provided metrics rather than owning its own local state.

10. **Audit trail subsystem**
   - The audit-log module is a dedicated read-only subsystem for tracking system changes.
   - The README indicates it supports created/updated/deleted actions, before/after comparisons, snapshots on creation, field name formatting, and filters by module/action/date.
   - This makes audit history a separate UX and data path, not just another CRUD list.

11. **Users and profiles domain**
   - Users support listing, creation/editing, profile assignment, and logical deletion.
   - Profiles support full CRUD plus “users per profile” counts and detail views with related users.
   - This implies role/permission management is an important boundary in the app, not just a data entry screen.

12. **UI technology and presentation**
   - PrimeNG, PrimeIcons, RxJS, and SCSS are the main UI stack.
   - Data tables, dialogs/modals, filters, badges, and responsive layouts are core presentation patterns.
   - `safe-value.pipe.ts` indicates the app sometimes renders trusted or sanitized values, likely for formatted audit details or rich content.

13. **Overall dependency direction**
   - The dependency flow is intentionally layered: components → feature services → HTTP interceptors → Laravel API.
   - Guards sit on the routing edge, while shared components provide the application shell.
   - This separation is the key architectural boundary to capture in a diagram.

Main entry points: [`src/app/app-routing.module.ts`](https://github.com/juantintos/admin-frontend/blob/main/src/app/app-routing.module.ts) (App routing), [`src/app/app.module.ts`](https://github.com/juantintos/admin-frontend/blob/main/src/app/app.module.ts) (App module), [`src/app/core/services/auth.service.ts`](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/services/auth.service.ts) (Auth service), [`src/app/core/shared/components/layout/layout.module.ts`](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/shared/components/layout/layout.module.ts) (Layout module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Bootstrap"]
  node_main_ts["main.ts<br/>entrypoint<br/>[main.ts]"]
  node_app_module["App module<br/>root module<br/>[app.module.ts]"]
  node_app_routing["App routing<br/>routes"]
  node_app_component["App host<br/>root component<br/>[app.component.ts]"]
  node_environment["Environment<br/>config<br/>[environment.ts]"]
end

subgraph group_core["Core"]
  node_auth_guard{{"Auth guard<br/>route guard<br/>[auth.guard.ts]"}}
  node_permission_guard{{"Permission guard<br/>route guard"}}
  node_auth_interceptor["Auth interceptor<br/>http interceptor"]
  node_error_interceptor["Error interceptor<br/>http interceptor"]
  node_auth_service["Auth service<br/>session service<br/>[auth.service.ts]"]
  node_api_services["API services<br/>domain services"]
  node_models["Models"]
  node_safe_pipe["Safe value<br/>pipe<br/>[safe-value.pipe.ts]"]
end

subgraph group_shell["Shell"]
  node_shared_module["Shared module<br/>shared ui<br/>[shared.module.ts]"]
  node_layout_module["Layout module<br/>shell module<br/>[layout.module.ts]"]
  node_header_component["Header<br/>navigation ui"]
  node_sidebar_component["Sidebar<br/>navigation ui"]
end

subgraph group_features["Features"]
  node_auth_module["Auth module<br/>feature module<br/>[auth.module.ts]"]
  node_dashboard_module["Dashboard<br/>feature module"]
  node_users_module["Users<br/>feature module<br/>[users.module.ts]"]
  node_profiles_module["Profiles<br/>feature module<br/>[profiles.module.ts]"]
  node_products_module["Products<br/>feature module<br/>[products.module.ts]"]
  node_audit_module["Audit logs<br/>feature module"]
end

node_main_ts -->|"bootstraps"| node_app_module
node_app_module -->|"imports"| node_app_routing
node_app_module -->|"hosts"| node_app_component
node_app_module -->|"imports"| node_shared_module
node_app_module -->|"imports"| node_layout_module
node_app_module -->|"registers"| node_auth_interceptor
node_app_module -->|"registers"| node_error_interceptor
node_app_routing -->|"protects"| node_auth_guard
node_app_routing -->|"checks"| node_permission_guard
node_app_routing -->|"routes to"| node_auth_module
node_app_routing -->|"routes to"| node_dashboard_module
node_app_routing -->|"routes to"| node_users_module
node_app_routing -->|"routes to"| node_profiles_module
node_app_routing -->|"routes to"| node_products_module
node_app_routing -->|"routes to"| node_audit_module
node_app_component -->|"renders"| node_layout_module
node_layout_module -->|"includes"| node_header_component
node_layout_module -->|"includes"| node_sidebar_component
node_shared_module -->|"exports"| node_safe_pipe
node_auth_guard -->|"reads session"| node_auth_service
node_permission_guard -->|"reads claims"| node_auth_service
node_auth_interceptor -->|"gets token"| node_auth_service
node_api_services -->|"uses api base"| node_environment
node_api_services -->|"maps data"| node_models
node_auth_service -->|"uses api base"| node_environment
node_auth_module -->|"uses"| node_auth_service
node_dashboard_module -->|"reads metrics"| node_api_services
node_users_module -->|"manages users"| node_api_services
node_profiles_module -->|"manages profiles"| node_api_services
node_products_module -->|"manages products"| node_api_services
node_audit_module -->|"reads history"| node_api_services
node_audit_module -->|"formats values"| node_safe_pipe

click node_main_ts "https://github.com/juantintos/admin-frontend/blob/main/src/main.ts"
click node_app_module "https://github.com/juantintos/admin-frontend/blob/main/src/app/app.module.ts"
click node_app_routing "https://github.com/juantintos/admin-frontend/blob/main/src/app/app-routing.module.ts"
click node_app_component "https://github.com/juantintos/admin-frontend/blob/main/src/app/app.component.ts"
click node_environment "https://github.com/juantintos/admin-frontend/blob/main/src/environments/environment.ts"
click node_shared_module "https://github.com/juantintos/admin-frontend/blob/main/src/app/core/shared/shared.module.ts"
click node_layout_module "https://github.com/juantintos/admin-frontend/blob/main/src/app/core/shared/components/layout/layout.module.ts"
click node_header_component "https://github.com/juantintos/admin-frontend/blob/main/src/app/core/shared/components/header/header.component.ts"
click node_sidebar_component "https://github.com/juantintos/admin-frontend/blob/main/src/app/core/shared/components/sidebar/sidebar.component.ts"
click node_auth_guard "https://github.com/juantintos/admin-frontend/blob/main/src/app/core/guards/auth.guard.ts"
click node_permission_guard "https://github.com/juantintos/admin-frontend/blob/main/src/app/core/guards/permission.guard.ts"
click node_auth_interceptor "https://github.com/juantintos/admin-frontend/blob/main/src/app/core/interceptors/auth.interceptor.ts"
click node_error_interceptor "https://github.com/juantintos/admin-frontend/blob/main/src/app/core/interceptors/error.interceptor.ts"
click node_auth_service "https://github.com/juantintos/admin-frontend/blob/main/src/app/core/services/auth.service.ts"
click node_models "https://github.com/juantintos/admin-frontend/tree/main/src/app/core/models"
click node_safe_pipe "https://github.com/juantintos/admin-frontend/blob/main/src/app/core/pipes/safe-value.pipe.ts"
click node_auth_module "https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/auth/auth.module.ts"
click node_dashboard_module "https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/dashboard/dashboard.module.ts"
click node_users_module "https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/users/users.module.ts"
click node_profiles_module "https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/profiles/profiles.module.ts"
click node_products_module "https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/products/products.module.ts"
click node_audit_module "https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/audit-logs/audit-logs.module.ts"

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_main_ts,node_app_module,node_app_routing,node_app_component,node_environment toneBlue
class node_auth_guard,node_permission_guard,node_auth_interceptor,node_error_interceptor,node_auth_service,node_api_services,node_models,node_safe_pipe toneAmber
class node_shared_module,node_layout_module,node_header_component,node_sidebar_component toneMint
class node_auth_module,node_dashboard_module,node_users_module,node_profiles_module,node_products_module,node_audit_module toneRose
```

## Components

### Bootstrap

Angular entrypoints and root app wiring

- [main.ts](https://github.com/juantintos/admin-frontend/blob/main/src/main.ts): entrypoint · Bootstraps the Angular app · `src/main.ts`
- [App module](https://github.com/juantintos/admin-frontend/blob/main/src/app/app.module.ts): root module · Composes app-wide imports, providers, and features · `src/app/app.module.ts`
- [App routing](https://github.com/juantintos/admin-frontend/blob/main/src/app/app-routing.module.ts): routes · Top-level navigation and route protection · `src/app/app-routing.module.ts`
- [App host](https://github.com/juantintos/admin-frontend/blob/main/src/app/app.component.ts): root component · Root shell host for routed content · `src/app/app.component.ts`
- [Environment](https://github.com/juantintos/admin-frontend/blob/main/src/environments/environment.ts): config · Runtime API base URL and environment settings · `src/environments/environment.ts`

### Core

Cross-cutting auth, API, and model layer

- [Auth guard](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/guards/auth.guard.ts): route guard · Blocks unauthenticated routes · `src/app/core/guards/auth.guard.ts`
- [Permission guard](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/guards/permission.guard.ts): route guard · Enforces role or permission checks · `src/app/core/guards/permission.guard.ts`
- [Auth interceptor](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/interceptors/auth.interceptor.ts): http interceptor · Adds credentials to outgoing API calls · `src/app/core/interceptors/auth.interceptor.ts`
- [Error interceptor](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/interceptors/error.interceptor.ts): http interceptor · Centralizes API error handling · `src/app/core/interceptors/error.interceptor.ts`
- [Auth service](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/services/auth.service.ts): session service · Handles login and session state · `src/app/core/services/auth.service.ts`
- **API services**: domain services · User, profile, product, audit, and export API bridges
- [Models](https://github.com/juantintos/admin-frontend/tree/main/src/app/core/models): data models · Frontend contracts for users, profiles, products, auth, logs, and paging · `src/app/core/models`
- [Safe value](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/pipes/safe-value.pipe.ts): pipe · Formats or safely renders trusted values · `src/app/core/pipes/safe-value.pipe.ts`

### Shell

Shared layout and navigation chrome

- [Shared module](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/shared/shared.module.ts): shared ui · Reusable UI declarations shared across features · `src/app/core/shared/shared.module.ts`
- [Layout module](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/shared/components/layout/layout.module.ts): shell module · Authenticated application shell wrapper · `src/app/core/shared/components/layout/layout.module.ts`
- [Header](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/shared/components/header/header.component.ts): navigation ui · Top bar for the authenticated shell · `src/app/core/shared/components/header/header.component.ts`
- [Sidebar](https://github.com/juantintos/admin-frontend/blob/main/src/app/core/shared/components/sidebar/sidebar.component.ts): navigation ui · Primary navigation for the shell · `src/app/core/shared/components/sidebar/sidebar.component.ts`

### Features

Routed domain modules and screens

- [Auth module](https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/auth/auth.module.ts): feature module · Login and password recovery area · `src/app/modules/auth/auth.module.ts`
- [Dashboard](https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/dashboard/dashboard.module.ts): feature module · KPIs and recent activity screen · `src/app/modules/dashboard/dashboard.module.ts`
- [Users](https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/users/users.module.ts): feature module · User CRUD and profile assignment · `src/app/modules/users/users.module.ts`
- [Profiles](https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/profiles/profiles.module.ts): feature module · Profile CRUD and user counts · `src/app/modules/profiles/profiles.module.ts`
- [Products](https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/products/products.module.ts): feature module · Product CRUD domain · `src/app/modules/products/products.module.ts`
- [Audit logs](https://github.com/juantintos/admin-frontend/blob/main/src/app/modules/audit-logs/audit-logs.module.ts): feature module · Read-only change history and filters · `src/app/modules/audit-logs/audit-logs.module.ts`

## Connections

- main.ts → App module: bootstraps · Angular starts through the root module
- App module → App routing: imports · Registers application routes
- App module → App host: hosts · Sets the root component
- App module → Shared module: imports · Makes shared UI available app-wide
- App module → Layout module: imports · Provides the shell layout
- App module → Auth interceptor: registers · Adds auth HTTP interception
- App module → Error interceptor: registers · Adds global HTTP error handling
- App routing → Auth guard: protects · Uses auth guard on private routes
- App routing → Permission guard: checks · Uses permission guard on restricted routes
- App routing → Auth module: routes to · Entry point for login and recovery
- App routing → Dashboard: routes to · Main post-login landing area
- App routing → Users: routes to · User management area
- App routing → Profiles: routes to · Profile management area
- App routing → Products: routes to · Product management area
- App routing → Audit logs: routes to · Audit history area
- App host → Layout module: renders · Root host delegates to the shell layout
- Layout module → Header: includes · Shell header is part of the layout
- Layout module → Sidebar: includes · Shell sidebar is part of the layout
- Shared module → Safe value: exports · Reusable shared pipe
- Auth guard → Auth service: reads session · Checks authentication state
- Permission guard → Auth service: reads claims · Checks current user permissions
- Auth interceptor → Auth service: gets token · Attaches stored credentials to requests
- API services → Environment: uses api base · Domain services build REST calls from environment config
- API services → Models: maps data · Services exchange typed API payloads with the UI
- Auth service → Environment: uses api base · Login and session calls depend on backend settings
- Auth module → Auth service: uses · Login and recovery screens call auth operations
- Dashboard → API services: reads metrics · Dashboard aggregates backend data
- Users → API services: manages users · User list and form workflows use domain services
- Profiles → API services: manages profiles · Profile screens use domain services
- Products → API services: manages products · Product screens use domain services
- Audit logs → API services: reads history · Audit log list is service-backed
- Audit logs → Safe value: formats values · Audit details may render trusted formatted content
