# abujubair7/dev-community architecture

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

- Interactive diagram: https://gitdiagram.com/abujubair7/dev-community
- Repository: https://github.com/abujubair7/dev-community

## Overview

1. **Overall shape**
   - This is a **NestJS backend API** for a developer/community platform.
   - The architecture is modular: `AppModule` wires together feature modules, and `main.ts` bootstraps the HTTP server.

2. **Runtime and persistence**
   - The app is TypeScript/NestJS running on Node.js.
   - `src/config/db.ts` indicates a database connection layer, and the entities/schema files strongly suggest **MongoDB with ObjectId-style references**.
   - `to-object-id` is a small utility boundary for converting IDs before queries.

3. **Request flow**
   - Incoming requests hit **controllers** in each module.
   - Controllers delegate to **services**, which contain the business rules and data access.
   - DTOs define request shapes, while entity files describe stored domain records.

4. **Authentication boundary**
   - The `auth` module handles **register/login** and issues a **JWT**.
   - `jwt.strategy.ts` and `jwt.guard.ts` protect authenticated routes.
   - The README says the token expires in **1 hour**.

5. **Authorization and ownership**
   - `role.guard.ts`, `self.guard.ts`, and the `role.decorator.ts` indicate layered authorization.
   - `self.guard` enforces “own resource” access for user/profile-style updates and deletes.
   - `role.guard` is likely used where member/community roles matter, especially in the community module.

6. **User profile subsystem**
   - The `users` module manages the core account record: profile retrieval, profile update, password update, and account deletion.
   - The README schema shows `User` as the primary identity record with names, unique email, password, and timestamps.

7. **Content and social subsystems**
   - `posts`, `comments`, and `reacts` form the community interaction layer.
   - Posts are top-level content.
   - Reactions are split into **post reactions** and **comment reactions**, with a shared `react-state` enum.
   - Comments are likely hierarchical, supported by helpers like `comments-tree`, `delete-replies`, and `update-reply-status`.

8. **Profile enrichment subsystems**
   - `skills` and `experiences` are user-linked profile data.
   - README confirms both are owned by `userId` and exposed through “my records” and “by userId” endpoints.
   - These modules are separate from auth/users, so profile enrichment stays decoupled from identity management.

9. **Community subsystem**
   - The `community` module is more workflow-heavy than the others.
   - It includes entities for `community`, `community-member`, `community-request`, and `community-invite`.
   - Supporting enums for invite status and member role suggest moderation/approval flows and membership state transitions.

10. **API contract and documentation**
   - `postman/openapi.json` plus the Postman request collection show the API is documented and likely used for manual/automated verification.
   - The README serves as the canonical endpoint map for the public REST surface.

11. **Deployment and local execution**
   - `Dockerfile` and `docker-compose.yml` indicate the service is container-friendly and likely run with a companion database container in development.
   - Build/test tooling is standard NestJS: unit tests per module, e2e tests in `test/`, and lint/format configs at the repo root.

12. **Important architectural boundary to diagram**
   - A good diagram should show:
     - external client → Nest controllers
     - controllers → module services
     - services → database/entities
     - auth guards/strategy wrapping protected routes
     - shared helpers used mainly by comments/community logic
   - The main domain partitions are: **auth**, **users**, **skills**, **experiences**, **posts**, **comments**, **reacts**, and **community**.

