# heir2050/ged architecture

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

- Interactive diagram: https://gitdiagram.com/heir2050/ged
- Repository: https://github.com/heir2050/ged

## Overview

1. **System shape**
   - This is a **PHP monolith built around a custom MVC framework**.
   - The browser hits `public/index.php`, and Apache rewrite rules in `public/.htaccess` route requests into the app.
   - The application code lives in `app/`, while uploaded documents live on disk under `public/uploads/`.

2. **Framework layer**
   - The core runtime is in `app/core/`: `App.php` handles routing, `Controller.php` and `Model.php` define the base abstractions, and `Database.php` is the persistence layer.
   - `config.php`, `init.php`, and helper files provide bootstrapping, shared configuration, and utility functions.
   - This means the architecture is controller-driven, with direct model access rather than a separate service layer.

3. **Primary UI flow**
   - Each request follows the classic flow: **router → controller → model → view**.
   - Views are server-rendered PHP templates in `app/views/`, with shared layout pieces such as `head`, `header`, `sidebar`, and `footer`.
   - The app is presentation-heavy and page-oriented, not API-first.

4. **Authentication and user administration**
   - Identity-related controllers include `Login`, `Signup`, `Logout`, `Profile`, `Users`, and `Admin`.
   - Models such as `User`, `Session`, and `Profile` back the authentication/session state and account management.
   - The `Admin` area is the administrative boundary for creating, editing, and deleting users and services.

5. **Service-based access model**
   - The README states that users belong to **services**, and each user can see the activity of their service.
   - This implies a multi-tenant-like partitioning by service, with access and visibility scoped by organizational unit rather than purely by individual ownership.
   - The presence of `Employe`, `Employes`, `Dossiers`, and `Folders` suggests the service/dossier structure is central to authorization and navigation.

6. **Document management core**
   - The heart of the repo is document handling: controllers such as `Document`, `Folder`, `Upload`, `DocumentAssignment`, `DocumentOg`, `Details`, and `Historique`.
   - Models such as `Documents`, `Folders`, `Uploads`, `DocumentAssignments`, and `ConsultationDocument` support metadata, storage location, assignment, and viewing history.
   - Views like `documents.view.php`, `folders.view.php`, `upload.view.php`, `documentassignments.view.php`, and `details.view.php` correspond to the main user journeys.

7. **File storage boundary**
   - Actual files are stored under `public/uploads/` in many subfolders, including `documents/`, `conges/`, `attachments/`, and several dossier-like directories.
   - This is an important architectural boundary: the database stores metadata and relationships, while the filesystem stores the binary documents.
   - The README requirement that uploaded documents should not be deleted when a user is removed indicates the file store is treated as a shared organizational archive, not user-owned ephemeral data.

8. **Upload workflow**
   - The system supports **multi-file uploads**, and the README says each new file should go into its own folder.
   - `Upload` and `Uploads`/`Uploads copy` are the main upload handlers, likely coordinating folder creation, filename generation, and database record creation.
   - The directory structure in `public/uploads/documents/<dossier>/...` shows uploads are organized by dossier/service context.

9. **Document consultation tracking**
   - A key domain requirement is tracking **who has opened a file and who has not**.
   - That behavior is reflected by `ConsultationDocument` and `DocumentAssignments`, plus history-related controllers/views.
   - In architecture terms, every document view/open action likely writes a consultation/audit record, which later feeds the “opened by” lists shown per service.

10. **Leave management side module**
   - There is a separate “congés” workflow with `Conges`, `DetailConges`, and related models `Conge`, `CongeAttachment`, and `DetailConge`.
   - Its files are stored separately under `public/uploads/conges/`, showing it is a distinct business module, not just a document subtype.
   - This module likely has its own list/detail pages and attachment handling, but shares the same core MVC and database patterns.

