Skip to main content

Technical Architecture

This page describes the technical architecture of PCH-SIG.

PCH-SIG Technical Architecture

Overview

PCH-SIG follows a classic 3-tier architecture:

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│ Presentation │ │ Business │ │ Data │
│ │ │ │ │ │
│ React + Nginx │────▶│ Symfony API │────▶│ PostgreSQL │
│ │ │ │ │ + PostGIS │
└─────────────────┘ └─────────────────┘ └─────────────────┘


┌─────────────┐
│ Redis │
│ (Cache) │
└─────────────┘

Technical Stack

Frontend

TechnologyVersionUsage
React18.xUI Framework
TypeScript5.xStatic typing
TanStack Query5.xAPI request management
Zustand4.xState management
Tailwind CSS3.xCSS Framework
Leaflet1.9Mapping
Recharts2.xCharts

Backend

TechnologyVersionUsage
PHP8.3Server language
Symfony6.4PHP Framework
API Platform3.xAutomatic REST API
Doctrine ORM2.xObject-relational mapping
LexikJWT2.xJWT Authentication

Database

TechnologyVersionUsage
PostgreSQL15Relational DBMS
PostGIS3.4Geospatial extension

Infrastructure

TechnologyVersionUsage
Docker24.xContainerization
Nginx1.25Web server / Reverse proxy
Redis7Cache and sessions

Container Architecture

┌─────────────────────────────────────────────────────────────┐
│ Docker Network │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ pch_frontend│ │pch_nginx_ │ │ pch_backend │ │
│ │ (Nginx) │───▶│ backend │───▶│ (PHP-FPM) │ │
│ │ :80 │ │ :8000 │ │ :9000 │ │
│ └─────────────┘ └─────────────┘ └──────┬──────┘ │
│ │ │
│ ┌─────────────────────────┼─────────┐ │
│ │ │ │ │
│ ┌─────▼─────┐ ┌───────▼───────┐ │ │
│ │pch_postgres│ │ pch_redis │ │ │
│ │ :5432 │ │ :6379 │ │ │
│ └───────────┘ └───────────────┘ │ │
│ │ │
└─────────────────────────────────────────────────────────────┘

Request flow

  1. Client accesses frontend via port 80 (or 3000)
  2. /api/* requests are proxied to backend (port 8000)
  3. Nginx backend passes PHP requests to PHP-FPM
  4. PHP-FPM queries PostgreSQL and Redis
  5. Response returns to client

Backend Architecture

Folder structure

backend/
├── bin/ # Console scripts
├── config/ # Symfony configuration
│ ├── packages/ # Bundle configs
│ └── routes/ # Routes
├── migrations/ # Doctrine migrations
├── public/ # Web entry point
├── src/
│ ├── Controller/ # API Controllers
│ ├── Entity/ # Doctrine Entities
│ ├── Repository/ # Repositories
│ ├── Service/ # Business Services
│ ├── Security/ # Voters, Authenticators
│ └── EventListener/ # Listeners
└── var/ # Cache and logs

Main entities

┌───────────────┐     ┌───────────────┐     ┌───────────────┐
│ Menage │────▶│ ChefMenage │ │ Logement │
│ │ │ │ │ │
│ - codeMenage │ │ - nomComplet │ │ - typeLogement│
│ - tailleMenage│ │ - telephone │ │ - nbPieces │
│ - scorePmt │ │ - age │ │ - sourceEau │
└───────┬───────┘ └───────────────┘ └───────────────┘

│ 1:N

┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ MembreMenage │ │ Beneficiaire │────▶│ Paiement │
│ │ │ │ │ │
│ - nomComplet │ │ - actif │ │ - montant │
│ - lienParente │ │ - modePaiement│ │ - statut │
└───────────────┘ └───────┬───────┘ └───────────────┘

│ N:1

┌───────────────┐
│ Cycle │
│ │
│ - nom │
│ - statut │
│ - montantTotal│
└───────────────┘

Frontend Architecture

Folder structure

frontend/
├── public/ # Static assets
├── src/
│ ├── components/ # Reusable components
│ ├── layouts/ # Layouts (MainLayout)
│ ├── pages/ # Pages by module
│ │ ├── menages/
│ │ ├── beneficiaires/
│ │ ├── paiements/
│ │ └── ...
│ ├── services/ # API client (axios)
│ ├── stores/ # Zustand stores
│ ├── utils/ # Utilities
│ └── App.tsx # Entry point
└── package.json

Data flow

┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│ Pages │───▶│ Stores │───▶│ Services │
│ │ │ (Zustand) │ │ (API) │
└─────────────┘ └─────────────┘ └──────┬──────┘
│ │
│ ▼
│ ┌─────────────┐
└──────────────────────────────▶│ Backend │
TanStack Query │ API │
└─────────────┘

Security

Authentication

  • JWT (JSON Web Tokens) via LexikJWTAuthenticationBundle
  • Access token (1 hour) + Refresh token (7 days)
  • Token storage in localStorage

Authorization

  • Granular permissions format module.action
  • Symfony Voters for authorization logic
  • Frontend and backend verification

Data protection

  • HTTPS encryption in production
  • Passwords hashed with bcrypt
  • CSRF protection on forms
  • Input validation

Scalability

Horizontal

  • Frontend: CDN or multiple Nginx instances
  • Backend: Load balancer + multiple PHP-FPM
  • Database: PostgreSQL read replicas

Vertical

  • Increased CPU/RAM resources
  • SQL query optimization
  • Redis caching

Next steps