# akshit926/toastmasters architecture

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

- Interactive diagram: https://gitdiagram.com/akshit926/toastmasters
- Repository: https://github.com/akshit926/toastmasters

## Overview

1. **System shape**
   - This repo is a three-part system: a **static browser frontend** in `frontend/`, an **Express/Node backend** in `backend/`, and a **MySQL database** managed through SQL scripts in `backend/database/`.
   - The backend is the application boundary: it serves the UI, exposes REST endpoints, performs workflow logic, sends emails, and persists state.

2. **Frontend boundary**
   - The frontend is plain **HTML/CSS/JavaScript**, not a SPA framework.
   - Key entry pages suggest distinct user roles and flows: `index.html`, `form.html`, `member.html`, `admin.html`, `roles.html`, `contacts.html`-style flows via scripts, plus informational pages like `what-to-expect.html` and `access.html`.
   - Frontend JS files (`form.js`, `member.js`, `admin.js`, `roles.js`, `script.js`) call backend APIs directly and render role-specific actions and status.

3. **Backend runtime**
   - `backend/server.js` is the central Express bootstrap: it wires middleware, routes, static file serving, CORS, and startup behavior.
   - The backend is organized by responsibility:
     - `routes/` for HTTP routing
     - `controllers/` for request handling and business rules
     - `services/` for reusable integrations like email
     - `config/` for database connection setup
     - `database/` for schema and migration logic

4. **Member onboarding flow**
   - Member registration originates from the frontend form and hits `routes/members.js` → `controllers/memberController.js`.
   - The flow persists member data in MySQL, then likely triggers a notification through `services/emailService.js`.
   - The readme’s “Customer ID-based login” and `frontend/member.js` indicate members later authenticate or identify themselves using a customer/member ID to view assigned roles.

5. **Role allocation workflow**
   - Role requests are handled through `routes/roles.js` → `controllers/roleController.js`.
   - The data model includes a workflow state machine: **Pending → Approved → Assigned**, with branches for **Rejected** and **Cancelled**.
   - This is the core approval boundary in the system: members request a role, admins decide, and the backend updates assignment status accordingly.

6. **Admin control plane**
   - `frontend/admin.html` and `frontend/admin.js` implement the admin dashboard for reviewing and acting on role requests.
   - Admin operations exposed by `roles.js` include approve/reject and cancellation handling; the readme also mentions delete actions and bulk management.
   - This makes the admin dashboard the operational control plane for the role workflow.

7. **Club member management**
   - `routes/clubMembers.js` → `controllers/clubMemberController.js` appears to be the separate CRUD surface for club member records.
   - The readme calls out **CSV upload**, which suggests this subsystem handles batch onboarding and maintenance of the club roster, distinct from public member registration.
   - This is likely the administrative source of truth for internal club membership data.

8. **Contact / message intake**
   - `routes/contacts.js` → `controllers/contactController.js` handles contact submissions and retrieval.
   - This is a separate inbound communication path from member registration and role requests, likely used for general inquiries or support.

9. **Database layer**
   - The schema is relational and centered on tables named in the readme: `members`, `roles`, `member_roles`, `contacts`, and `club_members`.
   - SQL files in `backend/database/` define and manage the schema: `schema.sql`, `members_setup.sql`, `clear_roles.sql`, and `query.sql`.
   - `migrate.js` indicates the app can initialize or update the database automatically on startup, which matters for deployment and diagramming the boot sequence.

10. **Email integration**
   - `backend/services/emailService.js` is the outbound notification subsystem.
   - The readme says it uses **Nodemailer with Gmail** and sends emails for registration, role requests, cancellations, and admin approval/rejection.
   - One-click action links in email are an important architecture detail: email is not just notification, but an alternate control surface into the role workflow.

11. **Configuration and deployment**
   - `backend/config/db.js` encapsulates environment-driven DB connectivity, including support for **Cloud SQL via Unix sockets** as well as local MySQL.
   - Environment variables also drive CORS, email credentials, port binding, and public base URL, so deployment behavior is configuration-heavy.
   - The `Dockerfile` and readme show the backend is intended for **Google Cloud Run**, while the frontend can be deployed statically elsewhere and pointed at the backend API.

12. **Main data flows to draw**
   - **Member registration:** browser form → members API → MySQL → email notification.
   - **Role request/approval:** member portal → roles API → pending record in MySQL → admin dashboard or email action link → approve/reject/cancel update.
   - **Club roster admin:** admin UI → club members API → MySQL, with optional CSV bulk upload.
   - **Contact submissions:** frontend contact form → contacts API → MySQL and/or email handling.

