How abdulrhmanmahfooz/erp_frontend works
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: projects.module.ts Projects & construction · app.module.ts Root module & shell · projects-routing.module.ts Feature routing · stock.service.ts Inventory & stock
Components 24
Browser runtime
- Angular bootstrap
src/main.ts - Root module & shell
src/app/app.module.ts - Runtime API config · Selects API endpoint and environment behavior.
src/assets/env-config.js - Feature routing · Root navigation composes core and feature routes.
src/app/features/projects/projects-routing.module.ts
Core platform
- HTTP interceptor chain · Applies API URI, JWT/session, CSRF, loading, errors, and deduplication.
src/app/core/interceptors/auth-session.interceptor.ts - Authentication session
src/app/core/services/auth/auth.service.ts - Permissions & guards · Controls route access and permission-driven UI visibility.
src/app/core/permissions/permission.service.ts - Document approvals · Reusable approval controls across business documents.
src/app/core/services/document-approval.service.ts - Shared business UI · Selectors, attachments, validation, wizards, exports, and BOQ primitives.
src/app/shared/shared.module.ts - PDF generation · Generates documents with Arabic-capable fonts.
src/app/core/services/pdf-generator.service.ts
Business domains
- Projects & construction · Central project context, structure, budgets, contracts, procurement, and handover.
src/app/features/projects/projects.module.ts - Project API client
src/app/features/projects/services/projects.service.ts - BOQ execution · Defines and revises BOQ/WBS and allocations.
src/app/features/projects/execution/boq-screen/boq-screen.component.ts - Progress & claims · Tracks execution progress and claims.
src/app/features/projects/execution/progress-claims-screen/progress-claims-screen.component.ts - Accounting & finance · Accounting configuration, receivables, payables, journals, reconciliation, and reporting.
src/app/features/accounting/accounting.module.ts - RFQ lifecycle
src/app/features/rfq/services/rfq.service.ts - Goods receiving · Goods receipts and purchase-order invoice creation inputs.
src/app/features/grn/services/grn.service.ts - Inventory & stock · Warehouses, movements, reservations, vouchers, and stock operations.
src/app/features/inventory/services/stock.service.ts - Adjustment state
src/app/features/inventory-adjustments/store/inventory-adjustment.store.ts - Reconciliation state
src/app/features/inventory-reconciliation/store/inventory-reconciliation.store.ts - AI agent client · UI/API boundary for an external AI capability.
src/app/features/ai-agent/services/ai-agent.service.ts
Delivery
- Nginx container delivery
Dockerfile - GitHub Actions CI
.github/workflows/ci.yml
Other components
- External backend API · Server implementation is outside this repository.
Connections 25
- 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