# thamesblanq/blog-backend architecture

> Architecture diagram of the GitHub repository thamesblanq/blog-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thamesblanq/blog-backend
- Repository: https://github.com/thamesblanq/blog-backend

## Overview

This is a NestJS REST API for a blog platform. Clients register or log in, then use JWT-protected endpoints to manage users, posts, and comments; post endpoints also support image uploads to Cloudinary. MongoDB-backed services persist the principal domain records. Comments are implemented in the tree despite being described as planned in the README. The graph follows sampled controller and service calls; strategy, schema, and module internals were not sampled, so uncertain wiring is omitted.

Main entry points: [`src/posts/posts.controller.ts`](https://github.com/thamesblanq/blog-backend/blob/main/src/posts/posts.controller.ts) (Posts controller), [`src/auth/auth.service.ts`](https://github.com/thamesblanq/blog-backend/blob/main/src/auth/auth.service.ts) (Auth service), [`src/users/users.controller.ts`](https://github.com/thamesblanq/blog-backend/blob/main/src/users/users.controller.ts) (Users controller), [`src/auth/jwt-auth.guard.ts`](https://github.com/thamesblanq/blog-backend/blob/main/src/auth/jwt-auth.guard.ts) (JWT guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API endpoints"]
  node_auth_controller["Auth controller<br/>[auth.controller.ts]"]
  node_users_controller["Users controller"]
  node_posts_controller["Posts controller"]
  node_comments_controller["Comments controller"]
end

subgraph group_identity["Identity and access"]
  node_auth_service["Auth service<br/>[auth.service.ts]"]
  node_jwt_guard["JWT guard<br/>[jwt-auth.guard.ts]"]
  node_jwt_strategy["JWT strategy<br/>[jwt.strategy.ts]"]
  node_local_strategy["Local strategy<br/>[localstrategy.ts]"]
  node_roles_guard["Roles guard<br/>[roles.guard.ts]"]
  node_roles_decorator["Role metadata<br/>[roles.decorator.ts]"]
end

subgraph group_content["Blog content"]
  node_users_service["Users service<br/>[users.service.ts]"]
  node_posts_service["Posts service<br/>[posts.service.ts]"]
  node_comments_service["Comments service<br/>[comment.service.ts]"]
end

subgraph group_integrations["Persistence and media"]
  node_user_schema["User schema<br/>[user.schema.ts]"]
  node_post_schema["Post schema<br/>[post.schema.ts]"]
  node_comment_schema["Comment schema<br/>[comment.schema.ts]"]
  node_mongo[("MongoDB")]
  node_cloudinary_service["Cloudinary service"]
  node_cloudinary["Cloudinary"]
end

node_client(("API client"))

node_client -->|"registers or logs in"| node_auth_controller
node_auth_controller -->|"delegates auth"| node_auth_service
node_auth_controller -->|"guards login"| node_local_strategy
node_local_strategy -.->|"validates credentials"| node_auth_service
node_auth_service -->|"looks up or creates"| node_users_service
node_auth_service -->|"issues JWT"| node_jwt_strategy
node_client -->|"requests profile"| node_users_controller
node_client -->|"requests posts"| node_posts_controller
node_client -->|"requests comments"| node_comments_controller
node_users_controller -->|"protects routes"| node_jwt_guard
node_posts_controller -->|"protects routes"| node_jwt_guard
node_comments_controller -->|"protects routes"| node_jwt_guard
node_users_controller -->|"checks role"| node_roles_guard
node_posts_controller -->|"checks role"| node_roles_guard
node_roles_guard -->|"reads role metadata"| node_roles_decorator
node_jwt_guard -->|"validates token"| node_jwt_strategy
node_users_controller -->|"delegates user operations"| node_users_service
node_auth_service -->|"reads or creates user"| node_users_service
node_posts_controller -->|"delegates post operations"| node_posts_service
node_comments_controller -->|"delegates comment operations"| node_comments_service
node_users_service -->|"queries and saves"| node_user_schema
node_posts_service -->|"queries and saves"| node_post_schema
node_comments_service -->|"queries and saves"| node_comment_schema
node_user_schema -->|"persists users"| node_mongo
node_post_schema -->|"persists posts"| node_mongo
node_comment_schema -->|"persists comments"| node_mongo
node_posts_controller -.->|"uploads image"| node_cloudinary_service
node_cloudinary_service -.->|"stores image"| node_cloudinary

click node_auth_controller "https://github.com/thamesblanq/blog-backend/blob/main/src/auth/auth.controller.ts"
click node_users_controller "https://github.com/thamesblanq/blog-backend/blob/main/src/users/users.controller.ts"
click node_posts_controller "https://github.com/thamesblanq/blog-backend/blob/main/src/posts/posts.controller.ts"
click node_comments_controller "https://github.com/thamesblanq/blog-backend/blob/main/src/comment/comment.controller.ts"
click node_auth_service "https://github.com/thamesblanq/blog-backend/blob/main/src/auth/auth.service.ts"
click node_jwt_guard "https://github.com/thamesblanq/blog-backend/blob/main/src/auth/jwt-auth.guard.ts"
click node_jwt_strategy "https://github.com/thamesblanq/blog-backend/blob/main/src/auth/jwt.strategy.ts"
click node_local_strategy "https://github.com/thamesblanq/blog-backend/blob/main/src/auth/localstrategy.ts"
click node_roles_guard "https://github.com/thamesblanq/blog-backend/blob/main/src/roles/roles.guard.ts"
click node_roles_decorator "https://github.com/thamesblanq/blog-backend/blob/main/src/roles/roles.decorator.ts"
click node_users_service "https://github.com/thamesblanq/blog-backend/blob/main/src/users/users.service.ts"
click node_posts_service "https://github.com/thamesblanq/blog-backend/blob/main/src/posts/posts.service.ts"
click node_comments_service "https://github.com/thamesblanq/blog-backend/blob/main/src/comment/comment.service.ts"
click node_user_schema "https://github.com/thamesblanq/blog-backend/blob/main/src/schemas/user.schema.ts"
click node_post_schema "https://github.com/thamesblanq/blog-backend/blob/main/src/schemas/post.schema.ts"
click node_comment_schema "https://github.com/thamesblanq/blog-backend/blob/main/src/schemas/comment.schema.ts"
click node_cloudinary_service "https://github.com/thamesblanq/blog-backend/blob/main/config/cloudinary.service.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_auth_controller,node_users_controller,node_posts_controller,node_comments_controller,node_client toneBlue
class node_auth_service,node_jwt_guard,node_jwt_strategy,node_local_strategy,node_roles_guard,node_roles_decorator toneAmber
class node_users_service,node_posts_service,node_comments_service toneMint
class node_user_schema,node_post_schema,node_comment_schema,node_mongo,node_cloudinary_service,node_cloudinary toneRose
```

## Components

### API endpoints

- [Auth controller](https://github.com/thamesblanq/blog-backend/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Users controller](https://github.com/thamesblanq/blog-backend/blob/main/src/users/users.controller.ts): `src/users/users.controller.ts`
- [Posts controller](https://github.com/thamesblanq/blog-backend/blob/main/src/posts/posts.controller.ts): `src/posts/posts.controller.ts`
- [Comments controller](https://github.com/thamesblanq/blog-backend/blob/main/src/comment/comment.controller.ts): `src/comment/comment.controller.ts`

### Identity and access

- [Auth service](https://github.com/thamesblanq/blog-backend/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [JWT guard](https://github.com/thamesblanq/blog-backend/blob/main/src/auth/jwt-auth.guard.ts): `src/auth/jwt-auth.guard.ts`
- [JWT strategy](https://github.com/thamesblanq/blog-backend/blob/main/src/auth/jwt.strategy.ts): `src/auth/jwt.strategy.ts`
- [Local strategy](https://github.com/thamesblanq/blog-backend/blob/main/src/auth/localstrategy.ts): `src/auth/localstrategy.ts`
- [Roles guard](https://github.com/thamesblanq/blog-backend/blob/main/src/roles/roles.guard.ts): `src/roles/roles.guard.ts`
- [Role metadata](https://github.com/thamesblanq/blog-backend/blob/main/src/roles/roles.decorator.ts): `src/roles/roles.decorator.ts`

### Blog content

- [Users service](https://github.com/thamesblanq/blog-backend/blob/main/src/users/users.service.ts): `src/users/users.service.ts`
- [Posts service](https://github.com/thamesblanq/blog-backend/blob/main/src/posts/posts.service.ts): `src/posts/posts.service.ts`
- [Comments service](https://github.com/thamesblanq/blog-backend/blob/main/src/comment/comment.service.ts): `src/comment/comment.service.ts`

### Persistence and media

- [User schema](https://github.com/thamesblanq/blog-backend/blob/main/src/schemas/user.schema.ts): `src/schemas/user.schema.ts`
- [Post schema](https://github.com/thamesblanq/blog-backend/blob/main/src/schemas/post.schema.ts): `src/schemas/post.schema.ts`
- [Comment schema](https://github.com/thamesblanq/blog-backend/blob/main/src/schemas/comment.schema.ts): `src/schemas/comment.schema.ts`
- **MongoDB**
- [Cloudinary service](https://github.com/thamesblanq/blog-backend/blob/main/config/cloudinary.service.ts): `config/cloudinary.service.ts`
- **Cloudinary**

### Other components

- **API client**

## Connections

- API client → Auth controller: registers or logs in
- Auth controller → Auth service: delegates auth
- Auth controller → Local strategy: guards login
- Local strategy → Auth service: validates credentials
- Auth service → Users service: looks up or creates
- Auth service → JWT strategy: issues JWT
- API client → Users controller: requests profile
- API client → Posts controller: requests posts
- API client → Comments controller: requests comments
- Users controller → JWT guard: protects routes
- Posts controller → JWT guard: protects routes
- Comments controller → JWT guard: protects routes
- Users controller → Roles guard: checks role
- Posts controller → Roles guard: checks role
- Roles guard → Role metadata: reads role metadata
- JWT guard → JWT strategy: validates token
- Users controller → Users service: delegates user operations
- Auth service → Users service: reads or creates user
- Posts controller → Posts service: delegates post operations
- Comments controller → Comments service: delegates comment operations
- Users service → User schema: queries and saves
- Posts service → Post schema: queries and saves
- Comments service → Comment schema: queries and saves
- User schema → MongoDB: persists users
- Post schema → MongoDB: persists posts
- Comment schema → MongoDB: persists comments
- Posts controller → Cloudinary service: uploads image
- Cloudinary service → Cloudinary: stores image