13. **Key architectural boundary**
   - The most important boundary is between the **static client UI** and the **stateful backend workflow engine**.
   - Everything business-critical—approval state, member records, club roster, and email-driven actions—lives behind the Express API and is persisted in MySQL.

Main entry points: [`backend/routes/roles.js`](https://github.com/akshit926/toastmasters/blob/main/backend/routes/roles.js) (Roles API), [`backend/server.js`](https://github.com/akshit926/toastmasters/blob/main/backend/server.js) (Server entry), [`backend/database/schema.sql`](https://github.com/akshit926/toastmasters/blob/main/backend/database/schema.sql) (Schema SQL), [`backend/config/db.js`](https://github.com/akshit926/toastmasters/blob/main/backend/config/db.js) (DB config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_shell["Site pages<br/>static ui<br/>[index.html]"]
  node_frontend_form["Registration form<br/>member intake ui<br/>[form.html]"]
  node_frontend_member["Member portal<br/>[member.html]"]
  node_frontend_admin["Admin dashboard<br/>admin control ui<br/>[admin.html]"]
  node_frontend_roles["Role requests<br/>workflow ui<br/>[roles.html]"]
  node_frontend_shared_js["Client scripts<br/>browser logic<br/>[script.js]"]
end

subgraph group_backend["Backend"]
  node_backend_server["Server entry<br/>express bootstrap<br/>[server.js]"]
  node_backend_members_route["Members API<br/>route<br/>[members.js]"]
  node_backend_roles_route["Roles API<br/>route<br/>[roles.js]"]
  node_backend_club_route["Club members API<br/>route<br/>[clubMembers.js]"]
  node_backend_contacts_route["Contacts API<br/>route<br/>[contacts.js]"]
  node_backend_member_controller["Member logic<br/>controller"]
  node_backend_role_controller["Role logic<br/>controller<br/>[roleController.js]"]
  node_backend_club_controller["Club logic<br/>controller"]
  node_backend_contact_controller["Contact logic<br/>controller"]
  node_backend_email["Email service<br/>notification integration<br/>[emailService.js]"]
  node_backend_db_config["DB config<br/>connection config<br/>[db.js]"]
  node_backend_migrate["Migrate<br/>startup db task<br/>[migrate.js]"]
end

subgraph group_database["Database"]
  node_db_schema[("Schema SQL<br/>schema script<br/>[schema.sql]")]
  node_db_members_setup[("Members setup<br/>seed script<br/>[members_setup.sql]")]
  node_db_clear_roles[("Clear roles<br/>maintenance sql<br/>[clear_roles.sql]")]
  node_db_query[("Query SQL<br/>query script<br/>[query.sql]")]
end

node_frontend_form -->|"submit signup"| node_backend_members_route
node_frontend_member -->|"view roles"| node_backend_roles_route
node_frontend_roles -->|"request action"| node_backend_roles_route
node_frontend_admin -->|"moderate"| node_backend_roles_route
node_frontend_admin -->|"manage roster"| node_backend_club_route
node_frontend_shared_js -->|"API calls"| node_backend_members_route
node_frontend_shared_js -->|"API calls"| node_backend_roles_route
node_frontend_shared_js -->|"API calls"| node_backend_contacts_route
node_backend_server -->|"mounts"| node_backend_members_route
node_backend_server -->|"mounts"| node_backend_roles_route
node_backend_server -->|"mounts"| node_backend_club_route
node_backend_server -->|"mounts"| node_backend_contacts_route
node_backend_members_route -->|"delegates"| node_backend_member_controller
node_backend_roles_route -->|"delegates"| node_backend_role_controller
node_backend_club_route -->|"delegates"| node_backend_club_controller
node_backend_contacts_route -->|"delegates"| node_backend_contact_controller
node_backend_member_controller -->|"persists via"| node_backend_db_config
node_backend_role_controller -->|"persists via"| node_backend_db_config
node_backend_club_controller -->|"persists via"| node_backend_db_config
node_backend_contact_controller -->|"persists via"| node_backend_db_config
node_backend_member_controller -->|"notifies"| node_backend_email
node_backend_role_controller -->|"notifies"| node_backend_email
node_backend_migrate -->|"creates"| node_db_schema
node_backend_migrate -->|"initializes"| node_db_members_setup
node_backend_role_controller -->|"reads/writes"| node_db_schema
node_backend_member_controller -->|"reads/writes"| node_db_schema
node_backend_club_controller -->|"reads/writes"| node_db_schema
node_backend_contact_controller -->|"reads/writes"| node_db_schema
node_backend_server -->|"starts"| node_backend_migrate
node_backend_db_config -.->|"connects to"| node_db_schema

click node_frontend_shell "https://github.com/akshit926/toastmasters/blob/main/frontend/index.html"
click node_frontend_form "https://github.com/akshit926/toastmasters/blob/main/frontend/form.html"
click node_frontend_member "https://github.com/akshit926/toastmasters/blob/main/frontend/member.html"
click node_frontend_admin "https://github.com/akshit926/toastmasters/blob/main/frontend/admin.html"
click node_frontend_roles "https://github.com/akshit926/toastmasters/blob/main/frontend/roles.html"
click node_frontend_shared_js "https://github.com/akshit926/toastmasters/blob/main/frontend/script.js"
click node_backend_server "https://github.com/akshit926/toastmasters/blob/main/backend/server.js"
click node_backend_members_route "https://github.com/akshit926/toastmasters/blob/main/backend/routes/members.js"
click node_backend_roles_route "https://github.com/akshit926/toastmasters/blob/main/backend/routes/roles.js"
click node_backend_club_route "https://github.com/akshit926/toastmasters/blob/main/backend/routes/clubMembers.js"
click node_backend_contacts_route "https://github.com/akshit926/toastmasters/blob/main/backend/routes/contacts.js"
click node_backend_member_controller "https://github.com/akshit926/toastmasters/blob/main/backend/controllers/memberController.js"
click node_backend_role_controller "https://github.com/akshit926/toastmasters/blob/main/backend/controllers/roleController.js"
click node_backend_club_controller "https://github.com/akshit926/toastmasters/blob/main/backend/controllers/clubMemberController.js"
click node_backend_contact_controller "https://github.com/akshit926/toastmasters/blob/main/backend/controllers/contactController.js"
click node_backend_email "https://github.com/akshit926/toastmasters/blob/main/backend/services/emailService.js"
click node_backend_db_config "https://github.com/akshit926/toastmasters/blob/main/backend/config/db.js"
click node_backend_migrate "https://github.com/akshit926/toastmasters/blob/main/backend/database/migrate.js"
click node_db_schema "https://github.com/akshit926/toastmasters/blob/main/backend/database/schema.sql"
click node_db_members_setup "https://github.com/akshit926/toastmasters/blob/main/backend/database/members_setup.sql"
click node_db_clear_roles "https://github.com/akshit926/toastmasters/blob/main/backend/database/clear_roles.sql"
click node_db_query "https://github.com/akshit926/toastmasters/blob/main/backend/database/query.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_frontend_shell,node_frontend_form,node_frontend_member,node_frontend_admin,node_frontend_roles,node_frontend_shared_js toneBlue
class node_backend_server,node_backend_members_route,node_backend_roles_route,node_backend_club_route,node_backend_contacts_route,node_backend_member_controller,node_backend_role_controller,node_backend_club_controller,node_backend_contact_controller,node_backend_email,node_backend_db_config,node_backend_migrate toneAmber
class node_db_schema,node_db_members_setup,node_db_clear_roles,node_db_query toneMint
```

## Components

### Frontend

Static browser UI and role-specific pages

- [Site pages](https://github.com/akshit926/toastmasters/blob/main/frontend/index.html): static ui · Public informational pages and shared site shell · `frontend/index.html`
- [Registration form](https://github.com/akshit926/toastmasters/blob/main/frontend/form.html): member intake ui · Member signup and onboarding entry point · `frontend/form.html`
- [Member portal](https://github.com/akshit926/toastmasters/blob/main/frontend/member.html): member portal ui · Member login and role/status view · `frontend/member.html`
- [Admin dashboard](https://github.com/akshit926/toastmasters/blob/main/frontend/admin.html): admin control ui · Operational dashboard for reviewing and acting on requests · `frontend/admin.html`
- [Role requests](https://github.com/akshit926/toastmasters/blob/main/frontend/roles.html): workflow ui · Role request and status actions for members · `frontend/roles.html`
- [Client scripts](https://github.com/akshit926/toastmasters/blob/main/frontend/script.js): browser logic · Shared JavaScript that calls backend APIs and renders flows · `frontend/script.js`

### Backend

Express application, API handlers, and integrations

- [Server entry](https://github.com/akshit926/toastmasters/blob/main/backend/server.js): express bootstrap · Wires middleware, routes, static serving, and startup · `backend/server.js`
- [Members API](https://github.com/akshit926/toastmasters/blob/main/backend/routes/members.js): route · HTTP surface for member registration · `backend/routes/members.js`
- [Roles API](https://github.com/akshit926/toastmasters/blob/main/backend/routes/roles.js): route · HTTP surface for role requests and workflow actions · `backend/routes/roles.js`
- [Club members API](https://github.com/akshit926/toastmasters/blob/main/backend/routes/clubMembers.js): route · CRUD surface for internal club member records · `backend/routes/clubMembers.js`
- [Contacts API](https://github.com/akshit926/toastmasters/blob/main/backend/routes/contacts.js): route · Inbound contact and message handling · `backend/routes/contacts.js`
- [Member logic](https://github.com/akshit926/toastmasters/blob/main/backend/controllers/memberController.js): controller · Validates and processes member onboarding · `backend/controllers/memberController.js`
- [Role logic](https://github.com/akshit926/toastmasters/blob/main/backend/controllers/roleController.js): controller · Implements approval state transitions and assignment rules · `backend/controllers/roleController.js`
- [Club logic](https://github.com/akshit926/toastmasters/blob/main/backend/controllers/clubMemberController.js): controller · Manages club roster operations and bulk maintenance · `backend/controllers/clubMemberController.js`
- [Contact logic](https://github.com/akshit926/toastmasters/blob/main/backend/controllers/contactController.js): controller · Handles contact submissions and retrieval · `backend/controllers/contactController.js`
- [Email service](https://github.com/akshit926/toastmasters/blob/main/backend/services/emailService.js): notification integration · Sends workflow and registration emails with action links · `backend/services/emailService.js`
- [DB config](https://github.com/akshit926/toastmasters/blob/main/backend/config/db.js): connection config · Environment-driven MySQL and Cloud SQL connection setup · `backend/config/db.js`
- [Migrate](https://github.com/akshit926/toastmasters/blob/main/backend/database/migrate.js): startup db task · Initializes or updates schema on application startup · `backend/database/migrate.js`

### Database

SQL schema, migrations, and query scripts

- [Schema SQL](https://github.com/akshit926/toastmasters/blob/main/backend/database/schema.sql): schema script · Core relational schema for members, roles, contacts, and club members · `backend/database/schema.sql`
- [Members setup](https://github.com/akshit926/toastmasters/blob/main/backend/database/members_setup.sql): seed script · Member-related setup and initialization SQL · `backend/database/members_setup.sql`
- [Clear roles](https://github.com/akshit926/toastmasters/blob/main/backend/database/clear_roles.sql): maintenance sql · Cleanup script for role data · `backend/database/clear_roles.sql`
- [Query SQL](https://github.com/akshit926/toastmasters/blob/main/backend/database/query.sql): query script · Operational SQL queries for inspection or maintenance · `backend/database/query.sql`

## Connections

- Registration form → Members API: submit signup · Member registration request
- Member portal → Roles API: view roles · Member portal reads role state and assignments
- Role requests → Roles API: request action · Role request and cancellation actions
- Admin dashboard → Roles API: moderate · Admin approves, rejects, assigns, or cancels requests
- Admin dashboard → Club members API: manage roster · Administrative club member CRUD and bulk handling
- Client scripts → Members API: API calls · Browser-side JavaScript invokes backend endpoints
- Client scripts → Roles API: API calls · Browser-side JavaScript invokes backend endpoints
- Client scripts → Contacts API: API calls · Browser-side JavaScript invokes backend endpoints
- Server entry → Members API: mounts · Express route registration
- Server entry → Roles API: mounts · Express route registration
- Server entry → Club members API: mounts · Express route registration
- Server entry → Contacts API: mounts · Express route registration
- Members API → Member logic: delegates · Routes forward requests to request handling logic
- Roles API → Role logic: delegates · Routes forward requests to workflow logic
- Club members API → Club logic: delegates · Routes forward requests to roster management logic
- Contacts API → Contact logic: delegates · Routes forward requests to contact handling logic
- Member logic → DB config: persists via · Uses database connection for member records
- Role logic → DB config: persists via · Uses database connection for role workflow state
- Club logic → DB config: persists via · Uses database connection for club roster records
- Contact logic → DB config: persists via · Uses database connection for contact records
- Member logic → Email service: notifies · Sends onboarding and confirmation emails
- Role logic → Email service: notifies · Sends approval, rejection, and cancellation emails
- Migrate → Schema SQL: creates · Startup migration uses schema definition
- Migrate → Members setup: initializes · Startup migration can apply member setup SQL
- Role logic → Schema SQL: reads/writes · Role workflow state is stored in relational tables
- Member logic → Schema SQL: reads/writes · Member onboarding data is stored in relational tables
- Club logic → Schema SQL: reads/writes · Club roster data is stored in relational tables
- Contact logic → Schema SQL: reads/writes · Contact submissions are stored in relational tables
- Server entry → Migrate: starts · Application startup may run migrations
- DB config → Schema SQL: connects to · Runtime DB connection targets the MySQL schema
