# baptwild/projet-annuel-2026 architecture

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

- Interactive diagram: https://gitdiagram.com/baptwild/projet-annuel-2026
- Repository: https://github.com/baptwild/projet-annuel-2026

## Overview

1. **System shape**
   - This repo is a two-app monolith: a **Symfony 8 backend** and a **Next.js 16 frontend**, connected through HTTP and run together with **Docker Compose**.
   - A **MySQL 8** database is the shared persistence layer.
   - The frontend is the user-facing app; the backend is the source of truth for authentication, business rules, and data access.

2. **Backend boundary**
   - The Symfony backend exposes a mix of **custom controllers** and **API Platform resources**.
   - Main backend entrypoints are:
     - `/auth/login` for JWT login
     - `/api/*` for resource APIs
     - custom app routes such as `/register`, `/me`, and occupancy-related endpoints
   - Security is handled server-side with **JWT authentication** and Symfony security config.

3. **Core domain model**
   - The main entities are **User**, **Dog**, **Daycare**, and **Booking**.
   - `BookingStatus` captures the lifecycle of a booking: pending, confirmed, cancelled, completed.
   - The business domain is centered on daycare reservation management: users own dogs, dogs book daycare time, and daycares control capacity and pricing.

4. **Business logic placement**
   - The backend keeps non-trivial rules in dedicated layers:
     - `State/BookingProcessor.php` and `State/DogProcessor.php` handle write-side processing, likely through API Platform state hooks.
     - `Controller/OccupancyController.php` computes or returns day occupancy information.
     - Entity methods plus unit tests suggest booking state helpers live partly on the model itself.
   - This separation implies the backend is not just CRUD; it enforces booking rules, duplicate-day prevention, and status transitions.

5. **Multi-tenant architecture**
   - The repository is explicitly **multi-tenant**: each daycare is a tenant, and data must not leak between them.
   - `Doctrine/TenantExtension.php` is the key architectural clue: it likely filters queries by current daycare context.
   - Tests confirm this boundary: an admin or user in one daycare must not see bookings, dogs, or users from another daycare.

6. **Authentication and user flows**
   - Login uses JWT; demo instructions show token acquisition via `/auth/login`.
   - `RegisterController.php` handles account creation, and `MeController.php` exposes the authenticated user’s profile area.
   - The frontend sends auth headers via `src/utils/authHeaders.ts`, so authenticated API calls are a first-class flow.

7. **Booking and occupancy flow**
   - Booking creation is a multi-step domain flow:
     - user selects a dog
     - picks a day and time slots
     - frontend asks the backend for availability/occupancy
     - backend validates capacity and duplicate-dog-per-day constraints
     - booking is persisted with a status, then later processed by admin actions
   - Occupancy is surfaced to the user even when the daycare is full, which implies the backend returns both **capacity state** and **current bookings** for a date.

8. **Admin workflow**
   - The `/admin` section in the frontend is a separate operational surface for daycare staff.
   - It manages:
     - bookings by week and status
     - confirm/cancel/complete transitions
     - pricing and schedule settings
     - monthly revenue reporting
   - This area depends on backend reads that are tenant-scoped and likely role-restricted.

9. **Frontend architecture**
   - The frontend is a **Next.js App Router** application, organized by route segment under `src/app/[slug]`.
   - The `[slug]` segment strongly suggests tenant-specific routing in the UI, matching the backend’s multi-tenant model.
   - UI composition follows a design-system style breakdown: atoms, molecules, organisms, and page-level components.

10. **Frontend data layer**
   - Data access is centralized in custom hooks such as `useAuth`, `useLogin`, `useRegister`, `useMe`, `useBooking`, `useDaycare`, `useAdminBookings`, and `useAdminUsers`.
   - These hooks are the bridge between React pages and the Symfony API.
   - Shared helper modules handle domain calculations on the client side, such as date windows, time slots, billing, and availability formatting.

11. **Presentation and styling**
   - The frontend uses **Sass** heavily, with a structured component stylesheet tree mirroring the React component hierarchy.
   - Static assets live in `public/`, while layout concerns are split across reusable header/footer/wrapper components.
   - This indicates a strongly componentized UI, not a server-rendered template app.

12. **Backend presentation layer**
   - Symfony still contains Twig templates and some Asset Mapper/Stimulus assets, but these look secondary.
   - The main backend responsibility is API and business logic, not HTML rendering.
   - The presence of `assets/controllers` and `ux_turbo` suggests some progressive-enhancement tooling, but it is not the primary app shell.

13. **Data initialization and testability**
   - `DataFixtures/AppFixtures.php` seeds demo tenants, users, dogs, and bookings.
   - Doctrine migrations define the schema, and tests use a separate `app_test` database.
   - Functional tests cover auth, booking rules, occupancy, and tenant isolation, which is important because those are the system’s key boundaries.

