# codefactory-co/nestjs-lv1 architecture

> Architecture diagram of the GitHub repository codefactory-co/nestjs-lv1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codefactory-co/nestjs-lv1
- Repository: https://github.com/codefactory-co/nestjs-lv1

## Overview

This is a NestJS server starter whose source tree implements a social application API: email registration and token-based authentication, user profiles and follows, posts and images, comments, and chats/messages. HTTP controllers delegate domain operations to services; TypeORM entities represent persisted state, while shared pagination and request infrastructure support those domains. The README describes Nest rather than the application, so feature coverage comes from the source tree and excerpts. Chat gateway behavior and several unsampled integrations are represented only where the index supports a relationship.

Main entry points: [`src/posts/posts.service.ts`](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/posts.service.ts) (Post Logic), [`src/posts/posts.controller.ts`](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/posts.controller.ts) (Posts API), [`src/posts/comments/comments.controller.ts`](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/comments/comments.controller.ts) (Comments API), [`src/auth/auth.service.ts`](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/auth/auth.service.ts) (Token and Auth Logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application Entry"]
  node_bootstrap["Nest Bootstrap<br/>[main.ts]"]
  node_application["Application Modules<br/>[app.module.ts]"]
end

subgraph group_identity["Identity and Users"]
  node_auth_api["Auth API<br/>[auth.controller.ts]"]
  node_auth_logic["Token and Auth Logic<br/>[auth.service.ts]"]
  node_token_guard["Bearer Token Guard"]
  node_users_api["Users API"]
  node_users_logic["User and Follow Logic<br/>[users.service.ts]"]
  node_user_records[("User Records<br/>[users.entity.ts]")]
end

subgraph group_content["Social Content"]
  node_posts_api["Posts API"]
  node_posts_logic["Post Logic<br/>[posts.service.ts]"]
  node_post_records[("Post Records<br/>[posts.entity.ts]")]
  node_image_logic["Post Images<br/>[images.service.ts]"]
  node_comments_api["Comments API"]
  node_comments_logic["Comment Logic"]
  node_comment_records[("Comment Records<br/>[comments.entity.ts]")]
end

subgraph group_messaging["Chat and Messaging"]
  node_chats_api["Chats API"]
  node_chats_logic["Chat Logic<br/>[chats.service.ts]"]
  node_chat_records[("Chat Records<br/>[chats.entity.ts]")]
  node_messages_api["Messages API"]
  node_messages_logic["Message Logic"]
  node_message_records[("Message Records<br/>[messages.entity.ts]")]
end

subgraph group_shared["Shared Infrastructure"]
  node_common_logic["Pagination Helpers<br/>[common.service.ts]"]
end

node_client(("API Client"))
node_postgres[("PostgreSQL")]

node_client -.->|"requests"| node_auth_api
node_client -.->|"requests"| node_users_api
node_client -.->|"requests"| node_posts_api
node_client -.->|"requests"| node_comments_api
node_client -.->|"requests"| node_chats_api
node_client -.->|"requests"| node_messages_api
node_bootstrap -->|"loads"| node_application
node_application -->|"configures"| node_postgres
node_auth_api -->|"delegates to"| node_auth_logic
node_token_guard -->|"validates with"| node_auth_logic
node_auth_logic -->|"looks up users"| node_users_logic
node_users_api -->|"delegates to"| node_users_logic
node_users_logic -->|"reads and writes"| node_user_records
node_posts_api -->|"delegates to"| node_posts_logic
node_posts_api -->|"creates images"| node_image_logic
node_posts_logic -->|"reads and writes"| node_post_records
node_posts_logic -->|"uses pagination"| node_common_logic
node_comments_api -->|"delegates to"| node_comments_logic
node_comments_api -->|"updates comment count"| node_posts_logic
node_comments_logic -->|"reads and writes"| node_comment_records
node_chats_api -->|"delegates to"| node_chats_logic
node_chats_logic -->|"uses entity"| node_chat_records
node_messages_api -->|"delegates to"| node_messages_logic
node_messages_logic -->|"uses entity"| node_message_records

click node_bootstrap "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/main.ts"
click node_application "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/app.module.ts"
click node_auth_api "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/auth/auth.controller.ts"
click node_auth_logic "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/auth/auth.service.ts"
click node_token_guard "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/auth/guard/bearer-token.guard.ts"
click node_users_api "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/users/users.controller.ts"
click node_users_logic "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/users/users.service.ts"
click node_user_records "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/users/entity/users.entity.ts"
click node_posts_api "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/posts.controller.ts"
click node_posts_logic "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/posts.service.ts"
click node_post_records "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/entity/posts.entity.ts"
click node_image_logic "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/image/images.service.ts"
click node_comments_api "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/comments/comments.controller.ts"
click node_comments_logic "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/comments/comments.service.ts"
click node_comment_records "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/comments/entity/comments.entity.ts"
click node_chats_api "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/chats.controller.ts"
click node_chats_logic "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/chats.service.ts"
click node_chat_records "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/entity/chats.entity.ts"
click node_messages_api "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/messages/messages.controller.ts"
click node_messages_logic "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/messages/messages.service.ts"
click node_message_records "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/messages/entity/messages.entity.ts"
click node_common_logic "https://github.com/codefactory-co/nestjs-lv1/blob/main/src/common/common.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_bootstrap,node_application,node_client toneBlue
class node_auth_api,node_auth_logic,node_token_guard,node_users_api,node_users_logic,node_user_records,node_postgres toneAmber
class node_posts_api,node_posts_logic,node_post_records,node_image_logic,node_comments_api,node_comments_logic,node_comment_records toneMint
class node_chats_api,node_chats_logic,node_chat_records,node_messages_api,node_messages_logic,node_message_records toneRose
class node_common_logic toneIndigo
```

## Components

### Application Entry

- [Nest Bootstrap](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/main.ts): `src/main.ts`
- [Application Modules](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/app.module.ts): `src/app.module.ts`

### Identity and Users

- [Auth API](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Token and Auth Logic](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [Bearer Token Guard](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/auth/guard/bearer-token.guard.ts): `src/auth/guard/bearer-token.guard.ts`
- [Users API](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/users/users.controller.ts): `src/users/users.controller.ts`
- [User and Follow Logic](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/users/users.service.ts): `src/users/users.service.ts`
- [User Records](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/users/entity/users.entity.ts): `src/users/entity/users.entity.ts`

### Social Content

- [Posts API](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/posts.controller.ts): `src/posts/posts.controller.ts`
- [Post Logic](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/posts.service.ts): `src/posts/posts.service.ts`
- [Post Records](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/entity/posts.entity.ts): `src/posts/entity/posts.entity.ts`
- [Post Images](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/image/images.service.ts): `src/posts/image/images.service.ts`
- [Comments API](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/comments/comments.controller.ts): `src/posts/comments/comments.controller.ts`
- [Comment Logic](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/comments/comments.service.ts): `src/posts/comments/comments.service.ts`
- [Comment Records](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/posts/comments/entity/comments.entity.ts): `src/posts/comments/entity/comments.entity.ts`

### Chat and Messaging

- [Chats API](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/chats.controller.ts): `src/chats/chats.controller.ts`
- [Chat Logic](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/chats.service.ts): `src/chats/chats.service.ts`
- [Chat Records](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/entity/chats.entity.ts): `src/chats/entity/chats.entity.ts`
- [Messages API](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/messages/messages.controller.ts): `src/chats/messages/messages.controller.ts`
- [Message Logic](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/messages/messages.service.ts): `src/chats/messages/messages.service.ts`
- [Message Records](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/chats/messages/entity/messages.entity.ts): `src/chats/messages/entity/messages.entity.ts`

### Shared Infrastructure

- [Pagination Helpers](https://github.com/codefactory-co/nestjs-lv1/blob/main/src/common/common.service.ts): `src/common/common.service.ts`

### Other components

- **API Client**
- **PostgreSQL**

## Connections

- API Client → Auth API: requests
- API Client → Users API: requests
- API Client → Posts API: requests
- API Client → Comments API: requests
- API Client → Chats API: requests
- API Client → Messages API: requests
- Nest Bootstrap → Application Modules: loads (evidence: `src/main.ts`)
- Application Modules → PostgreSQL: configures (evidence: `src/app.module.ts`)
- Auth API → Token and Auth Logic: delegates to (evidence: `src/auth/auth.controller.ts`)
- Bearer Token Guard → Token and Auth Logic: validates with (evidence: `src/auth/guard/bearer-token.guard.ts`)
- Token and Auth Logic → User and Follow Logic: looks up users (evidence: `src/auth/auth.service.ts`)
- Users API → User and Follow Logic: delegates to (evidence: `src/users/users.controller.ts`)
- User and Follow Logic → User Records: reads and writes (evidence: `src/users/users.service.ts`)
- Posts API → Post Logic: delegates to (evidence: `src/posts/posts.controller.ts`)
- Posts API → Post Images: creates images (evidence: `src/posts/posts.controller.ts`)
- Post Logic → Post Records: reads and writes (evidence: `src/posts/posts.service.ts`)
- Post Logic → Pagination Helpers: uses pagination (evidence: `src/posts/posts.service.ts`)
- Comments API → Comment Logic: delegates to (evidence: `src/posts/comments/comments.controller.ts`)
- Comments API → Post Logic: updates comment count (evidence: `src/posts/comments/comments.controller.ts`)
- Comment Logic → Comment Records: reads and writes (evidence: `src/posts/comments/comments.service.ts`)
- Chats API → Chat Logic: delegates to (evidence: `src/chats/chats.controller.ts`)
- Chat Logic → Chat Records: uses entity (evidence: `src/chats/chats.service.ts`)
- Messages API → Message Logic: delegates to (evidence: `src/chats/messages/messages.controller.ts`)
- Message Logic → Message Records: uses entity (evidence: `src/chats/messages/messages.service.ts`)
