# abdulrhmanmahfooz/erp_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/abdulrhmanmahfooz/erp_frontend
- Repository: https://github.com/abdulrhmanmahfooz/erp_frontend

## Overview

#### Purpose and runtime
This is a large Angular single-page frontend for multi-tenant ERP, accounting, construction/project management, procurement, inventory, HR/payroll, CRM, sales, and administration workflows. The browser application starts at `src/main.ts`, composes the root module and shell from `src/app/app.module.ts` and `src/app/app.component.ts`, and is deployed as static content behind Nginx/Docker (`Dockerfile`, `nginx.conf`, `docker-entrypoint.sh`).

#### Navigation and feature composition
Routing is module-oriented: the root router directs into core routes and a broad set of feature routing modules. Feature areas generally pair a `*.module.ts`, `*-routing.module.ts`, page components, typed models, and HTTP-facing services. Primary feature boundaries include:
- Project/construction operations: `src/app/features/projects/projects.module.ts`, `src/app/features/projects/projects-routing.module.ts`
- Financial/accounting configuration and operations: `src/app/features/accounting/accounting.module.ts`, `src/app/features/bonds/bonds.module.ts`
- Inventory and stock operations: `src/app/features/inventory/inventory.module.ts`, `src/app/features/inventory-adjustments/inventory-adjustments.module.ts`
- Purchasing lifecycle: `src/app/features/rfq/rfq.module.ts`, `src/app/features/purchase-orders/purchase-orders.module.ts`, `src/app/features/purchase-invoices/purchase-invoices.module.ts`

#### Core request, identity, and authorization boundary
`core` centralizes cross-cutting session and API behavior. HTTP requests pass through interceptors for base API URI selection, auth/session and JWT credentials, CSRF, loading state, error translation, and request deduplication. Access is enforced at route level by authentication, role, tenant/system-admin, document-approval, and permission guards; permissions also drive UI visibility/directives.
Key paths: `src/app/core/interceptors/auth-session.interceptor.ts`, `src/app/core/services/auth/auth.service.ts`, `src/app/core/permissions/permission.service.ts`.

The frontend communicates with an external backend API; its concrete server implementation is not in this repository. Runtime API/environment selection is represented by `src/assets/env-config.js` and `src/environments/environment.ts`.

#### Project execution and construction workflow
Projects are a central domain integration point. Project context, membership, structure (plots/blocks/floors/areas/units), BOQ/WBS, allocations, budgets, contracts, subcontracts, progress claims, financials, procurement, and handover all converge under the projects feature. A representative primary flow is: create/configure project structure → define or revise BOQ → allocate budget/materials/contracts → track progress/claims → generate invoices and review cost, revenue, commitments, and profitability.
Key paths: `src/app/features/projects/services/projects.service.ts`, `src/app/features/projects/execution/boq-screen/boq-screen.component.ts`, `src/app/features/projects/execution/progress-claims-screen/progress-claims-screen.component.ts`.

#### Commercial, accounting, and supply-chain flows
The application supports related document lifecycles rather than isolated screens: RFQs lead to purchase orders; goods-received notes and purchase orders can create purchase invoices; customer invoices, receipts, payments, credit notes, journals, reconciliations, and reporting support receivables/payables and general accounting. Approval controls are reusable across these business documents.
Key paths: `src/app/features/rfq/services/rfq.service.ts`, `src/app/features/grn/services/grn.service.ts`, `src/app/core/services/document-approval.service.ts`.

Inventory extends this flow through warehouses, locations, stock movements, reservations, issue/return vouchers, adjustments, reconciliations, and opening-stock import. Adjustment and reconciliation features each maintain feature-local client state stores rather than relying solely on component state.
Key paths: `src/app/features/inventory/services/stock.service.ts`, `src/app/features/inventory-adjustments/store/inventory-adjustment.store.ts`, `src/app/features/inventory-reconciliation/store/inventory-reconciliation.store.ts`.

