# mariabhai/bookclub-api architecture

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

- Interactive diagram: https://gitdiagram.com/mariabhai/bookclub-api
- Repository: https://github.com/mariabhai/bookclub-api

## Overview

This is a full-stack book catalogue and review application: visitors browse books and submit reviews, while account holders authenticate to access protected mutations. The browser client is served alongside an Express API, which dispatches requests through route modules to controllers and Mongoose models backed by MongoDB. The README also documents user management and protected pages; the excerpts do not show all client-to-API wiring or every route implementation, so those relationships are included only where documented or indexed.

Main entry points: [`api/index.ts`](https://github.com/mariabhai/bookclub-api/blob/main/api/index.ts) (Express API), [`public`](https://github.com/mariabhai/bookclub-api/tree/main/public) (Static web client), [`src/middleware/verifyToken.ts`](https://github.com/mariabhai/bookclub-api/blob/main/src/middleware/verifyToken.ts) (Token verification), [`src/routes/bookRoutes.ts`](https://github.com/mariabhai/bookclub-api/blob/main/src/routes/bookRoutes.ts) (Book routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_webclient["Static web client"]
  node_booklist["Book listing<br/>[index.js]"]
  node_bookview["Book details<br/>[book.js]"]
  node_reviewform["Review display and form<br/>[review.js]"]
  node_loginui["Login page<br/>[login.js]"]
  node_registerui["Registration page<br/>[register.js]"]
  node_protectedui["Protected page<br/>[loggedin.js]"]
end

subgraph group_server["API and routing"]
  node_api["Express API<br/>[index.ts]"]
  node_bookroutes["Book routes<br/>[bookRoutes.ts]"]
  node_reviewroutes["Review routes<br/>[reviewRoutes.ts]"]
  node_authroutes["Auth routes<br/>[auth.ts]"]
  node_userroutes["User routes<br/>[user.ts]"]
  node_greetingroutes["Greeting routes<br/>[greetings.ts]"]
  node_greetingcontroller["Greeting handler"]
end

subgraph group_catalog["Books and reviews"]
  node_bookcontroller["Book operations<br/>[bookController.ts]"]
  node_reviewcontroller["Review operations"]
  node_bookmodel["Book model<br/>[book.ts]"]
  node_reviewmodel["Review model<br/>[review.ts]"]
end

subgraph group_identity["Accounts and access"]
  node_authcontroller["Authentication<br/>[authController.ts]"]
  node_usercontroller["User operations<br/>[userController.ts]"]
  node_tokenmiddleware["Token verification<br/>[verifyToken.ts]"]
  node_usermodel["User model<br/>[user.ts]"]
end

node_visitor(("Browser user"))
node_mongodb[("MongoDB")]

node_visitor -->|"uses"| node_webclient
node_api -->|"serves static files"| node_webclient
node_webclient -->|"includes"| node_booklist
node_webclient -->|"includes"| node_bookview
node_webclient -->|"includes"| node_reviewform
node_visitor -->|"browses"| node_booklist
node_visitor -->|"selects book"| node_bookview
node_visitor -->|"submits review"| node_reviewform
node_visitor -.->|"signs in"| node_loginui
node_visitor -.->|"registers"| node_registerui
node_visitor -.->|"opens protected page"| node_protectedui
node_booklist -.->|"requests books"| node_api
node_bookview -->|"requests book"| node_api
node_reviewform -->|"requests reviews"| node_api
node_loginui -.->|"authenticates"| node_api
node_registerui -.->|"registers account"| node_api
node_protectedui -.->|"requests protected content"| node_api
node_api -->|"mounts /api/books"| node_bookroutes
node_api -->|"mounts /api/reviews"| node_reviewroutes
node_api -->|"mounts /api/auth"| node_authroutes
node_api -->|"mounts /api/users"| node_userroutes
node_api -->|"mounts /api/greetings"| node_greetingroutes
node_bookroutes -->|"dispatches"| node_bookcontroller
node_reviewroutes -->|"dispatches"| node_reviewcontroller
node_authroutes -->|"dispatches"| node_authcontroller
node_userroutes -->|"dispatches"| node_usercontroller
node_greetingroutes -->|"dispatches"| node_greetingcontroller
node_bookroutes -->|"protects mutations"| node_tokenmiddleware
node_reviewroutes -->|"protects mutations"| node_tokenmiddleware
node_userroutes -->|"uses token check"| node_tokenmiddleware
node_greetingroutes -->|"uses token check"| node_tokenmiddleware
node_bookcontroller -->|"queries"| node_bookmodel
node_reviewcontroller -->|"queries"| node_reviewmodel
node_reviewcontroller -->|"checks book"| node_bookmodel
node_authcontroller -->|"queries and creates"| node_usermodel
node_usercontroller -->|"manages users"| node_usermodel
node_api -->|"connects"| node_mongodb
node_bookmodel -->|"stores books"| node_mongodb
node_reviewmodel -->|"stores reviews"| node_mongodb
node_usermodel -->|"stores users"| node_mongodb

click node_webclient "https://github.com/mariabhai/bookclub-api/tree/main/public"
click node_booklist "https://github.com/mariabhai/bookclub-api/blob/main/public/js/index.js"
click node_bookview "https://github.com/mariabhai/bookclub-api/blob/main/public/js/book.js"
click node_reviewform "https://github.com/mariabhai/bookclub-api/blob/main/public/js/review.js"
click node_loginui "https://github.com/mariabhai/bookclub-api/blob/main/public/js/login.js"
click node_registerui "https://github.com/mariabhai/bookclub-api/blob/main/public/js/register.js"
click node_protectedui "https://github.com/mariabhai/bookclub-api/blob/main/public/js/loggedin.js"
click node_api "https://github.com/mariabhai/bookclub-api/blob/main/api/index.ts"
click node_bookroutes "https://github.com/mariabhai/bookclub-api/blob/main/src/routes/bookRoutes.ts"
click node_reviewroutes "https://github.com/mariabhai/bookclub-api/blob/main/src/routes/reviewRoutes.ts"
click node_authroutes "https://github.com/mariabhai/bookclub-api/blob/main/src/routes/auth.ts"
click node_userroutes "https://github.com/mariabhai/bookclub-api/blob/main/src/routes/user.ts"
click node_greetingroutes "https://github.com/mariabhai/bookclub-api/blob/main/src/routes/greetings.ts"
click node_bookcontroller "https://github.com/mariabhai/bookclub-api/blob/main/src/controllers/bookController.ts"
click node_reviewcontroller "https://github.com/mariabhai/bookclub-api/blob/main/src/controllers/reviewController.ts"
click node_bookmodel "https://github.com/mariabhai/bookclub-api/blob/main/src/models/book.ts"
click node_reviewmodel "https://github.com/mariabhai/bookclub-api/blob/main/src/models/review.ts"
click node_authcontroller "https://github.com/mariabhai/bookclub-api/blob/main/src/controllers/authController.ts"
click node_usercontroller "https://github.com/mariabhai/bookclub-api/blob/main/src/controllers/userController.ts"
click node_greetingcontroller "https://github.com/mariabhai/bookclub-api/blob/main/src/controllers/greetingController.ts"
click node_tokenmiddleware "https://github.com/mariabhai/bookclub-api/blob/main/src/middleware/verifyToken.ts"
click node_usermodel "https://github.com/mariabhai/bookclub-api/blob/main/src/models/user.ts"

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_webclient,node_booklist,node_bookview,node_reviewform,node_loginui,node_registerui,node_protectedui,node_visitor toneBlue
class node_api,node_bookroutes,node_reviewroutes,node_authroutes,node_userroutes,node_greetingroutes,node_greetingcontroller,node_mongodb toneAmber
class node_bookcontroller,node_reviewcontroller,node_bookmodel,node_reviewmodel toneMint
class node_authcontroller,node_usercontroller,node_tokenmiddleware,node_usermodel toneRose
```

## Components

### Browser client

- [Static web client](https://github.com/mariabhai/bookclub-api/tree/main/public): `public`
- [Book listing](https://github.com/mariabhai/bookclub-api/blob/main/public/js/index.js): `public/js/index.js`
- [Book details](https://github.com/mariabhai/bookclub-api/blob/main/public/js/book.js): `public/js/book.js`
- [Review display and form](https://github.com/mariabhai/bookclub-api/blob/main/public/js/review.js): `public/js/review.js`
- [Login page](https://github.com/mariabhai/bookclub-api/blob/main/public/js/login.js): `public/js/login.js`
- [Registration page](https://github.com/mariabhai/bookclub-api/blob/main/public/js/register.js): `public/js/register.js`
- [Protected page](https://github.com/mariabhai/bookclub-api/blob/main/public/js/loggedin.js): `public/js/loggedin.js`

### API and routing

- [Express API](https://github.com/mariabhai/bookclub-api/blob/main/api/index.ts): `api/index.ts`
- [Book routes](https://github.com/mariabhai/bookclub-api/blob/main/src/routes/bookRoutes.ts): `src/routes/bookRoutes.ts`
- [Review routes](https://github.com/mariabhai/bookclub-api/blob/main/src/routes/reviewRoutes.ts): `src/routes/reviewRoutes.ts`
- [Auth routes](https://github.com/mariabhai/bookclub-api/blob/main/src/routes/auth.ts): `src/routes/auth.ts`
- [User routes](https://github.com/mariabhai/bookclub-api/blob/main/src/routes/user.ts): `src/routes/user.ts`
- [Greeting routes](https://github.com/mariabhai/bookclub-api/blob/main/src/routes/greetings.ts): `src/routes/greetings.ts`
- [Greeting handler](https://github.com/mariabhai/bookclub-api/blob/main/src/controllers/greetingController.ts): `src/controllers/greetingController.ts`

### Books and reviews

- [Book operations](https://github.com/mariabhai/bookclub-api/blob/main/src/controllers/bookController.ts): `src/controllers/bookController.ts`
- [Review operations](https://github.com/mariabhai/bookclub-api/blob/main/src/controllers/reviewController.ts): `src/controllers/reviewController.ts`
- [Book model](https://github.com/mariabhai/bookclub-api/blob/main/src/models/book.ts): `src/models/book.ts`
- [Review model](https://github.com/mariabhai/bookclub-api/blob/main/src/models/review.ts): `src/models/review.ts`

### Accounts and access

- [Authentication](https://github.com/mariabhai/bookclub-api/blob/main/src/controllers/authController.ts): `src/controllers/authController.ts`
- [User operations](https://github.com/mariabhai/bookclub-api/blob/main/src/controllers/userController.ts): `src/controllers/userController.ts`
- [Token verification](https://github.com/mariabhai/bookclub-api/blob/main/src/middleware/verifyToken.ts): `src/middleware/verifyToken.ts`
- [User model](https://github.com/mariabhai/bookclub-api/blob/main/src/models/user.ts): `src/models/user.ts`

### Other components

- **Browser user**
- **MongoDB**

## Connections

- Browser user → Static web client: uses (evidence: `README.md`)
- Express API → Static web client: serves static files (evidence: `api/index.ts`)
- Static web client → Book listing: includes (evidence: `README.md`)
- Static web client → Book details: includes (evidence: `README.md`)
- Static web client → Review display and form: includes (evidence: `README.md`)
- Browser user → Book listing: browses (evidence: `README.md`)
- Browser user → Book details: selects book (evidence: `README.md`)
- Browser user → Review display and form: submits review (evidence: `README.md`)
- Browser user → Login page: signs in
- Browser user → Registration page: registers
- Browser user → Protected page: opens protected page
- Book listing → Express API: requests books
- Book details → Express API: requests book (evidence: `README.md`)
- Review display and form → Express API: requests reviews (evidence: `README.md`)
- Login page → Express API: authenticates
- Registration page → Express API: registers account
- Protected page → Express API: requests protected content
- Express API → Book routes: mounts /api/books (evidence: `api/index.ts`)
- Express API → Review routes: mounts /api/reviews (evidence: `api/index.ts`)
- Express API → Auth routes: mounts /api/auth (evidence: `api/index.ts`)
- Express API → User routes: mounts /api/users (evidence: `api/index.ts`)
- Express API → Greeting routes: mounts /api/greetings (evidence: `api/index.ts`)
- Book routes → Book operations: dispatches (evidence: `src/routes/bookRoutes.ts`)
- Review routes → Review operations: dispatches (evidence: `src/routes/reviewRoutes.ts`)
- Auth routes → Authentication: dispatches (evidence: `src/routes/auth.ts`)
- User routes → User operations: dispatches (evidence: `src/routes/user.ts`)
- Greeting routes → Greeting handler: dispatches (evidence: `src/routes/greetings.ts`)
- Book routes → Token verification: protects mutations (evidence: `src/routes/bookRoutes.ts`)
- Review routes → Token verification: protects mutations (evidence: `src/routes/reviewRoutes.ts`)
- User routes → Token verification: uses token check (evidence: `src/routes/user.ts`)
- Greeting routes → Token verification: uses token check (evidence: `src/routes/greetings.ts`)
- Book operations → Book model: queries (evidence: `src/controllers/bookController.ts`)
- Review operations → Review model: queries (evidence: `src/controllers/reviewController.ts`)
- Review operations → Book model: checks book (evidence: `src/controllers/reviewController.ts`)
- Authentication → User model: queries and creates (evidence: `src/controllers/authController.ts`)
- User operations → User model: manages users (evidence: `src/controllers/userController.ts`)
- Express API → MongoDB: connects (evidence: `api/index.ts`)
- Book model → MongoDB: stores books (evidence: `README.md`)
- Review model → MongoDB: stores reviews (evidence: `README.md`)
- User model → MongoDB: stores users (evidence: `README.md`)
