How kenjimattos/express-mongo-api works
This is a Node.js/Express bookstore REST API. An API client sends JSON requests to the server; the app connects to MongoDB and registers author, book, and user routes, which dispatch to controllers. Controllers perform CRUD operations through Mongoose models and return JSON responses. The book workflow also looks up an author when creating a book, and books can be searched by publisher. User passwords are hashed with bcrypt on save. The README documents these capabilities; connections are shown at the module level, since route and model implementations were not all sampled.
Main entry points: index.js Route registry · bookController.js Book operations · app.js App setup · authorController.js Author CRUD
Components 16
API runtime
- HTTP server
server.js - App setup
src/app.js - Route registry
src/routes/index.js
Book catalog
- Author routes
src/routes/authorRoute.js - Book routes
src/routes/bookRoute.js - Author CRUD
src/controllers/authorController.js - Book operations
src/controllers/bookController.js
Users
- User routes
src/routes/userRoute.js - User CRUD
src/controllers/userController.js
Persistence
- Author model
src/models/authorModel.js - Book model
src/models/bookModel.js - User model
src/models/userModel.js - DB connector
src/config/dbConnect.js
Other components
- API client
- MongoDB
- bcrypt
Connections 22
- API client → HTTP server: sends requests
- HTTP server → App setup: loads app
- App setup → DB connector: connects database
- DB connector → MongoDB: connects
- App setup → Route registry: registers routes
- Route registry → Author routes: mounts
- Route registry → Book routes: mounts
- Route registry → User routes: mounts
- Author routes → Author CRUD: dispatches
- Book routes → Book operations: dispatches
- User routes → User CRUD: dispatches
- Author CRUD → Author model: reads and writes
- Book operations → Book model: reads and writes
- Book operations → Author model: looks up author
- User CRUD → User model: reads and writes
- Author model → MongoDB: persists data
- Book model → MongoDB: persists data
- User model → MongoDB: persists data
- User model → bcrypt: hashes passwords
- Author CRUD → API client: returns JSON
- Book operations → API client: returns JSON
- User CRUD → API client: returns JSON