How shaorankun/blogfruits-api works
BlogFruits is an Express REST API for authentication, user and blog management, comments, and AI-generated Fruit of the Day recommendations. A client calls routes mounted by the app; route handlers dispatch to controllers, which apply domain rules and access Mongoose models. The documented FOTD flow checks the MongoDB cache before requesting Gemini and saving a new result. README capabilities supplement sampled source where route or controller wiring was not available for inspection.
Main entry points: index.js Express app · user.route.js User routes · post.route.js Post routes · comment.route.js Comment routes
Components 19
API application
- Express app
index.js - Auth routes
routes/auth.route.js - User routes
routes/user.route.js - Post routes
routes/post.route.js - Comment routes
routes/comment.route.js - FOTD routes
routes/fotd.route.js
Identity and users
- Authentication
controllers/auth.controller.js - User management
controllers/user.controller.js - Token verification
utils/verifyUser.js - User model
models/user.model.js
Blog and comments
- Post management
controllers/post.controller.js - Post model
models/post.model.js - Comment management
controllers/comment.controller.js - Comment model
models/comment.model.js
Fruit recommendations
- Daily fruit
controllers/fotd.controller.js - Fruit model
models/fruit.model.js
Other components
- API client
- MongoDB
- Gemini AI
Connections 25
- API client → Express app: sends requests
- Express app → Auth routes: mounts routes
- Express app → User routes: mounts routes
- Express app → Post routes: mounts routes
- Express app → Comment routes: mounts routes
- Express app → FOTD routes: mounts routes
- Express app → MongoDB: connects
- Auth routes → Authentication: dispatches
- User routes → User management: dispatches
- User routes → Token verification: verifies token
- Post routes → Post management: dispatches
- Post routes → Token verification: verifies token
- Comment routes → Comment management: dispatches
- Comment routes → Token verification: verifies token
- FOTD routes → Daily fruit: dispatches
- Authentication → User model: reads and writes
- User management → User model: reads and writes
- Post management → Post model: reads and writes
- Comment management → Comment model: reads and writes
- Daily fruit → Fruit model: checks and saves
- User model → MongoDB: persists users
- Post model → MongoDB: persists posts
- Comment model → MongoDB: persists comments
- Fruit model → MongoDB: persists fruit
- Daily fruit → Gemini AI: generates recommendation