11. **Notifications and activity history**
   - `Notifications` and `Historique` provide cross-cutting feedback and auditability.
   - These subsystems are important for the service visibility model: they help surface who uploaded, viewed, assigned, or changed documents.
   - The `Notification copy` files suggest iterative development, but the canonical boundary is the notification feed plus activity log.

12. **Database and schema**
   - The repo includes `bd.sql` and `sql.sql`, indicating a relational database schema is part of the project delivery.
   - The schema likely captures users, services, documents, folders/dossiers, consultations, notifications, and leave requests.
   - For an architecture diagram, the database should be shown as the authoritative store for all metadata and audit state.

13. **Static assets and generated UI**
   - `public/assets/` contains app-specific styling and scripts, while `public/build/` looks like a prebuilt admin UI/template bundle.
   - These assets support the server-rendered pages but do not appear to be the main application logic.
   - They matter mainly as the presentation layer around the MVC pages.

14. **Repo hygiene note**
   - There are many files named `copy`, which suggests older iterations or duplicated variants of controllers, models, and views.
   - For architecture purposes, the important thing is the canonical set: `Document`, `Upload`, `Notifications`, `Conges`, `Users`, and the matching models/views.
   - The copies are noise rather than separate subsystems.

15. **What the diagram should emphasize**
   - Show a **single PHP web app** with three major domain zones: **identity/admin**, **document management**, and **congés/attachments**.
   - Put the **database** and **filesystem uploads** as separate backends, with metadata in SQL and binaries on disk.
   - Highlight the **service-scoped visibility and consultation tracking** as the project’s distinctive architectural feature.

