# mgalen007/blogapi architecture

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

- Interactive diagram: https://gitdiagram.com/mgalen007/blogapi
- Repository: https://github.com/mgalen007/blogapi

## Overview

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: [`src/users/users.controller.ts`](https://github.com/mgalen007/blogapi/blob/main/src/users/users.controller.ts) (User routes), [`src/guards/jwt-auth.guard.ts`](https://github.com/mgalen007/blogapi/blob/main/src/guards/jwt-auth.guard.ts) (JWT guard), [`src/prisma/prisma.service.ts`](https://github.com/mgalen007/blogapi/blob/main/src/prisma/prisma.service.ts) (Prisma client), [`src/posts/posts.controller.ts`](https://github.com/mgalen007/blogapi/blob/main/src/posts/posts.controller.ts) (Post routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry and auth"]
  node_auth_controller["Auth routes<br/>[auth.controller.ts]"]
  node_auth_service["Auth service<br/>[auth.service.ts]"]
  node_jwt_service["JWT service<br/>[jwt.service.ts]"]
end

subgraph group_access["Access control"]
  node_jwt_guard["JWT guard<br/>[jwt-auth.guard.ts]"]
  node_roles_guard["Role guard<br/>[roles.guard.ts]"]
  node_ownership_guard["Ownership guard<br/>[ownership.guard.ts]"]
end

subgraph group_content["Blog resources"]
  node_users_controller["User routes"]
  node_users_service["User service<br/>[users.service.ts]"]
  node_posts_controller["Post routes"]
  node_posts_service["Post service<br/>[posts.service.ts]"]
  node_comments_controller["Comment routes"]
  node_comments_service["Comment service"]
  node_tags_controller["Tag routes<br/>[tags.controller.ts]"]
  node_tags_service["Tag service<br/>[tags.service.ts]"]
end

subgraph group_data["Persistence"]
  node_prisma_service["Prisma client<br/>[prisma.service.ts]"]
  node_postgres[("PostgreSQL")]
end

node_client(("API client"))

node_client -->|"registers or logs in"| node_auth_controller
node_auth_controller -->|"calls"| node_auth_service
node_auth_service -->|"creates or finds user"| node_users_service
node_auth_service -->|"signs token"| node_jwt_service
node_client -->|"requests"| node_users_controller
node_client -->|"requests"| node_posts_controller
node_client -->|"requests"| node_comments_controller
node_client -->|"requests"| node_tags_controller
node_users_controller -->|"applies"| node_jwt_guard
node_posts_controller -->|"applies"| node_jwt_guard
node_comments_controller -->|"applies"| node_jwt_guard
node_tags_controller -->|"applies"| node_jwt_guard
node_jwt_guard -->|"verifies token"| node_jwt_service
node_users_controller -->|"applies"| node_ownership_guard
node_posts_controller -->|"applies"| node_ownership_guard
node_comments_controller -->|"applies"| node_ownership_guard
node_users_controller -->|"applies"| node_roles_guard
node_tags_controller -->|"applies"| node_roles_guard
node_users_controller -->|"calls"| node_users_service
node_posts_controller -->|"calls"| node_posts_service
node_comments_controller -->|"calls"| node_comments_service
node_tags_controller -->|"calls"| node_tags_service
node_users_service -->|"reads and writes"| node_prisma_service
node_posts_service -->|"reads and writes"| node_prisma_service
node_comments_service -->|"reads and writes"| node_prisma_service
node_tags_service -->|"reads and writes"| node_prisma_service
node_prisma_service -->|"queries"| node_postgres

click node_auth_controller "https://github.com/mgalen007/blogapi/blob/main/src/auth/auth.controller.ts"
click node_auth_service "https://github.com/mgalen007/blogapi/blob/main/src/auth/auth.service.ts"
click node_jwt_service "https://github.com/mgalen007/blogapi/blob/main/src/auth/jwt/jwt.service.ts"
click node_jwt_guard "https://github.com/mgalen007/blogapi/blob/main/src/guards/jwt-auth.guard.ts"
click node_roles_guard "https://github.com/mgalen007/blogapi/blob/main/src/guards/roles.guard.ts"
click node_ownership_guard "https://github.com/mgalen007/blogapi/blob/main/src/guards/ownership.guard.ts"
click node_users_controller "https://github.com/mgalen007/blogapi/blob/main/src/users/users.controller.ts"
click node_users_service "https://github.com/mgalen007/blogapi/blob/main/src/users/users.service.ts"
click node_posts_controller "https://github.com/mgalen007/blogapi/blob/main/src/posts/posts.controller.ts"
click node_posts_service "https://github.com/mgalen007/blogapi/blob/main/src/posts/posts.service.ts"
click node_comments_controller "https://github.com/mgalen007/blogapi/blob/main/src/comments/comments.controller.ts"
click node_comments_service "https://github.com/mgalen007/blogapi/blob/main/src/comments/comments.service.ts"
click node_tags_controller "https://github.com/mgalen007/blogapi/blob/main/src/tags/tags.controller.ts"
click node_tags_service "https://github.com/mgalen007/blogapi/blob/main/src/tags/tags.service.ts"
click node_prisma_service "https://github.com/mgalen007/blogapi/blob/main/src/prisma/prisma.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_auth_service,node_jwt_service,node_client toneBlue
class node_jwt_guard,node_roles_guard,node_ownership_guard toneAmber
class node_users_controller,node_users_service,node_posts_controller,node_posts_service,node_comments_controller,node_comments_service,node_tags_controller,node_tags_service toneMint
class node_prisma_service,node_postgres toneRose
```

## Components

### API entry and auth

- [Auth routes](https://github.com/mgalen007/blogapi/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Auth service](https://github.com/mgalen007/blogapi/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [JWT service](https://github.com/mgalen007/blogapi/blob/main/src/auth/jwt/jwt.service.ts): `src/auth/jwt/jwt.service.ts`

### Access control

- [JWT guard](https://github.com/mgalen007/blogapi/blob/main/src/guards/jwt-auth.guard.ts): `src/guards/jwt-auth.guard.ts`
- [Role guard](https://github.com/mgalen007/blogapi/blob/main/src/guards/roles.guard.ts): `src/guards/roles.guard.ts`
- [Ownership guard](https://github.com/mgalen007/blogapi/blob/main/src/guards/ownership.guard.ts): `src/guards/ownership.guard.ts`

### Blog resources

- [User routes](https://github.com/mgalen007/blogapi/blob/main/src/users/users.controller.ts): `src/users/users.controller.ts`
- [User service](https://github.com/mgalen007/blogapi/blob/main/src/users/users.service.ts): `src/users/users.service.ts`
- [Post routes](https://github.com/mgalen007/blogapi/blob/main/src/posts/posts.controller.ts): `src/posts/posts.controller.ts`
- [Post service](https://github.com/mgalen007/blogapi/blob/main/src/posts/posts.service.ts): `src/posts/posts.service.ts`
- [Comment routes](https://github.com/mgalen007/blogapi/blob/main/src/comments/comments.controller.ts): `src/comments/comments.controller.ts`
- [Comment service](https://github.com/mgalen007/blogapi/blob/main/src/comments/comments.service.ts): `src/comments/comments.service.ts`
- [Tag routes](https://github.com/mgalen007/blogapi/blob/main/src/tags/tags.controller.ts): `src/tags/tags.controller.ts`
- [Tag service](https://github.com/mgalen007/blogapi/blob/main/src/tags/tags.service.ts): `src/tags/tags.service.ts`

### Persistence

- [Prisma client](https://github.com/mgalen007/blogapi/blob/main/src/prisma/prisma.service.ts): `src/prisma/prisma.service.ts`
- **PostgreSQL**

### Other components

- **API client**

## Connections

- 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
