# sharad420/social-network-prod architecture

> Architecture diagram of the GitHub repository sharad420/social-network-prod, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sharad420/social-network-prod
- Repository: https://github.com/sharad420/social-network-prod

## Overview

This is a Django REST and React social network. A user enters through the SPA, which routes to public or protected pages; those pages use API clients to authenticate or retrieve and mutate social data. Backend views validate requests and apply authentication, OTP, post, follow, and profile logic, backed by relational models and Redis for ephemeral OTP state. The map preserves the documented registration/verification and social-feature branches. Some backend endpoints and frontend pages were not sampled, so their detailed call relationships are shown only where the README or source index supports them.

Main entry points: [`backend/network/views.py`](https://github.com/sharad420/social-network-prod/blob/main/backend/network/views.py) (API views), [`frontend/src/App.jsx`](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/App.jsx) (Routes and layout), [`frontend/src/api.js`](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/api.js) (REST API client), [`frontend/src/components/Post.jsx`](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/components/Post.jsx) (Post interactions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React application"]
  node_spa["SPA entry<br/>[main.jsx]"]
  node_router["Routes and layout<br/>[App.jsx]"]
  node_apiclient["REST API client<br/>[api.js]"]
end

subgraph group_auth["Authentication"]
  node_authstate["Auth context<br/>[AuthContext.jsx]"]
  node_login["Login<br/>[Login.jsx]"]
  node_registration["Registration form"]
  node_otpflow["Email OTP flow<br/>[EmailOtpFlow.jsx]"]
  node_authclient["Auth API client<br/>[authApi.js]"]
end

subgraph group_social["Social features"]
  node_home["Home feed<br/>[Home.jsx]"]
  node_following["Following feed<br/>[Following.jsx]"]
  node_profile["User profile<br/>[Profile.jsx]"]
  node_postui["Post interactions<br/>[Post.jsx]"]
end

subgraph group_backend["Django API"]
  node_views["API views<br/>[views.py]"]
  node_utils["Auth utilities<br/>[utils.py]"]
  node_serializers["Request serializers<br/>[serializers.py]"]
  node_redislogic["OTP key operations<br/>[redis_client.py]"]
end

subgraph group_data["Persistence"]
  node_models[("Social and account models<br/>[models.py]")]
  node_redis[("Redis")]
end

node_user(("Visitor"))
node_email["Email service"]

node_user -->|"opens"| node_spa
node_spa -->|"renders"| node_router
node_router -->|"routes to"| node_home
node_router -->|"routes to"| node_following
node_router -->|"routes to"| node_profile
node_router -->|"routes to"| node_login
node_router -->|"routes to"| node_registration
node_router -->|"provides state"| node_authstate
node_home -->|"renders"| node_postui
node_following -->|"renders"| node_postui
node_profile -->|"renders"| node_postui
node_home -->|"requests data"| node_apiclient
node_following -->|"requests data"| node_apiclient
node_profile -->|"requests data"| node_apiclient
node_postui -->|"mutates posts"| node_apiclient
node_login -->|"submits credentials"| node_authclient
node_login -->|"sets user"| node_authstate
node_authstate -->|"refreshes tokens"| node_apiclient
node_registration -->|"starts verification"| node_otpflow
node_apiclient -->|"calls REST API"| node_views
node_authclient -->|"calls REST API"| node_views
node_views -->|"uses auth helpers"| node_utils
node_views -->|"verifies OTP"| node_redislogic
node_views -->|"serializes responses"| node_serializers
node_views -->|"reads and writes"| node_models
node_utils -->|"tracks sessions"| node_models
node_redislogic -->|"stores OTP state"| node_redis
node_utils -->|"sends verification"| node_email
node_views -.->|"sends OTP"| node_email
node_views -->|"serves social data"| node_models

click node_spa "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/main.jsx"
click node_router "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/pages/Home.jsx"
click node_following "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/pages/Following.jsx"
click node_profile "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/pages/Profile.jsx"
click node_postui "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/components/Post.jsx"
click node_authstate "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/components/AuthContext.jsx"
click node_login "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/pages/Login.jsx"
click node_registration "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/components/RegistrationForm.jsx"
click node_otpflow "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/pages/EmailOtpFlow.jsx"
click node_authclient "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/authApi.js"
click node_apiclient "https://github.com/sharad420/social-network-prod/blob/main/frontend/src/api.js"
click node_views "https://github.com/sharad420/social-network-prod/blob/main/backend/network/views.py"
click node_utils "https://github.com/sharad420/social-network-prod/blob/main/backend/network/utils.py"
click node_serializers "https://github.com/sharad420/social-network-prod/blob/main/backend/network/serializers.py"
click node_models "https://github.com/sharad420/social-network-prod/blob/main/backend/network/models.py"
click node_redislogic "https://github.com/sharad420/social-network-prod/blob/main/backend/network/redis_client.py"

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_spa,node_router,node_apiclient toneBlue
class node_authstate,node_login,node_registration,node_otpflow,node_authclient toneAmber
class node_home,node_following,node_profile,node_postui toneMint
class node_views,node_utils,node_serializers,node_redislogic toneRose
class node_models,node_redis,node_user,node_email toneIndigo
```

## Components

### React application

- [SPA entry](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Routes and layout](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [REST API client](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/api.js): `frontend/src/api.js`

### Authentication

- [Auth context](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/components/AuthContext.jsx): `frontend/src/components/AuthContext.jsx`
- [Login](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Registration form](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/components/RegistrationForm.jsx): `frontend/src/components/RegistrationForm.jsx`
- [Email OTP flow](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/pages/EmailOtpFlow.jsx): `frontend/src/pages/EmailOtpFlow.jsx`
- [Auth API client](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/authApi.js): `frontend/src/authApi.js`

### Social features

- [Home feed](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Following feed](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/pages/Following.jsx): `frontend/src/pages/Following.jsx`
- [User profile](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/pages/Profile.jsx): `frontend/src/pages/Profile.jsx`
- [Post interactions](https://github.com/sharad420/social-network-prod/blob/main/frontend/src/components/Post.jsx): `frontend/src/components/Post.jsx`

### Django API

- [API views](https://github.com/sharad420/social-network-prod/blob/main/backend/network/views.py): `backend/network/views.py`
- [Auth utilities](https://github.com/sharad420/social-network-prod/blob/main/backend/network/utils.py): `backend/network/utils.py`
- [Request serializers](https://github.com/sharad420/social-network-prod/blob/main/backend/network/serializers.py): `backend/network/serializers.py`
- [OTP key operations](https://github.com/sharad420/social-network-prod/blob/main/backend/network/redis_client.py): `backend/network/redis_client.py`

### Persistence

- [Social and account models](https://github.com/sharad420/social-network-prod/blob/main/backend/network/models.py): `backend/network/models.py`
- **Redis**

### Other components

- **Visitor**
- **Email service**

## Connections

- Visitor → SPA entry: opens (evidence: `frontend/src/main.jsx`)
- SPA entry → Routes and layout: renders (evidence: `frontend/src/main.jsx`)
- Routes and layout → Home feed: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Following feed: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → User profile: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Login: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Registration form: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Auth context: provides state (evidence: `frontend/src/App.jsx`)
- Home feed → Post interactions: renders (evidence: `frontend/src/pages/Home.jsx`)
- Following feed → Post interactions: renders (evidence: `frontend/src/pages/Following.jsx`)
- User profile → Post interactions: renders (evidence: `frontend/src/pages/Profile.jsx`)
- Home feed → REST API client: requests data (evidence: `frontend/src/pages/Home.jsx`)
- Following feed → REST API client: requests data (evidence: `frontend/src/pages/Following.jsx`)
- User profile → REST API client: requests data (evidence: `frontend/src/pages/Profile.jsx`)
- Post interactions → REST API client: mutates posts (evidence: `frontend/src/components/Post.jsx`)
- Login → Auth API client: submits credentials (evidence: `frontend/src/pages/Login.jsx`)
- Login → Auth context: sets user (evidence: `frontend/src/pages/Login.jsx`)
- Auth context → REST API client: refreshes tokens (evidence: `frontend/src/components/AuthContext.jsx`)
- Registration form → Email OTP flow: starts verification (evidence: `frontend/src/pages/Register.jsx`)
- REST API client → API views: calls REST API (evidence: `README.md`)
- Auth API client → API views: calls REST API (evidence: `README.md`)
- API views → Auth utilities: uses auth helpers (evidence: `backend/network/views.py`)
- API views → OTP key operations: verifies OTP (evidence: `backend/network/views.py`)
- API views → Request serializers: serializes responses (evidence: `backend/network/views.py`)
- API views → Social and account models: reads and writes (evidence: `backend/network/views.py`)
- Auth utilities → Social and account models: tracks sessions (evidence: `backend/network/utils.py`)
- OTP key operations → Redis: stores OTP state (evidence: `backend/network/redis_client.py`)
- Auth utilities → Email service: sends verification (evidence: `backend/network/utils.py`)
- API views → Email service: sends OTP
- API views → Social and account models: serves social data (evidence: `README.md`)
