How mgalen007/blogapi works
This is a NestJS REST blog API. Its main workflow is account registration or login, followed by JWT-authenticated requests to manage users, posts, comments, and tags; guards enforce authentication and selected role or ownership rules. Domain services use Prisma for PostgreSQL access. The README documents the capabilities and data model; source excerpts confirm several controller/service paths, but not every service or guard implementation, so uncertain internal wiring is omitted.
Main entry points: users.controller.ts User routes · jwt-auth.guard.ts JWT guard · prisma.service.ts Prisma client · posts.controller.ts Post routes
Components 17
API entry and auth
- Auth routes
src/auth/auth.controller.ts - Auth service
src/auth/auth.service.ts - JWT service
src/auth/jwt/jwt.service.ts
Access control
- JWT guard
src/guards/jwt-auth.guard.ts - Role guard
src/guards/roles.guard.ts - Ownership guard
src/guards/ownership.guard.ts
Blog resources
- User routes
src/users/users.controller.ts - User service
src/users/users.service.ts - Post routes
src/posts/posts.controller.ts - Post service
src/posts/posts.service.ts - Comment routes
src/comments/comments.controller.ts - Comment service
src/comments/comments.service.ts - Tag routes
src/tags/tags.controller.ts - Tag service
src/tags/tags.service.ts
Persistence
- Prisma client
src/prisma/prisma.service.ts - PostgreSQL
Other components
- API client
Connections 27
- API client → Auth routes: registers or logs in
- Auth routes → Auth service: calls
- Auth service → User service: creates or finds user
- Auth service → JWT service: signs token
- API client → User routes: requests
- API client → Post routes: requests
- API client → Comment routes: requests
- API client → Tag routes: requests
- User routes → JWT guard: applies
- Post routes → JWT guard: applies
- Comment routes → JWT guard: applies
- Tag routes → JWT guard: applies
- JWT guard → JWT service: verifies token
- User routes → Ownership guard: applies
- Post routes → Ownership guard: applies
- Comment routes → Ownership guard: applies
- User routes → Role guard: applies
- Tag routes → Role guard: applies
- User routes → User service: calls
- Post routes → Post service: calls
- Comment routes → Comment service: calls
- Tag routes → Tag service: calls
- User service → Prisma client: reads and writes
- Post service → Prisma client: reads and writes
- Comment service → Prisma client: reads and writes
- Tag service → Prisma client: reads and writes
- Prisma client → PostgreSQL: queries