# gyroubounce/tomtroc architecture

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

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

## Overview

TomTroc is a PHP/MySQL book-trading application. Visitors browse and search available books; signed-in users can list books, manage their account and profile, and message other users. The request enters through the public front controller, which starts the session, initializes the installer and dispatches routes. Controllers coordinate domain managers, persistence, image processing and rendered pages. The graph follows the sampled call paths and documented capabilities; some home, static-page and routing details are known only from the README or SOURCE INDEX.

Main entry points: [`app/core/VIew.php`](https://github.com/gyroubounce/tomtroc/blob/main/app/core/VIew.php) (Template renderer), [`app/managers/UserManager.php`](https://github.com/gyroubounce/tomtroc/blob/main/app/managers/UserManager.php) (User records), [`app/core/Router.php`](https://github.com/gyroubounce/tomtroc/blob/main/app/core/Router.php) (Route dispatch), [`app/managers/BookManager.php`](https://github.com/gyroubounce/tomtroc/blob/main/app/managers/BookManager.php) (Book records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web entry"]
  node_front["HTTP front controller<br/>[index.php]"]
  node_router["Route dispatch<br/>[Router.php]"]
  node_installer["First-run setup<br/>[Installer.php]"]
  node_session["Session state<br/>[Session.php]"]
  node_home_controller["Home page<br/>[HomeController.php]"]
  node_static_controller["Legal pages"]
end

subgraph group_accounts["Accounts"]
  node_auth["Sign-in and registration<br/>[AuthController.php]"]
  node_users["Account and profile<br/>[UserController.php]"]
  node_user_manager["User records<br/>[UserManager.php]"]
  node_user_model["User model<br/>[User.php]"]
  node_account_views["Account pages<br/>[account.php]"]
  node_auth_views["Authentication pages<br/>[login.php]"]
end

subgraph group_books["Book exchange"]
  node_book_controller["Book listing and edits<br/>[BookController.php]"]
  node_book_manager["Book records<br/>[BookManager.php]"]
  node_book_model["Book model<br/>[Book.php]"]
  node_image_manager["Image processing<br/>[ImageManager.php]"]
  node_book_views["Book pages<br/>[index.php]"]
end

subgraph group_messaging["Messaging"]
  node_message_controller["Conversation workflow"]
  node_message_manager["Message records<br/>[MessageManager.php]"]
  node_message_model["Message model<br/>[Message.php]"]
  node_message_views["Conversation pages<br/>[index.php]"]
end

subgraph group_platform["Persistence and rendering"]
  node_view["Template renderer<br/>[VIew.php]"]
  node_database[("MySQL database")]
  node_database_layer["Database connection<br/>[Database.php]"]
end

node_visitor(("Visitor"))

node_visitor -->|"requests pages"| node_front
node_front -->|"starts session"| node_session
node_front -->|"runs setup"| node_installer
node_front -->|"dispatches request"| node_router
node_router -->|"routes auth"| node_auth
node_router -->|"routes accounts"| node_users
node_router -->|"routes books"| node_book_controller
node_router -->|"routes messages"| node_message_controller
node_router -->|"routes home"| node_home_controller
node_router -->|"routes legal pages"| node_static_controller
node_auth -->|"reads and creates users"| node_user_manager
node_auth -->|"sets login state"| node_session
node_auth -->|"renders forms"| node_view
node_user_manager -->|"gets connection"| node_database_layer
node_user_manager -->|"queries users"| node_database
node_user_manager -->|"hydrates users"| node_user_model
node_users -->|"loads and updates accounts"| node_user_manager
node_users -->|"loads user books"| node_book_manager
node_users -->|"processes profile image"| node_image_manager
node_users -->|"checks login"| node_session
node_users -->|"renders account"| node_view
node_book_controller -->|"searches and changes books"| node_book_manager
node_book_controller -->|"loads book owner"| node_user_manager
node_book_controller -->|"processes book image"| node_image_manager
node_book_controller -->|"checks login"| node_session
node_book_controller -->|"renders book pages"| node_view
node_book_manager -->|"gets connection"| node_database_layer
node_book_manager -->|"queries books"| node_database
node_book_manager -->|"hydrates books"| node_book_model
node_book_manager -->|"loads book owner"| node_user_manager
node_message_controller -->|"loads and sends messages"| node_message_manager
node_message_controller -->|"loads conversation users"| node_user_manager
node_message_controller -->|"checks login"| node_session
node_message_controller -->|"renders conversations"| node_view
node_message_manager -->|"gets connection"| node_database_layer
node_message_manager -->|"queries messages"| node_database
node_home_controller -->|"loads latest books"| node_book_manager
node_home_controller -->|"loads users"| node_user_manager
node_home_controller -.->|"renders home"| node_view
node_static_controller -.->|"renders legal pages"| node_view
node_view -.->|"renders account template"| node_account_views
node_view -.->|"renders auth template"| node_auth_views
node_view -.->|"renders book template"| node_book_views
node_view -.->|"renders message template"| node_message_views
node_database_layer -->|"connects MySQL"| node_database
node_installer -->|"uses connection"| node_database_layer

click node_front "https://github.com/gyroubounce/tomtroc/blob/main/public/index.php"
click node_router "https://github.com/gyroubounce/tomtroc/blob/main/app/core/Router.php"
click node_installer "https://github.com/gyroubounce/tomtroc/blob/main/app/core/Installer.php"
click node_session "https://github.com/gyroubounce/tomtroc/blob/main/app/core/Session.php"
click node_auth "https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/AuthController.php"
click node_users "https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/UserController.php"
click node_user_manager "https://github.com/gyroubounce/tomtroc/blob/main/app/managers/UserManager.php"
click node_user_model "https://github.com/gyroubounce/tomtroc/blob/main/app/models/User.php"
click node_account_views "https://github.com/gyroubounce/tomtroc/blob/main/app/Views/users/account.php"
click node_auth_views "https://github.com/gyroubounce/tomtroc/blob/main/app/Views/auth/login.php"
click node_book_controller "https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/BookController.php"
click node_book_manager "https://github.com/gyroubounce/tomtroc/blob/main/app/managers/BookManager.php"
click node_book_model "https://github.com/gyroubounce/tomtroc/blob/main/app/models/Book.php"
click node_image_manager "https://github.com/gyroubounce/tomtroc/blob/main/app/services/ImageManager.php"
click node_book_views "https://github.com/gyroubounce/tomtroc/blob/main/app/Views/books/index.php"
click node_message_controller "https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/MessageController.php"
click node_message_manager "https://github.com/gyroubounce/tomtroc/blob/main/app/managers/MessageManager.php"
click node_message_model "https://github.com/gyroubounce/tomtroc/blob/main/app/models/Message.php"
click node_message_views "https://github.com/gyroubounce/tomtroc/blob/main/app/Views/messages/index.php"
click node_home_controller "https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/HomeController.php"
click node_static_controller "https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/StaticController.php"
click node_view "https://github.com/gyroubounce/tomtroc/blob/main/app/core/VIew.php"
click node_database_layer "https://github.com/gyroubounce/tomtroc/blob/main/app/core/Database.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_front,node_router,node_installer,node_session,node_home_controller,node_static_controller toneBlue
class node_auth,node_users,node_user_manager,node_user_model,node_account_views,node_auth_views toneAmber
class node_book_controller,node_book_manager,node_book_model,node_image_manager,node_book_views toneMint
class node_message_controller,node_message_manager,node_message_model,node_message_views toneRose
class node_view,node_database,node_database_layer,node_visitor toneIndigo
```

## Components

### Web entry

- [HTTP front controller](https://github.com/gyroubounce/tomtroc/blob/main/public/index.php): `public/index.php`
- [Route dispatch](https://github.com/gyroubounce/tomtroc/blob/main/app/core/Router.php): `app/core/Router.php`
- [First-run setup](https://github.com/gyroubounce/tomtroc/blob/main/app/core/Installer.php): `app/core/Installer.php`
- [Session state](https://github.com/gyroubounce/tomtroc/blob/main/app/core/Session.php): `app/core/Session.php`
- [Home page](https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/HomeController.php): `app/controllers/HomeController.php`
- [Legal pages](https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/StaticController.php): `app/controllers/StaticController.php`

### Accounts

- [Sign-in and registration](https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/AuthController.php): `app/controllers/AuthController.php`
- [Account and profile](https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/UserController.php): `app/controllers/UserController.php`
- [User records](https://github.com/gyroubounce/tomtroc/blob/main/app/managers/UserManager.php): `app/managers/UserManager.php`
- [User model](https://github.com/gyroubounce/tomtroc/blob/main/app/models/User.php): `app/models/User.php`
- [Account pages](https://github.com/gyroubounce/tomtroc/blob/main/app/Views/users/account.php): `app/Views/users/account.php`
- [Authentication pages](https://github.com/gyroubounce/tomtroc/blob/main/app/Views/auth/login.php): `app/Views/auth/login.php`

### Book exchange

- [Book listing and edits](https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/BookController.php): `app/controllers/BookController.php`
- [Book records](https://github.com/gyroubounce/tomtroc/blob/main/app/managers/BookManager.php): `app/managers/BookManager.php`
- [Book model](https://github.com/gyroubounce/tomtroc/blob/main/app/models/Book.php): `app/models/Book.php`
- [Image processing](https://github.com/gyroubounce/tomtroc/blob/main/app/services/ImageManager.php): `app/services/ImageManager.php`
- [Book pages](https://github.com/gyroubounce/tomtroc/blob/main/app/Views/books/index.php): `app/Views/books/index.php`

### Messaging

- [Conversation workflow](https://github.com/gyroubounce/tomtroc/blob/main/app/controllers/MessageController.php): `app/controllers/MessageController.php`
- [Message records](https://github.com/gyroubounce/tomtroc/blob/main/app/managers/MessageManager.php): `app/managers/MessageManager.php`
- [Message model](https://github.com/gyroubounce/tomtroc/blob/main/app/models/Message.php): `app/models/Message.php`
- [Conversation pages](https://github.com/gyroubounce/tomtroc/blob/main/app/Views/messages/index.php): `app/Views/messages/index.php`

### Persistence and rendering

- [Template renderer](https://github.com/gyroubounce/tomtroc/blob/main/app/core/VIew.php): `app/core/VIew.php`
- **MySQL database**
- [Database connection](https://github.com/gyroubounce/tomtroc/blob/main/app/core/Database.php): `app/core/Database.php`

### Other components

- **Visitor**

## Connections

- Visitor → HTTP front controller: requests pages (evidence: `public/index.php`)
- HTTP front controller → Session state: starts session (evidence: `public/index.php`)
- HTTP front controller → First-run setup: runs setup (evidence: `public/index.php`)
- HTTP front controller → Route dispatch: dispatches request (evidence: `public/index.php`)
- Route dispatch → Sign-in and registration: routes auth (evidence: `public/index.php`)
- Route dispatch → Account and profile: routes accounts (evidence: `public/index.php`)
- Route dispatch → Book listing and edits: routes books (evidence: `public/index.php`)
- Route dispatch → Conversation workflow: routes messages (evidence: `public/index.php`)
- Route dispatch → Home page: routes home (evidence: `public/index.php`)
- Route dispatch → Legal pages: routes legal pages (evidence: `public/index.php`)
- Sign-in and registration → User records: reads and creates users (evidence: `app/controllers/AuthController.php`)
- Sign-in and registration → Session state: sets login state (evidence: `app/controllers/AuthController.php`)
- Sign-in and registration → Template renderer: renders forms (evidence: `app/controllers/AuthController.php`)
- User records → Database connection: gets connection (evidence: `app/managers/UserManager.php`)
- User records → MySQL database: queries users (evidence: `app/managers/UserManager.php`)
- User records → User model: hydrates users (evidence: `app/managers/UserManager.php`)
- Account and profile → User records: loads and updates accounts (evidence: `app/controllers/UserController.php`)
- Account and profile → Book records: loads user books (evidence: `app/controllers/UserController.php`)
- Account and profile → Image processing: processes profile image (evidence: `app/controllers/UserController.php`)
- Account and profile → Session state: checks login (evidence: `app/controllers/UserController.php`)
- Account and profile → Template renderer: renders account (evidence: `app/controllers/UserController.php`)
- Book listing and edits → Book records: searches and changes books (evidence: `app/controllers/BookController.php`)
- Book listing and edits → User records: loads book owner (evidence: `app/controllers/BookController.php`)
- Book listing and edits → Image processing: processes book image (evidence: `app/controllers/BookController.php`)
- Book listing and edits → Session state: checks login (evidence: `app/controllers/BookController.php`)
- Book listing and edits → Template renderer: renders book pages (evidence: `app/controllers/BookController.php`)
- Book records → Database connection: gets connection (evidence: `app/managers/BookManager.php`)
- Book records → MySQL database: queries books (evidence: `app/managers/BookManager.php`)
- Book records → Book model: hydrates books (evidence: `app/managers/BookManager.php`)
- Book records → User records: loads book owner (evidence: `app/managers/BookManager.php`)
- Conversation workflow → Message records: loads and sends messages (evidence: `app/controllers/MessageController.php`)
- Conversation workflow → User records: loads conversation users (evidence: `app/controllers/MessageController.php`)
- Conversation workflow → Session state: checks login (evidence: `app/controllers/MessageController.php`)
- Conversation workflow → Template renderer: renders conversations (evidence: `app/controllers/MessageController.php`)
- Message records → Database connection: gets connection (evidence: `app/managers/MessageManager.php`)
- Message records → MySQL database: queries messages (evidence: `app/managers/MessageManager.php`)
- Home page → Book records: loads latest books (evidence: `app/controllers/HomeController.php`)
- Home page → User records: loads users (evidence: `app/controllers/HomeController.php`)
- Home page → Template renderer: renders home
- Legal pages → Template renderer: renders legal pages
- Template renderer → Account pages: renders account template
- Template renderer → Authentication pages: renders auth template
- Template renderer → Book pages: renders book template
- Template renderer → Conversation pages: renders message template
- Database connection → MySQL database: connects MySQL (evidence: `app/core/Database.php`)
- First-run setup → Database connection: uses connection (evidence: `app/core/Installer.php`)
