# ashutoshmodi/socialplatform_backend architecture

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

- Interactive diagram: https://gitdiagram.com/ashutoshmodi/socialplatform_backend
- Repository: https://github.com/ashutoshmodi/socialplatform_backend

## Overview

SocialPlatform is an ASP.NET Core social-platform backend: clients enter through an Ocelot gateway, then use user and post capabilities, while comment and notification services are documented as health-only scaffolds. The main workflows include registration/login, profiles and follows, post creation and feeds, and likes. The README documents gateway routing, per-service databases, Redis caching, and the protected post-to-user internal call. Some service internals and scaffold implementations were not sampled, so their details are limited to documented behavior.

Main entry points: [`gateway/ApiGateway/Program.cs`](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/gateway/ApiGateway/Program.cs) (API gateway), [`services/post-service/PostService/Services/PostService.cs`](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/post-service/PostService/Services/PostService.cs) (Posts, feeds, likes), [`services/user-service/UserService/Services/ProfileService.cs`](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Services/ProfileService.cs) (Profiles and follows), [`services/user-service/UserService/Data/UserDbContext.cs`](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Data/UserDbContext.cs) (User persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Gateway edge"]
  node_gateway["API gateway<br/>[Program.cs]"]
  node_rate["Rate limiting"]
  node_logging["Request logging"]
end

subgraph group_identity["Users and social graph"]
  node_auth_api["Registration and login<br/>[AuthController.cs]"]
  node_user_ops["User accounts and JWT<br/>[UserService.cs]"]
  node_profile_api["Profile and follow API"]
  node_internal_api["Internal user API"]
  node_profile_ops["Profiles and follows<br/>[ProfileService.cs]"]
  node_user_data[("User persistence<br/>[UserDbContext.cs]")]
  node_redis[("Redis cache")]
end

subgraph group_content["Posts and feeds"]
  node_post_api["Posts API<br/>[PostsController.cs]"]
  node_post_ops["Posts, feeds, likes<br/>[PostService.cs]"]
  node_user_client["User service client"]
  node_post_data[("Post persistence<br/>[PostDbContext.cs]")]
  node_post_models["Post and feed models<br/>[Post.cs]"]
end

subgraph group_support["Scaffold services"]
  node_notification["Notification scaffold<br/>[Program.cs]"]
  node_comment["Comment scaffold<br/>[Program.cs]"]
end

node_client(("Browser or app"))
node_user_db[("User PostgreSQL")]
node_post_db[("Post PostgreSQL")]
node_notification_db[("Notification PostgreSQL")]

node_client -->|"sends HTTP"| node_gateway
node_gateway -->|"uses middleware"| node_rate
node_gateway -->|"uses middleware"| node_logging
node_gateway -->|"routes requests"| node_auth_api
node_gateway -->|"routes requests"| node_post_api
node_gateway -->|"routes requests"| node_notification
node_gateway -->|"routes requests"| node_comment
node_auth_api -->|"calls"| node_user_ops
node_user_ops -->|"reads and writes"| node_user_data
node_profile_api -->|"calls"| node_profile_ops
node_internal_api -->|"calls"| node_profile_ops
node_profile_ops -->|"reads and writes"| node_user_data
node_profile_ops -->|"caches profiles and follows"| node_redis
node_user_data -->|"persists users and follows"| node_user_db
node_post_api -->|"calls"| node_post_ops
node_post_ops -->|"reads and writes"| node_post_data
node_post_ops -->|"requests follow IDs"| node_user_client
node_user_client -->|"calls internal API"| node_internal_api
node_post_data -->|"persists posts and likes"| node_post_db
node_post_ops -->|"maps post results"| node_post_models
node_notification -->|"owns database"| node_notification_db

click node_gateway "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/gateway/ApiGateway/Program.cs"
click node_rate "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/gateway/ApiGateway/Middleware/RateLimitMiddleware.cs"
click node_logging "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/gateway/ApiGateway/Middleware/RequestLoggingMiddleware.cs"
click node_auth_api "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Controllers/AuthController.cs"
click node_user_ops "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Services/UserService.cs"
click node_profile_api "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Controllers/ProfilesController.cs"
click node_internal_api "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Controllers/InternalController.cs"
click node_profile_ops "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Services/ProfileService.cs"
click node_user_data "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Data/UserDbContext.cs"
click node_post_api "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/post-service/PostService/Controller/PostsController.cs"
click node_post_ops "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/post-service/PostService/Services/PostService.cs"
click node_user_client "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/post-service/PostService/Clients/UserServiceClient.cs"
click node_post_data "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/post-service/PostService/Data/PostDbContext.cs"
click node_post_models "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/post-service/PostService/Models/Post.cs"
click node_notification "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/notification-service/NotificationService/Program.cs"
click node_comment "https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/comment-service/CommentService/Program.cs"

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_gateway,node_rate,node_logging,node_client toneBlue
class node_auth_api,node_user_ops,node_profile_api,node_internal_api,node_profile_ops,node_user_data,node_redis,node_user_db,node_post_db,node_notification_db toneAmber
class node_post_api,node_post_ops,node_user_client,node_post_data,node_post_models toneMint
class node_notification,node_comment toneRose
```

## Components

### Gateway edge

- [API gateway](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/gateway/ApiGateway/Program.cs): `gateway/ApiGateway/Program.cs`
- [Rate limiting](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/gateway/ApiGateway/Middleware/RateLimitMiddleware.cs): `gateway/ApiGateway/Middleware/RateLimitMiddleware.cs`
- [Request logging](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/gateway/ApiGateway/Middleware/RequestLoggingMiddleware.cs): `gateway/ApiGateway/Middleware/RequestLoggingMiddleware.cs`

### Users and social graph

- [Registration and login](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Controllers/AuthController.cs): `services/user-service/UserService/Controllers/AuthController.cs`
- [User accounts and JWT](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Services/UserService.cs): `services/user-service/UserService/Services/UserService.cs`
- [Profile and follow API](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Controllers/ProfilesController.cs): `services/user-service/UserService/Controllers/ProfilesController.cs`
- [Internal user API](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Controllers/InternalController.cs): `services/user-service/UserService/Controllers/InternalController.cs`
- [Profiles and follows](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Services/ProfileService.cs): `services/user-service/UserService/Services/ProfileService.cs`
- [User persistence](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/user-service/UserService/Data/UserDbContext.cs): `services/user-service/UserService/Data/UserDbContext.cs`
- **Redis cache**

### Posts and feeds

- [Posts API](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/post-service/PostService/Controller/PostsController.cs): `services/post-service/PostService/Controller/PostsController.cs`
- [Posts, feeds, likes](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/post-service/PostService/Services/PostService.cs): `services/post-service/PostService/Services/PostService.cs`
- [User service client](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/post-service/PostService/Clients/UserServiceClient.cs): `services/post-service/PostService/Clients/UserServiceClient.cs`
- [Post persistence](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/post-service/PostService/Data/PostDbContext.cs): `services/post-service/PostService/Data/PostDbContext.cs`
- [Post and feed models](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/post-service/PostService/Models/Post.cs): `services/post-service/PostService/Models/Post.cs`

### Scaffold services

- [Notification scaffold](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/notification-service/NotificationService/Program.cs): `services/notification-service/NotificationService/Program.cs`
- [Comment scaffold](https://github.com/ashutoshmodi/socialplatform_backend/blob/main/services/comment-service/CommentService/Program.cs): `services/comment-service/CommentService/Program.cs`

### Other components

- **Browser or app**
- **User PostgreSQL**
- **Post PostgreSQL**
- **Notification PostgreSQL**

## Connections

- Browser or app → API gateway: sends HTTP (evidence: `README.md`)
- API gateway → Rate limiting: uses middleware (evidence: `gateway/ApiGateway/Program.cs`)
- API gateway → Request logging: uses middleware (evidence: `gateway/ApiGateway/Program.cs`)
- API gateway → Registration and login: routes requests (evidence: `README.md`)
- API gateway → Posts API: routes requests (evidence: `README.md`)
- API gateway → Notification scaffold: routes requests (evidence: `README.md`)
- API gateway → Comment scaffold: routes requests (evidence: `README.md`)
- Registration and login → User accounts and JWT: calls (evidence: `services/user-service/UserService/Controllers/AuthController.cs`)
- User accounts and JWT → User persistence: reads and writes (evidence: `services/user-service/UserService/Services/UserService.cs`)
- Profile and follow API → Profiles and follows: calls (evidence: `services/user-service/UserService/Controllers/ProfilesController.cs`)
- Internal user API → Profiles and follows: calls (evidence: `services/user-service/UserService/Controllers/InternalController.cs`)
- Profiles and follows → User persistence: reads and writes (evidence: `services/user-service/UserService/Services/ProfileService.cs`)
- Profiles and follows → Redis cache: caches profiles and follows (evidence: `services/user-service/UserService/Services/ProfileService.cs`)
- User persistence → User PostgreSQL: persists users and follows (evidence: `README.md`)
- Posts API → Posts, feeds, likes: calls (evidence: `services/post-service/PostService/Controller/PostsController.cs`)
- Posts, feeds, likes → Post persistence: reads and writes (evidence: `services/post-service/PostService/Services/PostService.cs`)
- Posts, feeds, likes → User service client: requests follow IDs (evidence: `services/post-service/PostService/Services/PostService.cs`)
- User service client → Internal user API: calls internal API (evidence: `README.md`)
- Post persistence → Post PostgreSQL: persists posts and likes (evidence: `README.md`)
- Posts, feeds, likes → Post and feed models: maps post results (evidence: `services/post-service/PostService/Services/PostService.cs`)
- Notification scaffold → Notification PostgreSQL: owns database (evidence: `README.md`)
