How realstin/booksstore works
This is a BookStore backend API for a digital-book library and its reader community. Clients enter through the Express server, which mounts feature routes; route handlers authenticate or authorize requests, apply domain operations, and return API results. The major workflows cover accounts, book discovery and PDF delivery, bookmarks and notes, plus editorial content, teams, statistics, and newsletter subscriptions. Persistence is modeled with Mongoose; book/article publishing can trigger subscriber email. The tree and excerpts establish these boundaries, but several controllers and route implementations were not sampled, so their internal links are conservative.
Main entry points: server.js Express server · authenticate.js JWT authentication · requireAdmin.js Admin guard · adminUsers.js User administration
Components 34
API and access
- Express server
server.js - Auth routes
routes/auth.js - Account auth
controllers/authController.js - JWT authentication
middleware/authenticate.js - Admin guard
middleware/requireAdmin.js - User administration
routes/adminUsers.js - Admin user operations
controllers/adminUserController.js - User records
models/User.js
Reading library
- Book routes
routes/books.js - Book catalog and PDF
controllers/bookController.js - Book records
models/Book.js - Book cache
utils/bookCache.js - Reader library
controllers/libraryController.js
Reader community
- Bookmark routes
routes/bookmarks.js - Bookmark operations
controllers/bookmarkController.js - Bookmarks
models/Bookmark.js - Note routes
routes/notes.js - Reader notes
controllers/noteController.js - Notes
models/Note.js
Content and engagement
- Article routes
routes/articles.js - Article publishing
controllers/articleController.js - Articles
models/Article.js - Team routes
routes/team.js - Team operations
controllers/teamController.js - Team records
models/Team.js - Statistics routes
routes/stats.js - Statistics
controllers/statsController.js
Subscriber messaging
- Newsletter routes
routes/newsletter.js - Subscriptions
controllers/newsletterController.js - Subscribers
models/Subscriber.js - Subscriber notifications
utils/notifySubscribers.js - SMTP mailer
utils/mailer.js
Other components
- API clients
- Gmail SMTP
Connections 48
- API clients → Express server: send requests
server.js - Express server → Auth routes: mounts auth
server.js - Express server → Book routes: mounts books
server.js - Express server → User administration: mounts admin users
server.js - Express server → Bookmark routes: mounts bookmarks
server.js - Express server → Note routes: mounts notes
server.js - Express server → Article routes: mounts articles
server.js - Express server → Team routes: mounts team
server.js - Express server → Statistics routes: mounts statistics
server.js - Express server → Newsletter routes: mounts newsletter
server.js - Auth routes → Account auth: dispatches auth
routes/auth.js - Auth routes → JWT authentication: protects session
routes/auth.js - Account auth → Subscribers: uses subscriber records
controllers/authController.js - JWT authentication → Admin guard: provides user context
- JWT authentication → User records: loads account
middleware/authenticate.js - User administration → JWT authentication: protects admin routes
routes/adminUsers.js - User administration → Admin guard: guards admin routes
routes/adminUsers.js - User administration → Admin user operations: dispatches operations
routes/adminUsers.js - Book routes → JWT authentication: protects operations
routes/books.js - Book routes → Admin guard: guards changes
routes/books.js - Book routes → Book catalog and PDF: dispatches catalog
routes/books.js - Book catalog and PDF → Book records: queries books
controllers/bookController.js - Book catalog and PDF → Book cache: reads and clears
controllers/bookController.js - Book catalog and PDF → Subscriber notifications: notifies new books
controllers/bookController.js - Reader library → Book records: queries books
controllers/libraryController.js - Reader library → Book cache: uses cached books
controllers/libraryController.js - Reader library → User records: updates reader
controllers/libraryController.js - Bookmark routes → JWT authentication: protects routes
routes/bookmarks.js - Bookmark routes → Bookmark operations: dispatches actions
routes/bookmarks.js - Bookmark operations → Bookmarks: queries bookmarks
controllers/bookmarkController.js - Bookmark operations → Book records: updates book counts
controllers/bookmarkController.js - Note routes → JWT authentication: protects routes
routes/notes.js - Note routes → Reader notes: dispatches actions
routes/notes.js - Reader notes → Notes: creates and queries
controllers/noteController.js - Reader notes → Book records: checks book existence
controllers/noteController.js - Article routes → JWT authentication: protects edits
routes/articles.js - Article routes → Admin guard: guards publishing
routes/articles.js - Article routes → Article publishing: dispatches articles
routes/articles.js - Article publishing → Articles: queries articles
controllers/articleController.js - Article publishing → Subscriber notifications: notifies publication
controllers/articleController.js - Team routes → JWT authentication: protects edits
routes/team.js - Team routes → Admin guard: guards changes
routes/team.js - Team routes → Team operations: dispatches team
routes/team.js - Team operations → Team records: queries team
controllers/teamController.js - Statistics routes → Statistics: dispatches statistics
- Newsletter routes → JWT authentication: protects admin actions
routes/newsletter.js - Newsletter routes → Admin guard: guards admin actions
routes/newsletter.js - Newsletter routes → Subscriptions: dispatches subscriptions
routes/newsletter.js