Main entry points: [`src/app.module.ts`](https://github.com/abujubair7/dev-community/blob/main/src/app.module.ts) (App module), [`src/config/db.ts`](https://github.com/abujubair7/dev-community/blob/main/src/config/db.ts) (DB config), [`src/modules/auth/auth.module.ts`](https://github.com/abujubair7/dev-community/blob/main/src/modules/auth/auth.module.ts) (Auth), [`src/modules/auth/guard`](https://github.com/abujubair7/dev-community/tree/main/src/modules/auth/guard) (Auth guards)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main["main.ts<br/>bootstrap<br/>[main.ts]"]
  node_app_module["App module<br/>composition root<br/>[app.module.ts]"]
  node_db_config[("DB config<br/>database config<br/>[db.ts]")]
  node_helpers["Shared helpers<br/>utility boundary"]
end

subgraph group_identity["Identity"]
  node_auth_module["Auth<br/>[auth.module.ts]"]
  node_jwt_strategy["JWT strategy<br/>passport strategy<br/>[jwt.strategy.ts]"]
  node_auth_guards{{"Auth guards<br/>route guards"}}
  node_users_module["Users<br/>account module<br/>[users.module.ts]"]
  node_auth_service["Auth service<br/>business logic<br/>[auth.service.ts]"]
  node_users_service["Users service<br/>business logic<br/>[users.service.ts]"]
end

subgraph group_content["Content"]
  node_posts_module["Posts<br/>content module<br/>[posts.module.ts]"]
  node_comments_module["Comments<br/>[comments.module.ts]"]
  node_reacts_module["Reacts<br/>reaction module<br/>[reacts.module.ts]"]
  node_posts_service["Posts service<br/>business logic<br/>[posts.service.ts]"]
  node_comments_service["Comments service<br/>business logic"]
  node_reacts_service["Reacts service<br/>business logic<br/>[reacts.service.ts]"]
end

subgraph group_community["Community"]
  node_community_module["Community<br/>membership workflow"]
  node_community_service["Community service<br/>business logic"]
end

subgraph group_profile["Profile"]
  node_skills_module["Skills<br/>profile module<br/>[skills.module.ts]"]
  node_experiences_module["Experiences<br/>profile module"]
  node_skills_service["Skills service<br/>business logic<br/>[skills.service.ts]"]
  node_experiences_service["Experiences service<br/>business logic"]
end

node_main -->|"bootstraps"| node_app_module
node_app_module -->|"connects"| node_db_config
node_app_module -->|"imports"| node_auth_module
node_app_module -->|"imports"| node_users_module
node_app_module -->|"imports"| node_posts_module
node_app_module -->|"imports"| node_comments_module
node_app_module -->|"imports"| node_reacts_module
node_app_module -->|"imports"| node_skills_module
node_app_module -->|"imports"| node_experiences_module
node_app_module -->|"imports"| node_community_module
node_auth_module -->|"provides"| node_auth_service
node_auth_module -->|"uses"| node_jwt_strategy
node_auth_module -->|"exports"| node_auth_guards
node_users_module -->|"provides"| node_users_service
node_posts_module -->|"provides"| node_posts_service
node_comments_module -->|"provides"| node_comments_service
node_reacts_module -->|"provides"| node_reacts_service
node_skills_module -->|"provides"| node_skills_service
node_experiences_module -->|"provides"| node_experiences_service
node_community_module -->|"provides"| node_community_service
node_auth_guards -.->|"protects"| node_users_service
node_auth_guards -.->|"protects"| node_community_service
node_comments_service -.->|"uses"| node_helpers
node_posts_service -->|"queries"| node_db_config
node_comments_service -->|"queries"| node_db_config
node_reacts_service -->|"queries"| node_db_config
node_skills_service -->|"queries"| node_db_config
node_experiences_service -->|"queries"| node_db_config
node_community_service -->|"queries"| node_db_config

click node_main "https://github.com/abujubair7/dev-community/blob/main/src/main.ts"
click node_app_module "https://github.com/abujubair7/dev-community/blob/main/src/app.module.ts"
click node_db_config "https://github.com/abujubair7/dev-community/blob/main/src/config/db.ts"
click node_helpers "https://github.com/abujubair7/dev-community/tree/main/src/helpers"
click node_auth_module "https://github.com/abujubair7/dev-community/blob/main/src/modules/auth/auth.module.ts"
click node_jwt_strategy "https://github.com/abujubair7/dev-community/blob/main/src/modules/auth/strategy/jwt.strategy.ts"
click node_auth_guards "https://github.com/abujubair7/dev-community/tree/main/src/modules/auth/guard"
click node_users_module "https://github.com/abujubair7/dev-community/blob/main/src/modules/users/users.module.ts"
click node_posts_module "https://github.com/abujubair7/dev-community/blob/main/src/modules/posts/posts.module.ts"
click node_comments_module "https://github.com/abujubair7/dev-community/blob/main/src/modules/comments/comments.module.ts"
click node_reacts_module "https://github.com/abujubair7/dev-community/blob/main/src/modules/reacts/reacts.module.ts"
click node_skills_module "https://github.com/abujubair7/dev-community/blob/main/src/modules/skills/skills.module.ts"
click node_experiences_module "https://github.com/abujubair7/dev-community/blob/main/src/modules/experiences/experiences.module.ts"
click node_community_module "https://github.com/abujubair7/dev-community/blob/main/src/modules/community/community.module.ts"
click node_auth_service "https://github.com/abujubair7/dev-community/blob/main/src/modules/auth/auth.service.ts"
click node_users_service "https://github.com/abujubair7/dev-community/blob/main/src/modules/users/users.service.ts"
click node_posts_service "https://github.com/abujubair7/dev-community/blob/main/src/modules/posts/posts.service.ts"
click node_comments_service "https://github.com/abujubair7/dev-community/blob/main/src/modules/comments/comments.service.ts"
click node_reacts_service "https://github.com/abujubair7/dev-community/blob/main/src/modules/reacts/reacts.service.ts"
click node_skills_service "https://github.com/abujubair7/dev-community/blob/main/src/modules/skills/skills.service.ts"
click node_experiences_service "https://github.com/abujubair7/dev-community/blob/main/src/modules/experiences/experiences.service.ts"
click node_community_service "https://github.com/abujubair7/dev-community/blob/main/src/modules/community/community.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_main,node_app_module,node_db_config,node_helpers toneBlue
class node_auth_module,node_jwt_strategy,node_auth_guards,node_users_module,node_auth_service,node_users_service toneAmber
class node_posts_module,node_comments_module,node_reacts_module,node_posts_service,node_comments_service,node_reacts_service toneMint
class node_community_module,node_community_service toneRose
class node_skills_module,node_experiences_module,node_skills_service,node_experiences_service toneIndigo
```

## Components

### Runtime

NestJS bootstrap and shared infrastructure

- [main.ts](https://github.com/abujubair7/dev-community/blob/main/src/main.ts): bootstrap · Starts the Nest HTTP server and loads the app module · `src/main.ts`
- [App module](https://github.com/abujubair7/dev-community/blob/main/src/app.module.ts): composition root · Wires the feature modules into one API · `src/app.module.ts`
- [DB config](https://github.com/abujubair7/dev-community/blob/main/src/config/db.ts): database config · Database connection setup and persistence wiring · `src/config/db.ts`
- [Shared helpers](https://github.com/abujubair7/dev-community/tree/main/src/helpers): utility boundary · Tree, reply, and ObjectId helpers used across content modules · `src/helpers`

### Identity

Authentication, authorization, and user account management

- [Auth](https://github.com/abujubair7/dev-community/blob/main/src/modules/auth/auth.module.ts): JWT auth module · Register/login flow and token issuance · `src/modules/auth/auth.module.ts`
- [JWT strategy](https://github.com/abujubair7/dev-community/blob/main/src/modules/auth/strategy/jwt.strategy.ts): passport strategy · Validates bearer tokens for protected routes · `src/modules/auth/strategy/jwt.strategy.ts`
- [Auth guards](https://github.com/abujubair7/dev-community/tree/main/src/modules/auth/guard): route guards · JWT, role, and self access control boundaries · `src/modules/auth/guard`
- [Users](https://github.com/abujubair7/dev-community/blob/main/src/modules/users/users.module.ts): account module · Core profile, password, and account lifecycle management · `src/modules/users/users.module.ts`
- [Auth service](https://github.com/abujubair7/dev-community/blob/main/src/modules/auth/auth.service.ts): business logic · Handles credentials, registration, and login rules · `src/modules/auth/auth.service.ts`
- [Users service](https://github.com/abujubair7/dev-community/blob/main/src/modules/users/users.service.ts): business logic · Manages account records and ownership checks · `src/modules/users/users.service.ts`

### Content

Posts, comments, and reactions

- [Posts](https://github.com/abujubair7/dev-community/blob/main/src/modules/posts/posts.module.ts): content module · Top-level community posts · `src/modules/posts/posts.module.ts`
- [Comments](https://github.com/abujubair7/dev-community/blob/main/src/modules/comments/comments.module.ts): threaded comments · Nested comment creation, updates, and deletes · `src/modules/comments/comments.module.ts`
- [Reacts](https://github.com/abujubair7/dev-community/blob/main/src/modules/reacts/reacts.module.ts): reaction module · Post and comment reaction state · `src/modules/reacts/reacts.module.ts`
- [Posts service](https://github.com/abujubair7/dev-community/blob/main/src/modules/posts/posts.service.ts): business logic · Creates and manages post records · `src/modules/posts/posts.service.ts`
- [Comments service](https://github.com/abujubair7/dev-community/blob/main/src/modules/comments/comments.service.ts): business logic · Builds comment trees and manages reply state · `src/modules/comments/comments.service.ts`
- [Reacts service](https://github.com/abujubair7/dev-community/blob/main/src/modules/reacts/reacts.service.ts): business logic · Applies reaction state to posts and comments · `src/modules/reacts/reacts.service.ts`

### Community

Membership and workflow-heavy community features

- [Community](https://github.com/abujubair7/dev-community/blob/main/src/modules/community/community.module.ts): membership workflow · Communities, members, requests, and invites · `src/modules/community/community.module.ts`
- [Community service](https://github.com/abujubair7/dev-community/blob/main/src/modules/community/community.service.ts): business logic · Coordinates membership, requests, and invites · `src/modules/community/community.service.ts`

### Profile

User-linked enrichment data

- [Skills](https://github.com/abujubair7/dev-community/blob/main/src/modules/skills/skills.module.ts): profile module · User-owned skill records · `src/modules/skills/skills.module.ts`
- [Experiences](https://github.com/abujubair7/dev-community/blob/main/src/modules/experiences/experiences.module.ts): profile module · User-owned experience records · `src/modules/experiences/experiences.module.ts`
- [Skills service](https://github.com/abujubair7/dev-community/blob/main/src/modules/skills/skills.service.ts): business logic · Stores user skill entries · `src/modules/skills/skills.service.ts`
- [Experiences service](https://github.com/abujubair7/dev-community/blob/main/src/modules/experiences/experiences.service.ts): business logic · Stores user experience entries · `src/modules/experiences/experiences.service.ts`

## Connections

- main.ts → App module: bootstraps · Application startup loads the root module
- App module → DB config: connects · Root module depends on database configuration
- App module → Auth: imports · Feature module composition
- App module → Users: imports · Feature module composition
- App module → Posts: imports · Feature module composition
- App module → Comments: imports · Feature module composition
- App module → Reacts: imports · Feature module composition
- App module → Skills: imports · Feature module composition
- App module → Experiences: imports · Feature module composition
- App module → Community: imports · Feature module composition
- Auth → Auth service: provides · Auth controllers delegate to auth service
- Auth → JWT strategy: uses · JWT validation boundary
- Auth → Auth guards: exports · Protects authenticated and role-scoped routes
- Users → Users service: provides · User controllers delegate to users service
- Posts → Posts service: provides · Post controllers delegate to posts service
- Comments → Comments service: provides · Comment controllers delegate to comments service
- Reacts → Reacts service: provides · Reaction controllers delegate to reacts service
- Skills → Skills service: provides · Skill controllers delegate to skills service
- Experiences → Experiences service: provides · Experience controllers delegate to experiences service
- Community → Community service: provides · Community controllers delegate to community service
- Auth guards → Users service: protects · Self and role checks guard account operations
- Auth guards → Community service: protects · Role-based access for moderation and membership flows
- Comments service → Shared helpers: uses · Tree building and reply cleanup helpers
- Posts service → DB config: queries · Persists post records through the database layer
- Comments service → DB config: queries · Persists threaded comments through the database layer
- Reacts service → DB config: queries · Persists reaction records through the database layer
- Skills service → DB config: queries · Persists skill records through the database layer
- Experiences service → DB config: queries · Persists experience records through the database layer
- Community service → DB config: queries · Persists communities and membership workflow records
