How yasblha/projet-facturation works
Project Type and Purpose
• AquaERP is a full-stack, Kubernetes-deployed microservices platform for water-sector contract, billing, and field-operation management.
• Frontend: Vue.js 3 + TypeScript + Pinia.
• Backend: A suite of NestJS microservices behind an API Gateway, communicating via REST and RabbitMQ.
• Shared infrastructure: PostgreSQL, RabbitMQ, Traefik ingress, Prometheus/Grafana monitoring.
File Structure Highlights
• Top-level “frontend” folder: Vue SPA, static assets, Dockerfile.
• “services/…-service” folders: each a self-contained NestJS microservice (auth, contrat, operation, facture, mailer, intervention, workflow, api-gateway).
• “Database” folder: central Sequelize config, migrations, models.
• “k8s” + “infrastructure” folders: Kubernetes manifests, ingress, monitoring, config, adapters.
• “scripts”: deployment helpers, manifest generators, DB helpers.
Key Architectural Patterns
• API Gateway pattern for a single entry point.
• Microservices with CQRS-style structure (DTOs, use-cases, repositories).
• Event-driven communication via RabbitMQ for async workflows.
• Shared or per-service PostgreSQL persistence.
• Deployed on Kubernetes with Traefik ingress, HPA, NetworkPolicies, and observability stack.
Main Components
a) User Browser & Mobile (Clients)
– Connects via HTTPS to the Frontend.
b) Frontend (Vue.js SPA)
– Served behind Traefik ingress & CDN.
– Interacts with API Gateway over HTTPS/REST.
c) Traefik Ingress Controller (K8s)
– Routes external traffic to Frontend or API Gateway.
d) API Gateway (NestJS)
– Synchronous REST proxy for client requests.
– Asynchronous publisher to RabbitMQ for certain commands/events.
– Routes to individual microservices.
e) RabbitMQ Message Broker
– Central event bus for inter-service async communication.
– Exchanges for domain events (contractCreated, invoiceIssued, etc.).
f) Microservices
– Auth Service
– Contrat Service
– Operation Service
– Facture Service
– Intervention Service
– Mailer Service
– Workflow Service
Each:
• Exposes HTTP endpoints (including /health).
• Subscribes to RabbitMQ queues/exchanges.
• Reads/writes to PostgreSQL.
• Publishes events to RabbitMQ.
g) PostgreSQL Database
– Persistent volume claim.
– Single instance or per-service schemas.
h) Monitoring & Logging
– Prometheus scrapes /metrics endpoints.
– Grafana dashboards.
– Elasticsearch or external logger adapter (optional).
i) CI/CD & GitHub Actions
– selective-deploy workflows triggering Docker builds and k8s updates.
Relationships & Data Flows
• Frontend → (HTTPS/REST) → API Gateway
• API Gateway → (REST) → Microservice endpoints for sync operations
• API Gateway → (RabbitMQ) → Exchanges for async commands (e.g., sendInvitationEmail)
• Microservices → (REST) → Other services if required (rare)
• Microservices ↔ (RabbitMQ) ↔ Microservices for domain event propagation
• Each Microservice → (SQL) → PostgreSQL
• Prometheus ← (metrics endpoints) ← Each service + RabbitMQ + DB
• Grafana visualizes Prometheus data
Technologies & Frameworks
• Frontend: Vue 3, Pinia, Vite, Cypress (E2E).
• Backend: NestJS, TypeScript, Sequelize (or TypeORM), RabbitMQ.
• Deployment: Docker, Kubernetes (Traefik, HPA, NetworkPolicies), cert-manager.
• Monitoring: Prometheus, Grafana.
• CI/CD: GitHub Actions.