#### Shared UI, documents, and integrations
`shared` provides reusable business selectors, attachment handling, validation, wizard mechanics, export controls, and BOQ/material-request selection primitives that bridge modules. PDF generation includes Arabic-capable embedded fonts; translation assets support Arabic and English. The AI-agent and AI-audit features are API client/UI boundaries for an external AI capability, with no provider implementation present here.
Key paths: `src/app/shared/shared.module.ts`, `src/app/core/services/pdf-generator.service.ts`, `src/app/features/ai-agent/services/ai-agent.service.ts`.

#### Operations and validation
Docker Compose and Nginx support containerized frontend delivery. GitHub Actions provides CI, while Playwright end-to-end scenarios cover login and representative project/BOQ/contract flows. These tests indicate critical user journeys but do not constitute backend infrastructure.
Key paths: `docker-compose.yml`, `.github/workflows/ci.yml`, `e2e/tests/boq-import.spec.ts`.

Main entry points: [`src/app/features/projects/projects.module.ts`](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/projects.module.ts) (Projects & construction), [`src/app/app.module.ts`](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/app.module.ts) (Root module & shell), [`src/app/features/projects/projects-routing.module.ts`](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/projects-routing.module.ts) (Feature routing), [`src/app/features/inventory/services/stock.service.ts`](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/inventory/services/stock.service.ts) (Inventory & stock)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Browser runtime"]
  node_bootstrap(("Angular bootstrap<br/>entrypoint<br/>[main.ts]"))
  node_app_shell["Root module &amp; shell<br/>Angular composition<br/>[app.module.ts]"]
  node_environment["Runtime API config<br/>environment config<br/>[env-config.js]"]
  node_feature_routes["Feature routing<br/>Angular route modules"]
end

subgraph group_core["Core platform"]
  node_http_boundary{{"HTTP interceptor chain<br/>request boundary"}}
  node_auth["Authentication session<br/>identity service<br/>[auth.service.ts]"]
  node_permissions{{"Permissions &amp; guards<br/>authorization"}}
  node_document_approval["Document approvals<br/>approval service"]
  node_shared_ui["Shared business UI<br/>shared module<br/>[shared.module.ts]"]
  node_pdf["PDF generation<br/>document service"]
end

subgraph group_domains["Business domains"]
  node_projects["Projects &amp; construction<br/>feature module<br/>[projects.module.ts]"]
  node_project_api["Project API client<br/>domain service"]
  node_boq["BOQ execution<br/>project workflow"]
  node_progress_claims["Progress &amp; claims<br/>project workflow"]
  node_accounting["Accounting &amp; finance<br/>feature module"]
  node_rfq["RFQ lifecycle<br/>procurement feature<br/>[rfq.service.ts]"]
  node_grn["Goods receiving<br/>supply-chain feature<br/>[grn.service.ts]"]
  node_inventory["Inventory &amp; stock<br/>inventory service<br/>[stock.service.ts]"]
  node_adjustment_store["Adjustment state<br/>feature-local store"]
  node_reconciliation_store["Reconciliation state<br/>feature-local store"]
  node_ai_agent["AI agent client<br/>external AI client"]
end

subgraph group_delivery["Delivery"]
  node_container_delivery["Nginx container delivery<br/>static frontend deployment"]
  node_ci["GitHub Actions CI<br/>CI pipeline<br/>[ci.yml]"]
end

node_backend_api{{"External backend API<br/>external service"}}

node_bootstrap -->|"boots"| node_app_shell
node_app_shell -->|"composes navigation"| node_feature_routes
node_feature_routes -->|"enforces access"| node_permissions
node_permissions -->|"uses session identity"| node_auth
node_app_shell -->|"reuses"| node_shared_ui
node_app_shell -->|"issues requests through"| node_http_boundary
node_environment -->|"configures API URI"| node_http_boundary
node_http_boundary -->|"API calls"| node_backend_api
node_feature_routes -->|"loads"| node_projects
node_projects -->|"uses"| node_project_api
node_projects -->|"includes"| node_boq
node_boq -->|"feeds execution tracking"| node_progress_claims
node_progress_claims -->|"feeds financial review"| node_accounting
node_rfq -->|"leads to purchase orders and receiving"| node_grn
node_grn -->|"supports purchase invoices"| node_accounting
node_projects -->|"drives procurement"| node_rfq
node_projects -->|"allocates materials"| node_inventory
node_inventory -->|"adjustments state"| node_adjustment_store
node_inventory -->|"reconciliation state"| node_reconciliation_store
node_document_approval -.->|"approves project documents"| node_projects
node_document_approval -.->|"approves business documents"| node_rfq
node_projects -.->|"generates documents"| node_pdf
node_ai_agent -->|"external AI API calls"| node_backend_api
node_container_delivery -->|"serves static build"| node_app_shell
node_ci -.->|"validates delivery"| node_container_delivery

