# symac/covers architecture

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

- Interactive diagram: https://gitdiagram.com/symac/covers
- Repository: https://github.com/symac/covers

## Overview

1. This repository is a small Symfony-based web application whose purpose is to act as a proxy/cache layer for the BnF “service couverture” API. The main architectural boundary is between incoming HTTP requests from users and outgoing requests to the external BnF cover service.

2. The HTTP entrypoint is the standard Symfony front controller in `public/index.php`, with routing configured under `config/routes*.yaml` and controller classes in `src/Controller`. The app is therefore organized as a conventional server-rendered Symfony site, not a standalone API service.

3. There are two main controller surfaces: `IndexController` for the normal user-facing page and `AjaxController` for asynchronous cover lookups. This suggests a split between initial page rendering and incremental cover retrieval, likely driven by browser-side requests.

4. The core domain model is centered on two Doctrine entities in `src/Entity`: `Isbn` and `Cover`. That indicates the application persists or indexes covers by ISBN, and tracks cover metadata separately from the book identifier. Database schema changes are managed through Doctrine migrations in `migrations/`.

5. `src/Service/BnfClient.php` is the external integration point. It is the abstraction responsible for talking to the BnF cover API, so the app’s integration boundary is cleanly separated from controllers and persistence. In the architecture diagram, this is the outbound dependency to an external service.

6. The `src/Repository` layer (`CoverRepository`, `IsbnRepository`) provides data access for the two entities. The repositories form the persistence boundary between the application logic and the database, and are the likely place where cache lookups, existence checks, and retrieval by ISBN happen.

7. The `public/covers/` directory is an important storage boundary. It contains subdirectories for `original`, `large`, `medium`, and `small`, which strongly suggests the app stores downloaded cover images locally in multiple sizes and serves them as static files through the web server. This is the cache/asset layer of the architecture.

8. Presentation is handled with Twig templates in `templates/`, notably `templates/base.html.twig` and `templates/index/index.html.twig`. The app likely renders a minimal HTML shell and then uses the Ajax endpoint to fetch or update cover data dynamically.

9. Configuration is the usual Symfony stack: `config/packages/doctrine.yaml` for persistence, `framework.yaml` for core runtime behavior, `security.yaml` for access control, `twig.yaml` for templating, and `mailer.yaml` / `notifier.yaml` for optional framework services. The presence of these files shows the project is built on Symfony’s dependency-injection and bundle system rather than custom bootstrap code.

10. Deployment/runtime is container-friendly: there is a `Dockerfile` and `docker-compose.yml`, plus environment files (`.env`, `.env.test`). That means local development and production are expected to be driven by environment configuration, with Symfony and Doctrine wired at runtime.

11. Operationally, the data flow is likely: browser requests page → controller resolves ISBN/cover state from database → if missing, `BnfClient` fetches from the BnF API → cover metadata and/or image files are stored locally and indexed via Doctrine → page or Ajax response returns the local cached result. The key architectural idea is “external cover service in, cached cover assets out.”

12. Tests and dev tooling are present but lightweight: `tests/bootstrap.php` and Symfony test config indicate a standard PHPUnit/Symfony test setup, and the `dev` package configs include profiler/logging support. This points to a traditional monolith with clear service boundaries, not a distributed system.

