# mathieu7483/ma-mediatheque architecture

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

- Interactive diagram: https://gitdiagram.com/mathieu7483/ma-mediatheque
- Repository: https://github.com/mathieu7483/ma-mediatheque

## Overview

Ma médiathèque is a local Flask catalog for DVDs, CDs, and books. The main user workflow is browsing a collection or the home page, searching and selecting an item on the shared add page, enriching it through the relevant metadata service, and saving it to SQLite; users can also add items manually and delete entries. Separate bulk-import scripts cover all three collections. The sampled files establish the main web, storage, and import links; some page behavior and route details are documented only in the README.

Main entry points: [`app.py`](https://github.com/mathieu7483/ma-mediatheque/blob/main/app.py) (Flask routes), [`database.py`](https://github.com/mathieu7483/ma-mediatheque/blob/main/database.py) (Catalog database), [`services/books_service.py`](https://github.com/mathieu7483/ma-mediatheque/blob/main/services/books_service.py) (Book lookup), [`seed_cd.py`](https://github.com/mathieu7483/ma-mediatheque/blob/main/seed_cd.py) (CD importer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Flask routes<br/>[app.py]"]
  node_home["Home page<br/>[index.html]"]
  node_dvd_page["DVD page<br/>[dvd.html]"]
  node_cd_page["CD page<br/>[cd.html]"]
  node_books_page["Books page<br/>[livres.html]"]
  node_add_page["Add form<br/>[add.html]"]
end

subgraph group_catalog["Catalog storage"]
  node_database["Catalog database<br/>[database.py]"]
  node_sqlite[("SQLite catalog<br/>[dvds.db]")]
end

subgraph group_metadata["Metadata services"]
  node_tmdb_service["TMDb lookup<br/>[tmdb_service.py]"]
  node_discogs_service["Discogs lookup<br/>[discogs_service.py]"]
  node_books_service["Book lookup<br/>[books_service.py]"]
end

subgraph group_imports["Bulk imports"]
  node_seed_dvd["DVD importer<br/>[seed.py]"]
  node_seed_cd["CD importer<br/>[seed_cd.py]"]
  node_seed_books["Book importer<br/>[seed_livres.py]"]
  node_seed_common["Import helpers<br/>[seed_common.py]"]
end

node_visitor(("Collection owner"))
node_tmdb{{"TMDb API"}}
node_discogs{{"Discogs API"}}
node_google_books{{"Google Books"}}
node_open_library{{"Open Library"}}

node_visitor -->|"uses"| node_app
node_app -->|"renders"| node_home
node_app -->|"renders"| node_dvd_page
node_app -->|"renders"| node_cd_page
node_app -->|"renders"| node_books_page
node_app -->|"renders"| node_add_page
node_app -->|"reads and writes"| node_database
node_database -->|"queries"| node_sqlite
node_app -->|"requests details"| node_tmdb_service
node_tmdb_service -->|"queries"| node_tmdb
node_app -->|"searches releases"| node_discogs_service
node_discogs_service -->|"queries"| node_discogs
node_app -->|"searches books"| node_books_service
node_books_service -->|"searches"| node_google_books
node_books_service -->|"fallback search"| node_open_library
node_seed_dvd -->|"looks up titles"| node_tmdb_service
node_seed_dvd -->|"adds DVDs"| node_database
node_seed_cd -->|"uses helpers"| node_seed_common
node_seed_cd -->|"searches releases"| node_discogs_service
node_seed_cd -->|"adds albums"| node_database
node_seed_books -->|"uses helpers"| node_seed_common
node_seed_books -->|"searches books"| node_books_service
node_seed_books -->|"adds books"| node_database

click node_app "https://github.com/mathieu7483/ma-mediatheque/blob/main/app.py"
click node_home "https://github.com/mathieu7483/ma-mediatheque/blob/main/templates/index.html"
click node_dvd_page "https://github.com/mathieu7483/ma-mediatheque/blob/main/templates/dvd.html"
click node_cd_page "https://github.com/mathieu7483/ma-mediatheque/blob/main/templates/cd.html"
click node_books_page "https://github.com/mathieu7483/ma-mediatheque/blob/main/templates/livres.html"
click node_add_page "https://github.com/mathieu7483/ma-mediatheque/blob/main/templates/add.html"
click node_database "https://github.com/mathieu7483/ma-mediatheque/blob/main/database.py"
click node_sqlite "https://github.com/mathieu7483/ma-mediatheque/blob/main/dvds.db"
click node_tmdb_service "https://github.com/mathieu7483/ma-mediatheque/blob/main/services/tmdb_service.py"
click node_discogs_service "https://github.com/mathieu7483/ma-mediatheque/blob/main/services/discogs_service.py"
click node_books_service "https://github.com/mathieu7483/ma-mediatheque/blob/main/services/books_service.py"
click node_seed_dvd "https://github.com/mathieu7483/ma-mediatheque/blob/main/seed.py"
click node_seed_cd "https://github.com/mathieu7483/ma-mediatheque/blob/main/seed_cd.py"
click node_seed_books "https://github.com/mathieu7483/ma-mediatheque/blob/main/seed_livres.py"
click node_seed_common "https://github.com/mathieu7483/ma-mediatheque/blob/main/seed_common.py"

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_app,node_home,node_dvd_page,node_cd_page,node_books_page,node_add_page toneBlue
class node_database,node_sqlite toneAmber
class node_tmdb_service,node_discogs_service,node_books_service,node_tmdb,node_discogs toneMint
class node_seed_dvd,node_seed_cd,node_seed_books,node_seed_common toneRose
class node_visitor,node_google_books,node_open_library toneIndigo
```

## Components

### Web application

- [Flask routes](https://github.com/mathieu7483/ma-mediatheque/blob/main/app.py): `app.py`
- [Home page](https://github.com/mathieu7483/ma-mediatheque/blob/main/templates/index.html): `templates/index.html`
- [DVD page](https://github.com/mathieu7483/ma-mediatheque/blob/main/templates/dvd.html): `templates/dvd.html`
- [CD page](https://github.com/mathieu7483/ma-mediatheque/blob/main/templates/cd.html): `templates/cd.html`
- [Books page](https://github.com/mathieu7483/ma-mediatheque/blob/main/templates/livres.html): `templates/livres.html`
- [Add form](https://github.com/mathieu7483/ma-mediatheque/blob/main/templates/add.html): `templates/add.html`

### Catalog storage

- [Catalog database](https://github.com/mathieu7483/ma-mediatheque/blob/main/database.py): `database.py`
- [SQLite catalog](https://github.com/mathieu7483/ma-mediatheque/blob/main/dvds.db): `dvds.db`

### Metadata services

- [TMDb lookup](https://github.com/mathieu7483/ma-mediatheque/blob/main/services/tmdb_service.py): `services/tmdb_service.py`
- [Discogs lookup](https://github.com/mathieu7483/ma-mediatheque/blob/main/services/discogs_service.py): `services/discogs_service.py`
- [Book lookup](https://github.com/mathieu7483/ma-mediatheque/blob/main/services/books_service.py): `services/books_service.py`

### Bulk imports

- [DVD importer](https://github.com/mathieu7483/ma-mediatheque/blob/main/seed.py): `seed.py`
- [CD importer](https://github.com/mathieu7483/ma-mediatheque/blob/main/seed_cd.py): `seed_cd.py`
- [Book importer](https://github.com/mathieu7483/ma-mediatheque/blob/main/seed_livres.py): `seed_livres.py`
- [Import helpers](https://github.com/mathieu7483/ma-mediatheque/blob/main/seed_common.py): `seed_common.py`

### Other components

- **Collection owner**
- **TMDb API**
- **Discogs API**
- **Google Books**
- **Open Library**

## Connections

- Collection owner → Flask routes: uses (evidence: `README.md`)
- Flask routes → Home page: renders (evidence: `README.md`)
- Flask routes → DVD page: renders (evidence: `app.py`)
- Flask routes → CD page: renders (evidence: `app.py`)
- Flask routes → Books page: renders (evidence: `app.py`)
- Flask routes → Add form: renders (evidence: `app.py`)
- Flask routes → Catalog database: reads and writes (evidence: `app.py`)
- Catalog database → SQLite catalog: queries (evidence: `database.py`)
- Flask routes → TMDb lookup: requests details (evidence: `app.py`)
- TMDb lookup → TMDb API: queries (evidence: `services/tmdb_service.py`)
- Flask routes → Discogs lookup: searches releases (evidence: `app.py`)
- Discogs lookup → Discogs API: queries (evidence: `services/discogs_service.py`)
- Flask routes → Book lookup: searches books (evidence: `app.py`)
- Book lookup → Google Books: searches (evidence: `services/books_service.py`)
- Book lookup → Open Library: fallback search (evidence: `services/books_service.py`)
- DVD importer → TMDb lookup: looks up titles (evidence: `seed.py`)
- DVD importer → Catalog database: adds DVDs (evidence: `seed.py`)
- CD importer → Import helpers: uses helpers (evidence: `seed_cd.py`)
- CD importer → Discogs lookup: searches releases (evidence: `seed_cd.py`)
- CD importer → Catalog database: adds albums (evidence: `seed_cd.py`)
- Book importer → Import helpers: uses helpers (evidence: `seed_livres.py`)
- Book importer → Book lookup: searches books (evidence: `seed_livres.py`)
- Book importer → Catalog database: adds books (evidence: `seed_livres.py`)