click node_bootstrap "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/main.ts"
click node_app_shell "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/app.module.ts"
click node_environment "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/assets/env-config.js"
click node_feature_routes "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/projects-routing.module.ts"
click node_http_boundary "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/core/interceptors/auth-session.interceptor.ts"
click node_auth "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/core/services/auth/auth.service.ts"
click node_permissions "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/core/permissions/permission.service.ts"
click node_document_approval "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/core/services/document-approval.service.ts"
click node_shared_ui "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/shared/shared.module.ts"
click node_pdf "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/core/services/pdf-generator.service.ts"
click node_projects "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/projects.module.ts"
click node_project_api "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/services/projects.service.ts"
click node_boq "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/execution/boq-screen/boq-screen.component.ts"
click node_progress_claims "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/execution/progress-claims-screen/progress-claims-screen.component.ts"
click node_accounting "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/accounting/accounting.module.ts"
click node_rfq "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/rfq/services/rfq.service.ts"
click node_grn "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/grn/services/grn.service.ts"
click node_inventory "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/inventory/services/stock.service.ts"
click node_adjustment_store "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/inventory-adjustments/store/inventory-adjustment.store.ts"
click node_reconciliation_store "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/inventory-reconciliation/store/inventory-reconciliation.store.ts"
click node_ai_agent "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/ai-agent/services/ai-agent.service.ts"
click node_container_delivery "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/Dockerfile"
click node_ci "https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/.github/workflows/ci.yml"

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_bootstrap,node_app_shell,node_environment,node_feature_routes toneBlue
class node_http_boundary,node_auth,node_permissions,node_document_approval,node_shared_ui,node_pdf toneAmber
class node_projects,node_project_api,node_boq,node_progress_claims,node_accounting,node_rfq,node_grn,node_inventory,node_adjustment_store,node_reconciliation_store,node_ai_agent toneMint
class node_container_delivery,node_ci toneRose
class node_backend_api toneNeutral
```

## Components

### Browser runtime

- [Angular bootstrap](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/main.ts): entrypoint · `src/main.ts`
- [Root module & shell](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/app.module.ts): Angular composition · `src/app/app.module.ts`
- [Runtime API config](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/assets/env-config.js): environment config · Selects API endpoint and environment behavior. · `src/assets/env-config.js`
- [Feature routing](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/projects-routing.module.ts): Angular route modules · Root navigation composes core and feature routes. · `src/app/features/projects/projects-routing.module.ts`

### Core platform

- [HTTP interceptor chain](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/core/interceptors/auth-session.interceptor.ts): request boundary · Applies API URI, JWT/session, CSRF, loading, errors, and deduplication. · `src/app/core/interceptors/auth-session.interceptor.ts`
- [Authentication session](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/core/services/auth/auth.service.ts): identity service · `src/app/core/services/auth/auth.service.ts`
- [Permissions & guards](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/core/permissions/permission.service.ts): authorization · Controls route access and permission-driven UI visibility. · `src/app/core/permissions/permission.service.ts`
- [Document approvals](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/core/services/document-approval.service.ts): approval service · Reusable approval controls across business documents. · `src/app/core/services/document-approval.service.ts`
- [Shared business UI](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/shared/shared.module.ts): shared module · Selectors, attachments, validation, wizards, exports, and BOQ primitives. · `src/app/shared/shared.module.ts`
- [PDF generation](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/core/services/pdf-generator.service.ts): document service · Generates documents with Arabic-capable fonts. · `src/app/core/services/pdf-generator.service.ts`

### Business domains

- [Projects & construction](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/projects.module.ts): feature module · Central project context, structure, budgets, contracts, procurement, and handover. · `src/app/features/projects/projects.module.ts`
- [Project API client](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/services/projects.service.ts): domain service · `src/app/features/projects/services/projects.service.ts`
- [BOQ execution](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/execution/boq-screen/boq-screen.component.ts): project workflow · Defines and revises BOQ/WBS and allocations. · `src/app/features/projects/execution/boq-screen/boq-screen.component.ts`
- [Progress & claims](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/projects/execution/progress-claims-screen/progress-claims-screen.component.ts): project workflow · Tracks execution progress and claims. · `src/app/features/projects/execution/progress-claims-screen/progress-claims-screen.component.ts`
- [Accounting & finance](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/accounting/accounting.module.ts): feature module · Accounting configuration, receivables, payables, journals, reconciliation, and reporting. · `src/app/features/accounting/accounting.module.ts`
- [RFQ lifecycle](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/rfq/services/rfq.service.ts): procurement feature · `src/app/features/rfq/services/rfq.service.ts`
- [Goods receiving](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/grn/services/grn.service.ts): supply-chain feature · Goods receipts and purchase-order invoice creation inputs. · `src/app/features/grn/services/grn.service.ts`
- [Inventory & stock](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/inventory/services/stock.service.ts): inventory service · Warehouses, movements, reservations, vouchers, and stock operations. · `src/app/features/inventory/services/stock.service.ts`
- [Adjustment state](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/inventory-adjustments/store/inventory-adjustment.store.ts): feature-local store · `src/app/features/inventory-adjustments/store/inventory-adjustment.store.ts`
- [Reconciliation state](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/inventory-reconciliation/store/inventory-reconciliation.store.ts): feature-local store · `src/app/features/inventory-reconciliation/store/inventory-reconciliation.store.ts`
- [AI agent client](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/src/app/features/ai-agent/services/ai-agent.service.ts): external AI client · UI/API boundary for an external AI capability. · `src/app/features/ai-agent/services/ai-agent.service.ts`

### Delivery

- [Nginx container delivery](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/Dockerfile): static frontend deployment · `Dockerfile`
- [GitHub Actions CI](https://github.com/abdulrhmanmahfooz/erp_frontend/blob/main/.github/workflows/ci.yml): CI pipeline · `.github/workflows/ci.yml`

### Other components

- **External backend API**: external service · Server implementation is outside this repository.

## Connections

- Angular bootstrap → Root module & shell: boots
- Root module & shell → Feature routing: composes navigation
- Feature routing → Permissions & guards: enforces access
- Permissions & guards → Authentication session: uses session identity
- Root module & shell → Shared business UI: reuses
- Root module & shell → HTTP interceptor chain: issues requests through
- Runtime API config → HTTP interceptor chain: configures API URI
- HTTP interceptor chain → External backend API: API calls
- Feature routing → Projects & construction: loads
- Projects & construction → Project API client: uses
- Projects & construction → BOQ execution: includes
- BOQ execution → Progress & claims: feeds execution tracking
- Progress & claims → Accounting & finance: feeds financial review
- RFQ lifecycle → Goods receiving: leads to purchase orders and receiving
- Goods receiving → Accounting & finance: supports purchase invoices
- Projects & construction → RFQ lifecycle: drives procurement
- Projects & construction → Inventory & stock: allocates materials
- Inventory & stock → Adjustment state: adjustments state
- Inventory & stock → Reconciliation state: reconciliation state
- Document approvals → Projects & construction: approves project documents
- Document approvals → RFQ lifecycle: approves business documents
- Projects & construction → PDF generation: generates documents
- AI agent client → External backend API: external AI API calls
- Nginx container delivery → Root module & shell: serves static build
- GitHub Actions CI → Nginx container delivery: validates delivery
