# phu9608-byte/comp1841-cw architecture

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

- Interactive diagram: https://gitdiagram.com/phu9608-byte/comp1841-cw
- Repository: https://github.com/phu9608-byte/comp1841-cw

## Overview

This is a PHP coursework forum with user accounts, module-organized posts, and private email-like messaging. Users enter through the home page, authenticate where required, browse or create posts, and access module, profile, and messaging features; administrators also manage users and content. The sampled code confirms post creation/editing, authentication lookup, database helpers, and the shared layout. Other capabilities are represented from the file tree; their internal wiring is not assumed where source was not sampled.

Main entry points: [`admin/addpost.php`](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/addpost.php) (Create post), [`Database/DatabaseConnection.php`](https://github.com/phu9608-byte/comp1841-cw/blob/master/Database/DatabaseConnection.php) (PDO connection), [`admin/editpost.php`](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/editpost.php) (Edit post), [`index.php`](https://github.com/phu9608-byte/comp1841-cw/blob/master/index.php) (Home entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web entry and auth"]
  node_home["Home entry<br/>[index.php]"]
  node_auth_check["Session check<br/>[check.php]"]
  node_login["Login validation<br/>[validate.php]"]
  node_login_page["Login page<br/>[login.php]"]
end

subgraph group_forum["Forum content"]
  node_post_routes["Post browsing<br/>[post.php]"]
  node_add_post["Create post<br/>[addpost.php]"]
  node_edit_post["Edit post<br/>[editpost.php]"]
end

subgraph group_accounts["Accounts and modules"]
  node_module_routes["Module browsing<br/>[module.php]"]
  node_module_manage["Module management<br/>[addmodule.php]"]
  node_user_routes["User profiles<br/>[user.php]"]
  node_user_manage["User administration<br/>[manage_user.php]"]
  node_register["Registration<br/>[register.php]"]
  node_profile_edit["Profile editing<br/>[edituser.php]"]
end

subgraph group_messaging["Private messaging"]
  node_chat["Messaging hub<br/>[chat.php]"]
  node_send_mail["Send message<br/>[sent_email.php]"]
  node_inbox["Inbox<br/>[receive_email.php]"]
end

subgraph group_data["Persistence and views"]
  node_post_list["Post list view<br/>[postlist.html.php]"]
  node_post_form["Post form<br/>[addpost.html.php]"]
  node_email_view["Inbox view"]
  node_db_functions["Database operations"]
  node_db_connection["PDO connection"]
  node_mysql[("MySQL database")]
  node_layout["Shared layout<br/>[layout.html.php]"]
end

node_visitor(("Visitor"))

node_visitor -->|"opens"| node_home
node_home -->|"checks session"| node_auth_check
node_home -->|"loads PDO"| node_db_connection
node_home -->|"renders through"| node_layout
node_login_page -->|"submits credentials"| node_login
node_login -->|"loads PDO"| node_db_connection
node_login -->|"looks up user"| node_db_functions
node_add_post -->|"requires access"| node_auth_check
node_add_post -->|"loads PDO"| node_db_connection
node_add_post -->|"inserts post"| node_db_functions
node_add_post -->|"renders form"| node_post_form
node_add_post -->|"renders through"| node_layout
node_edit_post -->|"requires access"| node_auth_check
node_edit_post -->|"loads PDO"| node_db_connection
node_edit_post -->|"reads and updates"| node_db_functions
node_edit_post -->|"renders through"| node_layout
node_post_routes -->|"renders listing"| node_post_list
node_inbox -->|"renders inbox"| node_email_view
node_layout -->|"counts inbox"| node_mysql
node_db_connection -->|"connects"| node_mysql
node_db_functions -->|"queries and mutates"| node_mysql

click node_home "https://github.com/phu9608-byte/comp1841-cw/blob/master/index.php"
click node_auth_check "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/auth/check.php"
click node_login "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/auth/validate.php"
click node_login_page "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/auth/login.php"
click node_post_routes "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/post.php"
click node_post_list "https://github.com/phu9608-byte/comp1841-cw/blob/master/Display/postlist.html.php"
click node_add_post "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/addpost.php"
click node_edit_post "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/editpost.php"
click node_post_form "https://github.com/phu9608-byte/comp1841-cw/blob/master/Display/addpost.html.php"
click node_module_routes "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/module.php"
click node_module_manage "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/addmodule.php"
click node_user_routes "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/user.php"
click node_user_manage "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/manage_user.php"
click node_register "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/register.php"
click node_profile_edit "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/edituser.php"
click node_chat "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/chat.php"
click node_send_mail "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/sent_email.php"
click node_inbox "https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/receive_email.php"
click node_email_view "https://github.com/phu9608-byte/comp1841-cw/blob/master/Display/receive_email.html.php"
click node_db_functions "https://github.com/phu9608-byte/comp1841-cw/blob/master/Database/DatabaseFunction.php"
click node_db_connection "https://github.com/phu9608-byte/comp1841-cw/blob/master/Database/DatabaseConnection.php"
click node_layout "https://github.com/phu9608-byte/comp1841-cw/blob/master/Display/layout.html.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_home,node_auth_check,node_login,node_login_page toneBlue
class node_post_routes,node_add_post,node_edit_post toneAmber
class node_module_routes,node_module_manage,node_user_routes,node_user_manage,node_register,node_profile_edit toneMint
class node_chat,node_send_mail,node_inbox toneRose
class node_post_list,node_post_form,node_email_view,node_db_functions,node_db_connection,node_mysql,node_layout,node_visitor toneIndigo
```

## Components

### Web entry and auth

- [Home entry](https://github.com/phu9608-byte/comp1841-cw/blob/master/index.php): `index.php`
- [Session check](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/auth/check.php): `admin/auth/check.php`
- [Login validation](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/auth/validate.php): `admin/auth/validate.php`
- [Login page](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/auth/login.php): `admin/auth/login.php`

### Forum content

- [Post browsing](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/post.php): `admin/post.php`
- [Create post](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/addpost.php): `admin/addpost.php`
- [Edit post](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/editpost.php): `admin/editpost.php`

### Accounts and modules

- [Module browsing](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/module.php): `admin/module.php`
- [Module management](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/addmodule.php): `admin/addmodule.php`
- [User profiles](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/user.php): `admin/user.php`
- [User administration](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/manage_user.php): `admin/manage_user.php`
- [Registration](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/register.php): `admin/register.php`
- [Profile editing](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/edituser.php): `admin/edituser.php`

### Private messaging

- [Messaging hub](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/chat.php): `admin/chat.php`
- [Send message](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/sent_email.php): `admin/sent_email.php`
- [Inbox](https://github.com/phu9608-byte/comp1841-cw/blob/master/admin/receive_email.php): `admin/receive_email.php`

### Persistence and views

- [Post list view](https://github.com/phu9608-byte/comp1841-cw/blob/master/Display/postlist.html.php): `Display/postlist.html.php`
- [Post form](https://github.com/phu9608-byte/comp1841-cw/blob/master/Display/addpost.html.php): `Display/addpost.html.php`
- [Inbox view](https://github.com/phu9608-byte/comp1841-cw/blob/master/Display/receive_email.html.php): `Display/receive_email.html.php`
- [Database operations](https://github.com/phu9608-byte/comp1841-cw/blob/master/Database/DatabaseFunction.php): `Database/DatabaseFunction.php`
- [PDO connection](https://github.com/phu9608-byte/comp1841-cw/blob/master/Database/DatabaseConnection.php): `Database/DatabaseConnection.php`
- **MySQL database**
- [Shared layout](https://github.com/phu9608-byte/comp1841-cw/blob/master/Display/layout.html.php): `Display/layout.html.php`

### Other components

- **Visitor**

## Connections

- Visitor → Home entry: opens
- Home entry → Session check: checks session
- Home entry → PDO connection: loads PDO
- Home entry → Shared layout: renders through
- Login page → Login validation: submits credentials
- Login validation → PDO connection: loads PDO
- Login validation → Database operations: looks up user
- Create post → Session check: requires access
- Create post → PDO connection: loads PDO
- Create post → Database operations: inserts post
- Create post → Post form: renders form
- Create post → Shared layout: renders through
- Edit post → Session check: requires access
- Edit post → PDO connection: loads PDO
- Edit post → Database operations: reads and updates
- Edit post → Shared layout: renders through
- Post browsing → Post list view: renders listing
- Inbox → Inbox view: renders inbox
- Shared layout → MySQL database: counts inbox
- PDO connection → MySQL database: connects
- Database operations → MySQL database: queries and mutates