Main entry points: [`app/views`](https://github.com/heir2050/ged/tree/main/app/views) (Server views), [`app/controllers/Document.php`](https://github.com/heir2050/ged/blob/main/app/controllers/Document.php) (Documents), [`sql.sql`](https://github.com/heir2050/ged/blob/main/sql.sql) (SQL schema), [`app/controllers/Conges.php`](https://github.com/heir2050/ged/blob/main/app/controllers/Conges.php) (Congés)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry & Presentation"]
  node_public_index["Front controller<br/>php entrypoint<br/>[index.php]"]
  node_rewrite["Rewrite rules<br/>apache config<br/>[.htaccess]"]
  node_views["Server views<br/>php templates"]
  node_assets["UI assets<br/>static assets"]
end

subgraph group_core["Framework Core"]
  node_core_app["Router<br/>[App.php]"]
  node_core_controller["Base controller<br/>mvc base<br/>[Controller.php]"]
  node_core_model["Base model<br/>mvc base<br/>[Model.php]"]
  node_core_db[("Database layer<br/>persistence<br/>[Database.php]")]
  node_bootstrap["Bootstrap<br/>init/config<br/>[init.php]"]
end

subgraph group_domain["Domain Modules"]
  node_auth["Identity<br/>auth module<br/>[Login.php]"]
  node_users_admin["User admin<br/>admin module<br/>[Users.php]"]
  node_documents["Documents<br/>document module<br/>[Document.php]"]
  node_upload["Upload flow<br/>ingest module<br/>[Upload.php]"]
  node_folder["Folders<br/>navigation module<br/>[Folder.php]"]
  node_tracking["Tracking<br/>audit module<br/>[Historique.php]"]
  node_leave["Congés<br/>leave module<br/>[Conges.php]"]
end

subgraph group_data["Storage Backends"]
  node_schema[("SQL schema<br/>relational schema<br/>[sql.sql]")]
  node_uploads_fs[("Uploads store<br/>filesystem store")]
end

node_rewrite -->|"rewrites to"| node_public_index
node_public_index -->|"boots"| node_bootstrap
node_bootstrap -->|"initializes"| node_core_app
node_core_app -->|"dispatches"| node_core_controller
node_core_controller -->|"renders"| node_views
node_core_controller -->|"uses"| node_core_model
node_core_model -->|"queries"| node_core_db
node_auth -->|"delegates"| node_users_admin
node_users_admin -->|"stores metadata"| node_schema
node_documents -->|"organizes by"| node_folder
node_documents -->|"records views"| node_tracking
node_upload -->|"writes files"| node_uploads_fs
node_upload -->|"records uploads"| node_schema
node_documents -->|"reads files"| node_uploads_fs
node_tracking -->|"audits"| node_schema
node_leave -->|"stores attachments"| node_uploads_fs
node_leave -->|"persists requests"| node_schema
node_auth -->|"renders pages"| node_views
node_documents -->|"renders pages"| node_views
node_leave -->|"renders pages"| node_views
node_assets -->|"supports UI"| node_views

click node_public_index "https://github.com/heir2050/ged/blob/main/public/index.php"
click node_rewrite "https://github.com/heir2050/ged/blob/main/public/.htaccess"
click node_views "https://github.com/heir2050/ged/tree/main/app/views"
click node_assets "https://github.com/heir2050/ged/tree/main/public/assets"
click node_core_app "https://github.com/heir2050/ged/blob/main/app/core/App.php"
click node_core_controller "https://github.com/heir2050/ged/blob/main/app/core/Controller.php"
click node_core_model "https://github.com/heir2050/ged/blob/main/app/core/Model.php"
click node_core_db "https://github.com/heir2050/ged/blob/main/app/core/Database.php"
click node_bootstrap "https://github.com/heir2050/ged/blob/main/app/core/init.php"
click node_auth "https://github.com/heir2050/ged/blob/main/app/controllers/Login.php"
click node_users_admin "https://github.com/heir2050/ged/blob/main/app/controllers/Users.php"
click node_documents "https://github.com/heir2050/ged/blob/main/app/controllers/Document.php"
click node_upload "https://github.com/heir2050/ged/blob/main/app/controllers/Upload.php"
click node_folder "https://github.com/heir2050/ged/blob/main/app/controllers/Folder.php"
click node_tracking "https://github.com/heir2050/ged/blob/main/app/controllers/Historique.php"
click node_leave "https://github.com/heir2050/ged/blob/main/app/controllers/Conges.php"
click node_schema "https://github.com/heir2050/ged/blob/main/sql.sql"
click node_uploads_fs "https://github.com/heir2050/ged/tree/main/public/uploads"

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_public_index,node_rewrite,node_views,node_assets toneBlue
class node_core_app,node_core_controller,node_core_model,node_core_db,node_bootstrap toneAmber
class node_auth,node_users_admin,node_documents,node_upload,node_folder,node_tracking,node_leave toneMint
class node_schema,node_uploads_fs toneRose
```

## Components

### Entry & Presentation

Web entrypoint, server-rendered views, and static frontend assets.

- [Front controller](https://github.com/heir2050/ged/blob/main/public/index.php): php entrypoint · Main web entry that receives requests before routing into the app. · `public/index.php`
- [Rewrite rules](https://github.com/heir2050/ged/blob/main/public/.htaccess): apache config · Apache rewrite boundary that forwards browser requests to the front controller. · `public/.htaccess`
- [Server views](https://github.com/heir2050/ged/tree/main/app/views): php templates · Rendered page templates and shared layout partials. · `app/views`
- [UI assets](https://github.com/heir2050/ged/tree/main/public/assets): static assets · Application styling, scripts, and bundled UI resources. · `public/assets`

### Framework Core

Custom MVC runtime, bootstrap, and shared infrastructure.

- [Router](https://github.com/heir2050/ged/blob/main/app/core/App.php): mvc router · Dispatches incoming requests to controllers. · `app/core/App.php`
- [Base controller](https://github.com/heir2050/ged/blob/main/app/core/Controller.php): mvc base · Shared controller abstraction for request handling and view rendering. · `app/core/Controller.php`
- [Base model](https://github.com/heir2050/ged/blob/main/app/core/Model.php): mvc base · Shared model abstraction used by application models. · `app/core/Model.php`
- [Database layer](https://github.com/heir2050/ged/blob/main/app/core/Database.php): persistence · Low-level database access used by models. · `app/core/Database.php`
- [Bootstrap](https://github.com/heir2050/ged/blob/main/app/core/init.php): init/config · Application configuration and startup helpers. · `app/core/init.php`

### Domain Modules

Identity, document, notification, and leave-management boundaries.

- [Identity](https://github.com/heir2050/ged/blob/main/app/controllers/Login.php): auth module · Login, signup, logout, profile, and user administration boundaries. · `app/controllers/Login.php`
- [User admin](https://github.com/heir2050/ged/blob/main/app/controllers/Users.php): admin module · User and administrative management area. · `app/controllers/Users.php`
- [Documents](https://github.com/heir2050/ged/blob/main/app/controllers/Document.php): document module · Main document browsing, metadata, and consultation workflow. · `app/controllers/Document.php`
- [Upload flow](https://github.com/heir2050/ged/blob/main/app/controllers/Upload.php): ingest module · Multi-file upload handling and dossier-based file creation. · `app/controllers/Upload.php`
- [Folders](https://github.com/heir2050/ged/blob/main/app/controllers/Folder.php): navigation module · Folder and dossier organization for document grouping. · `app/controllers/Folder.php`
- [Tracking](https://github.com/heir2050/ged/blob/main/app/controllers/Historique.php): audit module · Consultation history, document assignments, and notifications. · `app/controllers/Historique.php`
- [Congés](https://github.com/heir2050/ged/blob/main/app/controllers/Conges.php): leave module · Leave requests and related attachments. · `app/controllers/Conges.php`

### Storage Backends

Relational schema and filesystem-backed uploads.

- [SQL schema](https://github.com/heir2050/ged/blob/main/sql.sql): relational schema · Authoritative metadata and audit store for users, services, documents, and leave records. · `sql.sql`
- [Uploads store](https://github.com/heir2050/ged/tree/main/public/uploads): filesystem store · Shared filesystem archive for documents, attachments, and congés files. · `public/uploads`

## Connections

- Rewrite rules → Front controller: rewrites to · Apache forwards requests into the PHP front controller.
- Front controller → Bootstrap: boots · Front controller loads shared configuration and startup logic.
- Bootstrap → Router: initializes · Bootstrap prepares the router/runtime.
- Router → Base controller: dispatches · Router invokes controller actions.
- Base controller → Server views: renders · Controllers select server-side templates.
- Base controller → Base model: uses · Controllers coordinate model access through the base abstraction.
- Base model → Database layer: queries · Models persist and read data through the database layer.
- Identity → User admin: delegates · Identity flows lead into account administration.
- User admin → SQL schema: stores metadata · User and service state is persisted in the relational schema.
- Documents → Folders: organizes by · Documents are grouped through dossiers and folders.
- Documents → Tracking: records views · Opening documents feeds consultation and history tracking.
- Upload flow → Uploads store: writes files · Uploaded binaries are stored on disk in dossier-specific folders.
- Upload flow → SQL schema: records uploads · Upload metadata and relationships are written to the database.
- Documents → Uploads store: reads files · Document views resolve stored binaries from the filesystem archive.
- Tracking → SQL schema: audits · Consultations, assignments, and notifications are stored as metadata.
- Congés → Uploads store: stores attachments · Congés attachments are kept in a separate upload subtree.
- Congés → SQL schema: persists requests · Leave requests and their details are stored in the database.
- Identity → Server views: renders pages · Login, signup, and profile screens are server-rendered pages.
- Documents → Server views: renders pages · Document management pages are served from PHP templates.
- Congés → Server views: renders pages · Congés views are part of the server-rendered UI.
- UI assets → Server views: supports UI · Static assets back the rendered templates and layouts.
