How gokulreddy05/backend-blog-api works
This is an Express REST API for user authentication and blog posts with comments. Requests enter through the server’s mounted routes; authentication endpoints register users or return access tokens, while protected post and comment endpoints validate bearer tokens before controllers call domain services. Services implement persistence through Prisma backed by PostgreSQL. The README also documents post search, publication filtering, and pagination. Route, controller, service, and database edges are grounded in the supplied source index or excerpts; schema and migration details are not expanded beyond the README because their contents were not sampled.
Main entry points: db.js Prisma client · server.js Express server · postRoute.js Post routes · commentRoute.js Comment routes
Components 15
HTTP API
- Express server
src/server.js - Auth routes
src/routes/authRoute.js - Post routes
src/routes/postRoute.js - Comment routes
src/routes/commentRoute.js
Identity
- Auth handlers
src/controllers/authController.js - JWT guard
src/middleware/authMiddleware.js - Auth operations
src/services/authService.js
Blog Content
- Post handlers
src/controllers/postController.js - Post operations
src/services/postService.js - Comment handlers
src/controllers/commentController.js - Comment operations
src/services/commentService.js
Persistence
- Data model
prisma/schema.prisma - Prisma client
src/config/db.js - PostgreSQL
Other components
- API caller
Connections 18
- API caller → Express server: sends requests
README.md - Express server → Auth routes: mounts at /api/auth
src/server.js - Express server → Post routes: mounts at /api/posts
src/server.js - Express server → Comment routes: mounts at /api/posts
src/server.js - Auth routes → Auth handlers: routes to
src/routes/authRoute.js - Post routes → Post handlers: routes to
src/routes/postRoute.js - Comment routes → Comment handlers: routes to
src/routes/commentRoute.js - Post routes → JWT guard: guards writes
src/routes/postRoute.js - Comment routes → JWT guard: guards endpoints
src/routes/commentRoute.js - Auth handlers → Auth operations: calls
src/controllers/authController.js - Post handlers → Post operations: calls
src/controllers/postController.js - Comment handlers → Comment operations: calls
src/controllers/commentController.js - Auth operations → Prisma client: queries users
src/services/authService.js - Post operations → Prisma client: queries posts
src/services/postService.js - Comment operations → Prisma client: queries comments
src/services/commentService.js - Express server → Prisma client: connects at startup
src/server.js - Prisma client → PostgreSQL: uses adapter pool
src/config/db.js - Data model → Prisma client: defines ORM model