14. **Deployment/runtime boundary**
   - The repo is designed to run as three containers: backend, frontend, and MySQL.
   - The Docker setup and Makefile automate bootstrapping, migrations, JWT key generation, and fixture loading.
   - In diagram terms, the only persistent state is in MySQL; both app containers are stateless and rebuilt from code.

15. **Most important diagram edges**
   - Browser → Next.js frontend
   - Next.js frontend → Symfony backend API over HTTP with JWT
   - Symfony backend → MySQL via Doctrine
   - Symfony backend → internal tenant filter / security boundary before any DB access
   - Backend fixtures/migrations → database initialization path
   - Tests → backend API and tenant boundary verification

Main entry points: [`frontend/src/app`](https://github.com/baptwild/projet-annuel-2026/tree/main/frontend/src/app) (Next.js app), [`backend/src/Entity`](https://github.com/baptwild/projet-annuel-2026/tree/main/backend/src/Entity) (Domain models), [`backend/public/index.php`](https://github.com/baptwild/projet-annuel-2026/blob/main/backend/public/index.php) (Symfony app), [`docker-compose.yml`](https://github.com/baptwild/projet-annuel-2026/blob/main/docker-compose.yml) (Docker Compose)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_browser(("Browser<br/>client"))
  node_compose["Docker Compose<br/>orchestration<br/>[docker-compose.yml]"]
  node_mysql[("MySQL<br/>database")]
end

subgraph group_backend["Symfony backend"]
  node_backendapp["Symfony app<br/>api app<br/>[index.php]"]
  node_routes["API routes<br/>http endpoints"]
  node_security["Security<br/>jwt auth<br/>[security.yaml]"]
  node_domain["Domain models<br/>entities"]
  node_processors["Write processors<br/>state hooks"]
  node_tenant["Tenant filter<br/>doctrine extension"]
  node_fixtures["Fixtures & migrations<br/>schema init<br/>[AppFixtures.php]"]
end

subgraph group_frontend["Next.js frontend"]
  node_nextapp["Next.js app<br/>ui app"]
  node_ui["UI system<br/>components"]
  node_hooks["Data hooks<br/>api client"]
  node_clientutils["Client utils<br/>helpers"]
end

subgraph group_tests["Verification"]
  node_testsuite["Functional tests"]
  node_unittests["Unit tests"]
end

node_browser -->|"uses"| node_nextapp
node_nextapp -->|"loads data"| node_hooks
node_hooks -->|"formats"| node_clientutils
node_nextapp -->|"renders"| node_ui
node_nextapp -->|"HTTP + JWT"| node_backendapp
node_compose -->|"runs"| node_nextapp
node_compose -->|"runs"| node_backendapp
node_compose -->|"runs"| node_mysql
node_backendapp -->|"guards"| node_security
node_security -->|"permits"| node_routes
node_routes -->|"reads/writes"| node_domain
node_processors -->|"mutates"| node_domain
node_tenant -->|"scopes"| node_domain
node_domain -->|"persists via Doctrine"| node_mysql
node_fixtures -->|"initializes"| node_mysql
node_testsuite -->|"verifies"| node_routes
node_testsuite -->|"verifies"| node_tenant
node_unittests -->|"verifies"| node_domain
node_backendapp -.->|"bootstraps"| node_fixtures

click node_compose "https://github.com/baptwild/projet-annuel-2026/blob/main/docker-compose.yml"
click node_nextapp "https://github.com/baptwild/projet-annuel-2026/tree/main/frontend/src/app"
click node_ui "https://github.com/baptwild/projet-annuel-2026/tree/main/frontend/src/components"
click node_hooks "https://github.com/baptwild/projet-annuel-2026/tree/main/frontend/src/hooks"
click node_clientutils "https://github.com/baptwild/projet-annuel-2026/tree/main/frontend/src/utils"
click node_backendapp "https://github.com/baptwild/projet-annuel-2026/blob/main/backend/public/index.php"
click node_routes "https://github.com/baptwild/projet-annuel-2026/tree/main/backend/src/Controller"
click node_security "https://github.com/baptwild/projet-annuel-2026/blob/main/backend/config/packages/security.yaml"
click node_domain "https://github.com/baptwild/projet-annuel-2026/tree/main/backend/src/Entity"
click node_processors "https://github.com/baptwild/projet-annuel-2026/tree/main/backend/src/State"
click node_tenant "https://github.com/baptwild/projet-annuel-2026/blob/main/backend/src/Doctrine/TenantExtension.php"
click node_fixtures "https://github.com/baptwild/projet-annuel-2026/blob/main/backend/src/DataFixtures/AppFixtures.php"
click node_testsuite "https://github.com/baptwild/projet-annuel-2026/tree/main/backend/tests/Functional"
click node_unittests "https://github.com/baptwild/projet-annuel-2026/tree/main/backend/tests/Unit/Entity"

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_browser,node_compose,node_mysql toneBlue
class node_backendapp,node_routes,node_security,node_domain,node_processors,node_tenant,node_fixtures toneAmber
class node_nextapp,node_ui,node_hooks,node_clientutils toneMint
class node_testsuite,node_unittests toneRose
```

## Components

### Runtime

Containers and shared infrastructure

- **Browser**: client · User-facing entry point
- [Docker Compose](https://github.com/baptwild/projet-annuel-2026/blob/main/docker-compose.yml): orchestration · Runs backend, frontend, and MySQL together · `docker-compose.yml`
- **MySQL**: database · Shared persistent datastore

### Symfony backend

API, auth, domain rules, and persistence access

- [Symfony app](https://github.com/baptwild/projet-annuel-2026/blob/main/backend/public/index.php): api app · Backend entrypoint and framework runtime · `backend/public/index.php`
- [API routes](https://github.com/baptwild/projet-annuel-2026/tree/main/backend/src/Controller): http endpoints · Login, register, profile, occupancy, and API Platform routes · `backend/src/Controller`
- [Security](https://github.com/baptwild/projet-annuel-2026/blob/main/backend/config/packages/security.yaml): jwt auth · JWT login and Symfony access control · `backend/config/packages/security.yaml`
- [Domain models](https://github.com/baptwild/projet-annuel-2026/tree/main/backend/src/Entity): entities · User, Dog, Daycare, Booking, and booking status · `backend/src/Entity`
- [Write processors](https://github.com/baptwild/projet-annuel-2026/tree/main/backend/src/State): state hooks · API Platform state processors for booking and dog writes · `backend/src/State`
- [Tenant filter](https://github.com/baptwild/projet-annuel-2026/blob/main/backend/src/Doctrine/TenantExtension.php): doctrine extension · Scopes queries to the current daycare tenant · `backend/src/Doctrine/TenantExtension.php`
- [Fixtures & migrations](https://github.com/baptwild/projet-annuel-2026/blob/main/backend/src/DataFixtures/AppFixtures.php): schema init · Seeds demo data and defines schema evolution · `backend/src/DataFixtures/AppFixtures.php`

### Next.js frontend

Tenant-aware UI and client data access

- [Next.js app](https://github.com/baptwild/projet-annuel-2026/tree/main/frontend/src/app): ui app · App Router frontend served by React and SSR/CSR · `frontend/src/app`
- [UI system](https://github.com/baptwild/projet-annuel-2026/tree/main/frontend/src/components): components · Atoms, molecules, organisms, and page sections · `frontend/src/components`
- [Data hooks](https://github.com/baptwild/projet-annuel-2026/tree/main/frontend/src/hooks): api client · Centralized React hooks for auth, booking, daycare, and admin data · `frontend/src/hooks`
- [Client utils](https://github.com/baptwild/projet-annuel-2026/tree/main/frontend/src/utils): helpers · Date, slot, billing, and auth helpers · `frontend/src/utils`

### Verification

Functional and unit coverage around core boundaries

- [Functional tests](https://github.com/baptwild/projet-annuel-2026/tree/main/backend/tests/Functional): tests · Auth, booking, occupancy, and tenant isolation coverage · `backend/tests/Functional`
- [Unit tests](https://github.com/baptwild/projet-annuel-2026/tree/main/backend/tests/Unit/Entity): tests · Entity-level booking behavior checks · `backend/tests/Unit/Entity`

## Connections

- Browser → Next.js app: uses · Users interact with the tenant-aware frontend
- Next.js app → Data hooks: loads data · Pages delegate API access to custom hooks
- Data hooks → Client utils: formats · Hooks rely on shared client-side domain helpers
- Next.js app → UI system: renders · Route pages compose reusable UI components
- Next.js app → Symfony app: HTTP + JWT · Frontend calls the Symfony API over authenticated requests
- Docker Compose → Next.js app: runs · Compose starts the frontend container
- Docker Compose → Symfony app: runs · Compose starts the backend container
- Docker Compose → MySQL: runs · Compose provides the shared database container
- Symfony app → Security: guards · Requests pass through server-side authentication and authorization
- Security → API routes: permits · Authenticated access unlocks controllers and API resources
- API routes → Domain models: reads/writes · Controllers expose and mutate core daycare data
- Write processors → Domain models: mutates · State processors enforce booking and dog write rules
- Tenant filter → Domain models: scopes · Doctrine filters keep reads tenant-isolated
- Domain models → MySQL: persists via Doctrine · Entities are stored in the shared MySQL database
- Fixtures & migrations → MySQL: initializes · Migrations and fixtures prepare the database state
- Functional tests → API routes: verifies · Functional tests exercise auth, booking, and occupancy endpoints
- Functional tests → Tenant filter: verifies · Functional tests assert daycare isolation boundaries
- Unit tests → Domain models: verifies · Unit tests cover booking entity behavior
- Symfony app → Fixtures & migrations: bootstraps · Runtime and setup scripts load schema and demo data