Main entry points: [`src/Controller/AjaxController.php`](https://github.com/symac/covers/blob/master/src/Controller/AjaxController.php) (Ajax lookup), [`config/routes.yaml`](https://github.com/symac/covers/blob/master/config/routes.yaml) (Routing), [`src/Controller/IndexController.php`](https://github.com/symac/covers/blob/master/src/Controller/IndexController.php) (Main page), [`public/index.php`](https://github.com/symac/covers/blob/master/public/index.php) (Front controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_http["HTTP app"]
  node_n_public_index["Front controller<br/>Symfony entrypoint<br/>[index.php]"]
  node_n_routes["Routing<br/>Symfony routes<br/>[routes.yaml]"]
  node_n_index_controller["Main page<br/>Controller"]
  node_n_ajax_controller["Ajax lookup<br/>Controller<br/>[AjaxController.php]"]
  node_n_base_tpl["Base layout<br/>Twig layout<br/>[base.html.twig]"]
  node_n_index_tpl["Index view<br/>Twig template<br/>[index.html.twig]"]
end

subgraph group_grp_domain["Domain & storage"]
  node_n_isbn_entity[("ISBN<br/>Doctrine entity<br/>[Isbn.php]")]
  node_n_cover_entity[("Cover<br/>Doctrine entity<br/>[Cover.php]")]
  node_n_isbn_repo["ISBN repo<br/>Doctrine repository<br/>[IsbnRepository.php]"]
  node_n_cover_repo["Cover repo<br/>Doctrine repository"]
  node_n_migrations["Migrations"]
  node_n_covers_storage["Cached covers<br/>Static asset cache"]
end

subgraph group_grp_external["External & runtime"]
  node_n_bnf_client["BnF client<br/>External integration<br/>[BnfClient.php]"]
  node_n_symfony_config["Symfony config<br/>Framework config"]
  node_n_runtime["Docker runtime<br/>Container setup<br/>[docker-compose.yml]"]
  node_n_tests["Test setup<br/>Test bootstrap<br/>[bootstrap.php]"]
end

node_n_public_index -->|"dispatches via"| node_n_routes
node_n_routes -->|"maps to"| node_n_index_controller
node_n_routes -->|"maps to"| node_n_ajax_controller
node_n_index_controller -->|"renders"| node_n_base_tpl
node_n_index_controller -->|"renders"| node_n_index_tpl
node_n_ajax_controller -->|"reads"| node_n_isbn_repo
node_n_ajax_controller -->|"reads"| node_n_cover_repo
node_n_ajax_controller -->|"fetches from"| node_n_bnf_client
node_n_bnf_client -->|"writes cache"| node_n_covers_storage
node_n_cover_repo -->|"persists"| node_n_cover_entity
node_n_isbn_repo -->|"persists"| node_n_isbn_entity
node_n_cover_entity -->|"links by ISBN"| node_n_isbn_entity
node_n_migrations -->|"evolves schema"| node_n_isbn_entity
node_n_migrations -->|"evolves schema"| node_n_cover_entity
node_n_symfony_config -->|"boots"| node_n_public_index
node_n_runtime -->|"hosts"| node_n_public_index
node_n_tests -.->|"uses"| node_n_symfony_config

click node_n_public_index "https://github.com/symac/covers/blob/master/public/index.php"
click node_n_routes "https://github.com/symac/covers/blob/master/config/routes.yaml"
click node_n_index_controller "https://github.com/symac/covers/blob/master/src/Controller/IndexController.php"
click node_n_ajax_controller "https://github.com/symac/covers/blob/master/src/Controller/AjaxController.php"
click node_n_base_tpl "https://github.com/symac/covers/blob/master/templates/base.html.twig"
click node_n_index_tpl "https://github.com/symac/covers/blob/master/templates/index/index.html.twig"
click node_n_isbn_entity "https://github.com/symac/covers/blob/master/src/Entity/Isbn.php"
click node_n_cover_entity "https://github.com/symac/covers/blob/master/src/Entity/Cover.php"
click node_n_isbn_repo "https://github.com/symac/covers/blob/master/src/Repository/IsbnRepository.php"
click node_n_cover_repo "https://github.com/symac/covers/blob/master/src/Repository/CoverRepository.php"
click node_n_migrations "https://github.com/symac/covers/blob/master/migrations/Version20200425224356.php"
click node_n_covers_storage "https://github.com/symac/covers/tree/master/public/covers"
click node_n_bnf_client "https://github.com/symac/covers/blob/master/src/Service/BnfClient.php"
click node_n_symfony_config "https://github.com/symac/covers/tree/master/config/packages"
click node_n_runtime "https://github.com/symac/covers/blob/master/docker-compose.yml"
click node_n_tests "https://github.com/symac/covers/blob/master/tests/bootstrap.php"

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_n_public_index,node_n_routes,node_n_index_controller,node_n_ajax_controller,node_n_base_tpl,node_n_index_tpl toneBlue
class node_n_isbn_entity,node_n_cover_entity,node_n_isbn_repo,node_n_cover_repo,node_n_migrations,node_n_covers_storage toneAmber
class node_n_bnf_client,node_n_symfony_config,node_n_runtime,node_n_tests toneMint
```

## Components

### HTTP app

Symfony request handling, routing, controllers, and Twig rendering.

- [Front controller](https://github.com/symac/covers/blob/master/public/index.php): Symfony entrypoint · Web entrypoint for incoming HTTP requests. · `public/index.php`
- [Routing](https://github.com/symac/covers/blob/master/config/routes.yaml): Symfony routes · Route definitions and annotation-based routing config. · `config/routes.yaml`
- [Main page](https://github.com/symac/covers/blob/master/src/Controller/IndexController.php): Controller · Renders the user-facing cover search/view page. · `src/Controller/IndexController.php`
- [Ajax lookup](https://github.com/symac/covers/blob/master/src/Controller/AjaxController.php): Controller · Handles asynchronous cover lookup requests. · `src/Controller/AjaxController.php`
- [Base layout](https://github.com/symac/covers/blob/master/templates/base.html.twig): Twig layout · Shared HTML shell for the application. · `templates/base.html.twig`
- [Index view](https://github.com/symac/covers/blob/master/templates/index/index.html.twig): Twig template · Main page template for the cover interface. · `templates/index/index.html.twig`

### Domain & storage

ISBN/cover entities, repositories, migrations, and local cached cover files.

- [ISBN](https://github.com/symac/covers/blob/master/src/Entity/Isbn.php): Doctrine entity · Book identifier model used as the lookup key. · `src/Entity/Isbn.php`
- [Cover](https://github.com/symac/covers/blob/master/src/Entity/Cover.php): Doctrine entity · Cover metadata and cached cover record. · `src/Entity/Cover.php`
- [ISBN repo](https://github.com/symac/covers/blob/master/src/Repository/IsbnRepository.php): Doctrine repository · Persistence access for ISBN records. · `src/Repository/IsbnRepository.php`
- [Cover repo](https://github.com/symac/covers/blob/master/src/Repository/CoverRepository.php): Doctrine repository · Persistence access for cover records and cache state. · `src/Repository/CoverRepository.php`
- [Migrations](https://github.com/symac/covers/blob/master/migrations/Version20200425224356.php): Doctrine migrations · Database schema evolution for the entity model. · `migrations/Version20200425224356.php`
- [Cached covers](https://github.com/symac/covers/tree/master/public/covers): Static asset cache · Local cover image storage in multiple sizes. · `public/covers`

### External & runtime

Outbound BnF integration and deployment/runtime concerns.

- [BnF client](https://github.com/symac/covers/blob/master/src/Service/BnfClient.php): External integration · Outbound client for the BnF service couverture API. · `src/Service/BnfClient.php`
- [Symfony config](https://github.com/symac/covers/tree/master/config/packages): Framework config · Runtime, DI, security, templating, and Doctrine configuration. · `config/packages`
- [Docker runtime](https://github.com/symac/covers/blob/master/docker-compose.yml): Container setup · Local and deployable runtime via Docker and Compose. · `docker-compose.yml`
- [Test setup](https://github.com/symac/covers/blob/master/tests/bootstrap.php): Test bootstrap · PHPUnit/Symfony test bootstrap and test environment config. · `tests/bootstrap.php`

## Connections

- Front controller → Routing: dispatches via · Front controller hands requests to Symfony routing.
- Routing → Main page: maps to · Main page route resolves to the page controller.
- Routing → Ajax lookup: maps to · Ajax route resolves to the asynchronous lookup controller.
- Main page → Base layout: renders · Controller uses the shared Twig layout.
- Main page → Index view: renders · Controller renders the main index template.
- Ajax lookup → ISBN repo: reads · Lookup flow checks ISBN persistence/cache state.
- Ajax lookup → Cover repo: reads · Lookup flow checks cover persistence/cache state.
- Ajax lookup → BnF client: fetches from · Missing covers are retrieved from the external BnF API.
- BnF client → Cached covers: writes cache · Downloaded cover files are stored locally in size variants.
- Cover repo → Cover: persists · Repository manages cover records.
- ISBN repo → ISBN: persists · Repository manages ISBN records.
- Cover → ISBN: links by ISBN · Cover data is associated with the ISBN lookup key.
- Migrations → ISBN: evolves schema · Migration supports the ISBN table/entity schema.
- Migrations → Cover: evolves schema · Migration supports the cover table/entity schema.
- Symfony config → Front controller: boots · Framework configuration enables the HTTP kernel and services.
- Docker runtime → Front controller: hosts · Container runtime serves the Symfony front controller.
- Test setup → Symfony config: uses · Tests rely on the Symfony runtime configuration.
