# jp-btrd/cinebai architecture

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

- Interactive diagram: https://gitdiagram.com/jp-btrd/cinebai
- Repository: https://github.com/jp-btrd/cinebai

## Overview

Cine Bai is a PHP/MySQL cinema ticketing site for moviegoers and cinema administrators. Moviegoers register or sign in, browse and filter films, inspect details and showtimes, then select seats and book at a server-calculated discounted price; they can review, cancel, and print tickets. Administrators manage movies, showtimes, bookings, and accounts, and view sales summaries. Shared helpers provide session guards, CSRF, discounts, and booking rules. Edges reflect README workflows and sampled call/reference evidence; unsampled page internals are not inferred.

Main entry points: [`db.php`](https://github.com/jp-btrd/cinebai/blob/main/db.php) (PDO connection), [`includes.php`](https://github.com/jp-btrd/cinebai/blob/main/includes.php) (Session and booking rules), [`admin/movie_helpers.php`](https://github.com/jp-btrd/cinebai/blob/main/admin/movie_helpers.php) (Movie management), [`bookings.php`](https://github.com/jp-btrd/cinebai/blob/main/bookings.php) (My bookings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_accounts["Accounts"]
  node_login["Sign in<br/>[login.php]"]
  node_register["Registration<br/>[register.php]"]
  node_profile["Profile settings<br/>[profile.php]"]
end

subgraph group_catalog["Movie catalog"]
  node_movies["Movie browser<br/>[movies.php]"]
  node_movie_detail["Movie details<br/>[movie.php]"]
end

subgraph group_ticketing["Ticketing"]
  node_book["Seat selection and booking<br/>[book.php]"]
  node_my_bookings["My bookings<br/>[bookings.php]"]
  node_cancel["Booking cancellation<br/>[booking_cancel.php]"]
  node_ticket["Printable ticket<br/>[ticket.php]"]
end

subgraph group_admin["Administration"]
  node_movie_admin["Movie management<br/>[movie_helpers.php]"]
  node_movie_form["Movie editor form<br/>[movie_form.php]"]
  node_showtime_admin["Showtime management"]
  node_showtime_form["Showtime editor form<br/>[showtime_form.php]"]
  node_admin_bookings["Booking oversight<br/>[bookings.php]"]
  node_users_admin["User administration<br/>[user_helpers.php]"]
  node_dashboard["Sales dashboard<br/>[dashboard.php]"]
  node_admin_nav["Admin navigation<br/>[admin_nav.php]"]
end

subgraph group_shared["Shared runtime"]
  node_shared_helpers["Session and booking rules<br/>[includes.php]"]
  node_db_connection["PDO connection<br/>[db.php]"]
  node_database[("Cinema data<br/>[schema.sql]")]
  node_header["Shared page header<br/>[header.php]"]
  node_footer["Shared page footer<br/>[footer.php]"]
end

node_visitor(("Moviegoer"))
node_admin_actor(("Administrator"))

node_visitor -->|"creates account"| node_register
node_visitor -->|"signs in"| node_login
node_visitor -->|"browses films"| node_movies
node_movies -->|"opens details"| node_movie_detail
node_movie_detail -->|"chooses showtime"| node_book
node_book -->|"creates booking"| node_my_bookings
node_visitor -->|"reviews bookings"| node_my_bookings
node_my_bookings -->|"requests cancellation"| node_cancel
node_my_bookings -->|"prints e-ticket"| node_ticket
node_visitor -->|"updates account"| node_profile
node_admin_actor -->|"views metrics"| node_dashboard
node_admin_actor -->|"manages movies"| node_movie_admin
node_movie_admin -->|"uses form"| node_movie_form
node_admin_actor -->|"manages showtimes"| node_showtime_admin
node_showtime_admin -->|"uses form"| node_showtime_form
node_admin_actor -->|"filters bookings"| node_admin_bookings
node_admin_actor -->|"manages accounts"| node_users_admin
node_login -->|"checks session"| node_shared_helpers
node_book -->|"validates seats"| node_shared_helpers
node_book -->|"loads PDO"| node_db_connection
node_db_connection -->|"connects to"| node_database
node_profile -->|"updates user"| node_db_connection
node_admin_bookings -->|"queries bookings"| node_db_connection
node_dashboard -->|"queries totals"| node_db_connection
node_movie_admin -->|"uses guards"| node_shared_helpers
node_showtime_admin -->|"uses guards"| node_shared_helpers
node_movie_admin -->|"writes catalog"| node_db_connection
node_showtime_admin -->|"writes schedule"| node_db_connection
node_users_admin -->|"updates users"| node_db_connection
node_admin_bookings -->|"reads records"| node_db_connection
node_movies -->|"reads catalog"| node_db_connection
node_movie_detail -->|"reads showtimes"| node_db_connection
node_my_bookings -->|"reads bookings"| node_db_connection
node_cancel -->|"calls cancellation"| node_shared_helpers
node_header -->|"renders CSRF"| node_shared_helpers
node_movie_admin -->|"includes navigation"| node_admin_nav

click node_login "https://github.com/jp-btrd/cinebai/blob/main/login.php"
click node_register "https://github.com/jp-btrd/cinebai/blob/main/register.php"
click node_profile "https://github.com/jp-btrd/cinebai/blob/main/profile.php"
click node_movies "https://github.com/jp-btrd/cinebai/blob/main/movies.php"
click node_movie_detail "https://github.com/jp-btrd/cinebai/blob/main/movie.php"
click node_movie_admin "https://github.com/jp-btrd/cinebai/blob/main/admin/movie_helpers.php"
click node_movie_form "https://github.com/jp-btrd/cinebai/blob/main/admin/movie_form.php"
click node_showtime_admin "https://github.com/jp-btrd/cinebai/blob/main/admin/showtime_helpers.php"
click node_showtime_form "https://github.com/jp-btrd/cinebai/blob/main/admin/showtime_form.php"
click node_book "https://github.com/jp-btrd/cinebai/blob/main/book.php"
click node_my_bookings "https://github.com/jp-btrd/cinebai/blob/main/bookings.php"
click node_cancel "https://github.com/jp-btrd/cinebai/blob/main/booking_cancel.php"
click node_ticket "https://github.com/jp-btrd/cinebai/blob/main/ticket.php"
click node_admin_bookings "https://github.com/jp-btrd/cinebai/blob/main/admin/bookings.php"
click node_users_admin "https://github.com/jp-btrd/cinebai/blob/main/admin/user_helpers.php"
click node_dashboard "https://github.com/jp-btrd/cinebai/blob/main/admin/dashboard.php"
click node_admin_nav "https://github.com/jp-btrd/cinebai/blob/main/admin/admin_nav.php"
click node_shared_helpers "https://github.com/jp-btrd/cinebai/blob/main/includes.php"
click node_db_connection "https://github.com/jp-btrd/cinebai/blob/main/db.php"
click node_database "https://github.com/jp-btrd/cinebai/blob/main/schema.sql"
click node_header "https://github.com/jp-btrd/cinebai/blob/main/header.php"
click node_footer "https://github.com/jp-btrd/cinebai/blob/main/footer.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_login,node_register,node_profile toneBlue
class node_movies,node_movie_detail toneAmber
class node_book,node_my_bookings,node_cancel,node_ticket toneMint
class node_movie_admin,node_movie_form,node_showtime_admin,node_showtime_form,node_admin_bookings,node_users_admin,node_dashboard,node_admin_nav toneRose
class node_shared_helpers,node_db_connection,node_database,node_header,node_footer,node_visitor,node_admin_actor toneIndigo
```

## Components

### Accounts

- [Sign in](https://github.com/jp-btrd/cinebai/blob/main/login.php): `login.php`
- [Registration](https://github.com/jp-btrd/cinebai/blob/main/register.php): `register.php`
- [Profile settings](https://github.com/jp-btrd/cinebai/blob/main/profile.php): `profile.php`

### Movie catalog

- [Movie browser](https://github.com/jp-btrd/cinebai/blob/main/movies.php): `movies.php`
- [Movie details](https://github.com/jp-btrd/cinebai/blob/main/movie.php): `movie.php`

### Ticketing

- [Seat selection and booking](https://github.com/jp-btrd/cinebai/blob/main/book.php): `book.php`
- [My bookings](https://github.com/jp-btrd/cinebai/blob/main/bookings.php): `bookings.php`
- [Booking cancellation](https://github.com/jp-btrd/cinebai/blob/main/booking_cancel.php): `booking_cancel.php`
- [Printable ticket](https://github.com/jp-btrd/cinebai/blob/main/ticket.php): `ticket.php`

### Administration

- [Movie management](https://github.com/jp-btrd/cinebai/blob/main/admin/movie_helpers.php): `admin/movie_helpers.php`
- [Movie editor form](https://github.com/jp-btrd/cinebai/blob/main/admin/movie_form.php): `admin/movie_form.php`
- [Showtime management](https://github.com/jp-btrd/cinebai/blob/main/admin/showtime_helpers.php): `admin/showtime_helpers.php`
- [Showtime editor form](https://github.com/jp-btrd/cinebai/blob/main/admin/showtime_form.php): `admin/showtime_form.php`
- [Booking oversight](https://github.com/jp-btrd/cinebai/blob/main/admin/bookings.php): `admin/bookings.php`
- [User administration](https://github.com/jp-btrd/cinebai/blob/main/admin/user_helpers.php): `admin/user_helpers.php`
- [Sales dashboard](https://github.com/jp-btrd/cinebai/blob/main/admin/dashboard.php): `admin/dashboard.php`
- [Admin navigation](https://github.com/jp-btrd/cinebai/blob/main/admin/admin_nav.php): `admin/admin_nav.php`

### Shared runtime

- [Session and booking rules](https://github.com/jp-btrd/cinebai/blob/main/includes.php): `includes.php`
- [PDO connection](https://github.com/jp-btrd/cinebai/blob/main/db.php): `db.php`
- [Cinema data](https://github.com/jp-btrd/cinebai/blob/main/schema.sql): `schema.sql`
- [Shared page header](https://github.com/jp-btrd/cinebai/blob/main/header.php): `header.php`
- [Shared page footer](https://github.com/jp-btrd/cinebai/blob/main/footer.php): `footer.php`

### Other components

- **Moviegoer**
- **Administrator**

## Connections

- Moviegoer → Registration: creates account (evidence: `README.txt`)
- Moviegoer → Sign in: signs in (evidence: `README.txt`)
- Moviegoer → Movie browser: browses films (evidence: `README.txt`)
- Movie browser → Movie details: opens details (evidence: `README.txt`)
- Movie details → Seat selection and booking: chooses showtime (evidence: `README.txt`)
- Seat selection and booking → My bookings: creates booking (evidence: `book.php`)
- Moviegoer → My bookings: reviews bookings (evidence: `README.txt`)
- My bookings → Booking cancellation: requests cancellation (evidence: `README.txt`)
- My bookings → Printable ticket: prints e-ticket (evidence: `README.txt`)
- Moviegoer → Profile settings: updates account (evidence: `README.txt`)
- Administrator → Sales dashboard: views metrics (evidence: `README.txt`)
- Administrator → Movie management: manages movies (evidence: `README.txt`)
- Movie management → Movie editor form: uses form (evidence: `admin/movie_add.php`)
- Administrator → Showtime management: manages showtimes (evidence: `README.txt`)
- Showtime management → Showtime editor form: uses form (evidence: `admin/showtime_edit.php`)
- Administrator → Booking oversight: filters bookings (evidence: `README.txt`)
- Administrator → User administration: manages accounts (evidence: `README.txt`)
- Sign in → Session and booking rules: checks session (evidence: `login.php`)
- Seat selection and booking → Session and booking rules: validates seats (evidence: `book.php`)
- Seat selection and booking → PDO connection: loads PDO (evidence: `book.php`)
- PDO connection → Cinema data: connects to (evidence: `README.txt`)
- Profile settings → PDO connection: updates user (evidence: `profile.php`)
- Booking oversight → PDO connection: queries bookings (evidence: `admin/bookings.php`)
- Sales dashboard → PDO connection: queries totals (evidence: `admin/dashboard.php`)
- Movie management → Session and booking rules: uses guards (evidence: `admin/movie_add.php`)
- Showtime management → Session and booking rules: uses guards (evidence: `admin/showtime_edit.php`)
- Movie management → PDO connection: writes catalog (evidence: `admin/movie_add.php`)
- Showtime management → PDO connection: writes schedule (evidence: `admin/showtime_edit.php`)
- User administration → PDO connection: updates users (evidence: `admin/user_role.php`)
- Booking oversight → PDO connection: reads records (evidence: `admin/bookings.php`)
- Movie browser → PDO connection: reads catalog (evidence: `movies.php`)
- Movie details → PDO connection: reads showtimes (evidence: `movie.php`)
- My bookings → PDO connection: reads bookings (evidence: `bookings.php`)
- Booking cancellation → Session and booking rules: calls cancellation (evidence: `booking_cancel.php`)
- Shared page header → Session and booking rules: renders CSRF (evidence: `header.php`)
- Movie management → Admin navigation: includes navigation
