# chrisanger59/tomtroc architecture

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

- Interactive diagram: https://gitdiagram.com/chrisanger59/tomtroc
- Repository: https://github.com/chrisanger59/tomtroc

## Overview

TomTroc is a PHP MVC book-exchange site with account/profile management and user-to-user messaging. A request enters through the public front controller, is dispatched by the router, and is handled by controllers that coordinate validation, authentication, repositories, and views. The sampled source confirms the book, account, and messaging paths; other documented capabilities are represented where their modules are present, but unsampled implementation details are not inferred. MySQL persistence is represented by the repository/database layer.

Main entry points: [`app/Controllers/UserController.php`](https://github.com/chrisanger59/tomtroc/blob/main/app/Controllers/UserController.php) (Account workflows), [`app/Core/View.php`](https://github.com/chrisanger59/tomtroc/blob/main/app/Core/View.php) (View renderer), [`app/Controllers/BookController.php`](https://github.com/chrisanger59/tomtroc/blob/main/app/Controllers/BookController.php) (Book workflows), [`app/Controllers/MailController.php`](https://github.com/chrisanger59/tomtroc/blob/main/app/Controllers/MailController.php) (Message workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web request and views"]
  node_front["Front controller<br/>[index.php]"]
  node_router["Action router<br/>[Router.php]"]
  node_view["View renderer<br/>[View.php]"]
end

subgraph group_books["Book exchange"]
  node_bookctl["Book workflows<br/>[BookController.php]"]
  node_bookrules["Book validation<br/>[BookValidator.php]"]
  node_image["Image uploads<br/>[ImageUploader.php]"]
  node_bookviews["Book pages"]
end

subgraph group_accounts["Accounts and profiles"]
  node_userctl["Account workflows<br/>[UserController.php]"]
  node_auth["Authentication<br/>[Auth.php]"]
  node_userrules["User validation<br/>[UserValidator.php]"]
  node_profileviews["Account pages"]
end

subgraph group_messages["Messaging"]
  node_mailctl["Message workflows<br/>[MailController.php]"]
  node_mailviews["Mailbox page<br/>[mailBox.php]"]
end

subgraph group_persistence["Domain and persistence"]
  node_bookrepo["Book repository<br/>[BookManager.php]"]
  node_userrepo["User repository<br/>[UserManager.php]"]
  node_messagerepo["Message repository<br/>[MessageManager.php]"]
  node_bookmodel["Book model<br/>[Book.php]"]
  node_usermodel["User model<br/>[User.php]"]
  node_messagemodel["Message model<br/>[Message.php]"]
  node_repositorybase["Repository base"]
  node_dbmanager["Database access<br/>[DBManager.php]"]
  node_database[("MySQL database<br/>[schema.sql]")]
end

node_visitor(("Site visitor"))

node_visitor -->|"requests pages"| node_front
node_front -->|"dispatches to"| node_router
node_router -->|"routes actions"| node_bookctl
node_router -->|"routes actions"| node_userctl
node_router -->|"routes actions"| node_mailctl
node_bookctl -->|"reads and writes"| node_bookrepo
node_bookctl -->|"validates input"| node_bookrules
node_bookctl -->|"uploads covers"| node_image
node_bookctl -->|"renders pages"| node_view
node_view -->|"renders template"| node_bookviews
node_userctl -->|"reads and writes"| node_userrepo
node_userctl -->|"loads user books"| node_bookrepo
node_userctl -->|"validates input"| node_userrules
node_userctl -->|"checks access"| node_auth
node_userctl -->|"uploads profile photo"| node_image
node_userctl -->|"renders pages"| node_view
node_view -->|"renders template"| node_profileviews
node_mailctl -->|"loads and sends"| node_messagerepo
node_mailctl -->|"loads recipient"| node_userrepo
node_mailctl -->|"requires login"| node_auth
node_mailctl -->|"renders mailbox"| node_view
node_view -->|"renders template"| node_mailviews
node_bookrepo -->|"hydrates books"| node_bookmodel
node_bookrepo -->|"hydrates owners"| node_usermodel
node_userrepo -->|"hydrates users"| node_usermodel
node_messagerepo -->|"hydrates messages"| node_messagemodel
node_messagerepo -->|"hydrates participants"| node_usermodel
node_bookrepo -->|"extends"| node_repositorybase
node_userrepo -->|"extends"| node_repositorybase
node_messagerepo -->|"extends"| node_repositorybase
node_repositorybase -->|"uses connection"| node_dbmanager
node_dbmanager -.->|"queries"| node_database

click node_front "https://github.com/chrisanger59/tomtroc/blob/main/public/index.php"
click node_router "https://github.com/chrisanger59/tomtroc/blob/main/app/Core/Router.php"
click node_view "https://github.com/chrisanger59/tomtroc/blob/main/app/Core/View.php"
click node_bookctl "https://github.com/chrisanger59/tomtroc/blob/main/app/Controllers/BookController.php"
click node_bookrules "https://github.com/chrisanger59/tomtroc/blob/main/app/Services/BookValidator.php"
click node_image "https://github.com/chrisanger59/tomtroc/blob/main/app/Services/ImageUploader.php"
click node_bookviews "https://github.com/chrisanger59/tomtroc/tree/main/app/Views"
click node_userctl "https://github.com/chrisanger59/tomtroc/blob/main/app/Controllers/UserController.php"
click node_auth "https://github.com/chrisanger59/tomtroc/blob/main/app/Services/Auth.php"
click node_userrules "https://github.com/chrisanger59/tomtroc/blob/main/app/Services/UserValidator.php"
click node_profileviews "https://github.com/chrisanger59/tomtroc/tree/main/app/Views"
click node_mailctl "https://github.com/chrisanger59/tomtroc/blob/main/app/Controllers/MailController.php"
click node_mailviews "https://github.com/chrisanger59/tomtroc/blob/main/app/Views/mailBox.php"
click node_bookrepo "https://github.com/chrisanger59/tomtroc/blob/main/app/Repositories/BookManager.php"
click node_userrepo "https://github.com/chrisanger59/tomtroc/blob/main/app/Repositories/UserManager.php"
click node_messagerepo "https://github.com/chrisanger59/tomtroc/blob/main/app/Repositories/MessageManager.php"
click node_bookmodel "https://github.com/chrisanger59/tomtroc/blob/main/app/Models/Book.php"
click node_usermodel "https://github.com/chrisanger59/tomtroc/blob/main/app/Models/User.php"
click node_messagemodel "https://github.com/chrisanger59/tomtroc/blob/main/app/Models/Message.php"
click node_repositorybase "https://github.com/chrisanger59/tomtroc/blob/main/app/Repositories/AbstractRepository.php"
click node_dbmanager "https://github.com/chrisanger59/tomtroc/blob/main/app/Core/DBManager.php"
click node_database "https://github.com/chrisanger59/tomtroc/blob/main/database/schema.sql"

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_front,node_router,node_view toneBlue
class node_bookctl,node_bookrules,node_image,node_bookviews toneAmber
class node_userctl,node_auth,node_userrules,node_profileviews toneMint
class node_mailctl,node_mailviews toneRose
class node_bookrepo,node_userrepo,node_messagerepo,node_bookmodel,node_usermodel,node_messagemodel,node_repositorybase,node_dbmanager,node_database,node_visitor toneIndigo
```

## Components

### Web request and views

- [Front controller](https://github.com/chrisanger59/tomtroc/blob/main/public/index.php): `public/index.php`
- [Action router](https://github.com/chrisanger59/tomtroc/blob/main/app/Core/Router.php): `app/Core/Router.php`
- [View renderer](https://github.com/chrisanger59/tomtroc/blob/main/app/Core/View.php): `app/Core/View.php`

### Book exchange

- [Book workflows](https://github.com/chrisanger59/tomtroc/blob/main/app/Controllers/BookController.php): `app/Controllers/BookController.php`
- [Book validation](https://github.com/chrisanger59/tomtroc/blob/main/app/Services/BookValidator.php): `app/Services/BookValidator.php`
- [Image uploads](https://github.com/chrisanger59/tomtroc/blob/main/app/Services/ImageUploader.php): `app/Services/ImageUploader.php`
- [Book pages](https://github.com/chrisanger59/tomtroc/tree/main/app/Views): `app/Views`

### Accounts and profiles

- [Account workflows](https://github.com/chrisanger59/tomtroc/blob/main/app/Controllers/UserController.php): `app/Controllers/UserController.php`
- [Authentication](https://github.com/chrisanger59/tomtroc/blob/main/app/Services/Auth.php): `app/Services/Auth.php`
- [User validation](https://github.com/chrisanger59/tomtroc/blob/main/app/Services/UserValidator.php): `app/Services/UserValidator.php`
- [Account pages](https://github.com/chrisanger59/tomtroc/tree/main/app/Views): `app/Views`

### Messaging

- [Message workflows](https://github.com/chrisanger59/tomtroc/blob/main/app/Controllers/MailController.php): `app/Controllers/MailController.php`
- [Mailbox page](https://github.com/chrisanger59/tomtroc/blob/main/app/Views/mailBox.php): `app/Views/mailBox.php`

### Domain and persistence

- [Book repository](https://github.com/chrisanger59/tomtroc/blob/main/app/Repositories/BookManager.php): `app/Repositories/BookManager.php`
- [User repository](https://github.com/chrisanger59/tomtroc/blob/main/app/Repositories/UserManager.php): `app/Repositories/UserManager.php`
- [Message repository](https://github.com/chrisanger59/tomtroc/blob/main/app/Repositories/MessageManager.php): `app/Repositories/MessageManager.php`
- [Book model](https://github.com/chrisanger59/tomtroc/blob/main/app/Models/Book.php): `app/Models/Book.php`
- [User model](https://github.com/chrisanger59/tomtroc/blob/main/app/Models/User.php): `app/Models/User.php`
- [Message model](https://github.com/chrisanger59/tomtroc/blob/main/app/Models/Message.php): `app/Models/Message.php`
- [Repository base](https://github.com/chrisanger59/tomtroc/blob/main/app/Repositories/AbstractRepository.php): `app/Repositories/AbstractRepository.php`
- [Database access](https://github.com/chrisanger59/tomtroc/blob/main/app/Core/DBManager.php): `app/Core/DBManager.php`
- [MySQL database](https://github.com/chrisanger59/tomtroc/blob/main/database/schema.sql): `database/schema.sql`

### Other components

- **Site visitor**

## Connections

- Site visitor → Front controller: requests pages (evidence: `README.md`)
- Front controller → Action router: dispatches to (evidence: `public/index.php`)
- Action router → Book workflows: routes actions (evidence: `app/Core/Router.php`)
- Action router → Account workflows: routes actions (evidence: `app/Core/Router.php`)
- Action router → Message workflows: routes actions (evidence: `app/Core/Router.php`)
- Book workflows → Book repository: reads and writes (evidence: `app/Controllers/BookController.php`)
- Book workflows → Book validation: validates input (evidence: `app/Controllers/BookController.php`)
- Book workflows → Image uploads: uploads covers (evidence: `app/Controllers/BookController.php`)
- Book workflows → View renderer: renders pages (evidence: `app/Controllers/BookController.php`)
- View renderer → Book pages: renders template (evidence: `app/Core/View.php`)
- Account workflows → User repository: reads and writes (evidence: `app/Controllers/UserController.php`)
- Account workflows → Book repository: loads user books (evidence: `app/Controllers/UserController.php`)
- Account workflows → User validation: validates input (evidence: `app/Controllers/UserController.php`)
- Account workflows → Authentication: checks access (evidence: `app/Controllers/UserController.php`)
- Account workflows → Image uploads: uploads profile photo (evidence: `app/Controllers/UserController.php`)
- Account workflows → View renderer: renders pages (evidence: `app/Controllers/UserController.php`)
- View renderer → Account pages: renders template (evidence: `app/Core/View.php`)
- Message workflows → Message repository: loads and sends (evidence: `app/Controllers/MailController.php`)
- Message workflows → User repository: loads recipient (evidence: `app/Controllers/MailController.php`)
- Message workflows → Authentication: requires login (evidence: `app/Controllers/MailController.php`)
- Message workflows → View renderer: renders mailbox (evidence: `app/Controllers/MailController.php`)
- View renderer → Mailbox page: renders template (evidence: `app/Core/View.php`)
- Book repository → Book model: hydrates books (evidence: `app/Repositories/BookManager.php`)
- Book repository → User model: hydrates owners (evidence: `app/Repositories/BookManager.php`)
- User repository → User model: hydrates users (evidence: `app/Repositories/UserManager.php`)
- Message repository → Message model: hydrates messages (evidence: `app/Repositories/MessageManager.php`)
- Message repository → User model: hydrates participants (evidence: `app/Repositories/MessageManager.php`)
- Book repository → Repository base: extends (evidence: `app/Repositories/BookManager.php`)
- User repository → Repository base: extends (evidence: `app/Repositories/UserManager.php`)
- Message repository → Repository base: extends (evidence: `app/Repositories/MessageManager.php`)
- Repository base → Database access: uses connection (evidence: `app/Repositories/AbstractRepository.php`)
- Database access → MySQL database: queries
