# anup4944/vinstagram architecture

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

- Interactive diagram: https://gitdiagram.com/anup4944/vinstagram
- Repository: https://github.com/anup4944/vinstagram

## Overview

This is a social-network application: users authenticate, browse a post feed, interact with posts, and manage profiles and relationships. The client routes users through protected pages and provides shared authentication, post, and user state; the Express API handles domain operations backed by Prisma and Cloudinary. Password reset also uses email. The excerpts show several client-to-API calls and controller dependencies, but not the full client API wiring or server setup, so uncertain cross-tier links are omitted or marked unverified.

Main entry points: [`server/server.ts`](https://github.com/anup4944/vinstagram/blob/master/server/server.ts) (HTTP server), [`client/src/App.tsx`](https://github.com/anup4944/vinstagram/blob/master/client/src/App.tsx) (Route application), [`client/src/hooks/useAuth.ts`](https://github.com/anup4944/vinstagram/blob/master/client/src/hooks/useAuth.ts) (Auth hook), [`client/src/pages/Posts.tsx`](https://github.com/anup4944/vinstagram/blob/master/client/src/pages/Posts.tsx) (Feed page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Route application<br/>[App.tsx]"]
  node_authui["Auth state<br/>[AuthProvider.tsx]"]
  node_login["Login and signup<br/>[Login.tsx]"]
  node_feedpage["Feed page<br/>[Posts.tsx]"]
  node_postview["Post interactions<br/>[Post.tsx]"]
  node_postedit["Post editing<br/>[EditPostModal.tsx]"]
  node_profile["Profile management<br/>[UserProfile.tsx]"]
  node_search["Search<br/>[Search.tsx]"]
  node_poststate["Post state<br/>[PostProvider.tsx]"]
  node_userstate["User state<br/>[UserProvider.tsx]"]
  node_posthook["Post hook<br/>[usePosts.ts]"]
  node_authhook["Auth hook<br/>[useAuth.ts]"]
  node_protected["Route protection<br/>[ProtectedRoute.tsx]"]
end

subgraph group_api["API and domain"]
  node_server["HTTP server<br/>[server.ts]"]
  node_authroutes["Auth routes<br/>[authRoutes.ts]"]
  node_authcontroller["Authentication<br/>[authController.ts]"]
  node_postroutes["Post routes<br/>[postRoute.ts]"]
  node_postcontroller["Posts and comments<br/>[postController.ts]"]
  node_userroutes["User routes<br/>[userRoutes.ts]"]
  node_usercontroller["Profiles and follows<br/>[userContoller.ts]"]
  node_authmw["Token verification<br/>[auth.ts]"]
end

subgraph group_infra["Persistence and integrations"]
  node_db[("Relational data<br/>[prisma.ts]")]
  node_cloudinary["Media storage<br/>[cloudinary.ts]"]
  node_email["Reset email<br/>[sendEmail.ts]"]
  node_mailer["Mail transport<br/>[nodemailer.ts]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_feedpage
node_app -->|"routes to"| node_profile
node_app -->|"guards pages"| node_protected
node_login -->|"uses"| node_authhook
node_authhook -->|"reads context"| node_authui
node_feedpage -->|"renders"| node_search
node_feedpage -->|"renders"| node_postview
node_feedpage -->|"reads state"| node_posthook
node_postedit -->|"updates posts"| node_posthook
node_profile -->|"opens"| node_postedit
node_profile -->|"reads state"| node_posthook
node_profile -->|"reads state"| node_authhook
node_search -->|"uses"| node_authhook
node_search -->|"searches posts"| node_posthook
node_protected -->|"checks session"| node_authhook
node_server -->|"registers"| node_authroutes
node_server -->|"registers"| node_postroutes
node_server -->|"registers"| node_userroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_postroutes -->|"dispatches"| node_postcontroller
node_userroutes -->|"dispatches"| node_usercontroller
node_postroutes -->|"protects routes"| node_authmw
node_userroutes -->|"protects routes"| node_authmw
node_authcontroller -->|"reads and writes"| node_db
node_postcontroller -->|"reads and writes"| node_db
node_usercontroller -->|"reads and writes"| node_db
node_authcontroller -->|"uploads avatars"| node_cloudinary
node_postcontroller -->|"manages images"| node_cloudinary
node_authcontroller -->|"sends reset link"| node_email
node_email -->|"uses transport"| node_mailer
node_authui -.->|"calls API"| node_server
node_poststate -.->|"calls API"| node_server
node_userstate -.->|"calls API"| node_server

click node_app "https://github.com/anup4944/vinstagram/blob/master/client/src/App.tsx"
click node_authui "https://github.com/anup4944/vinstagram/blob/master/client/src/context/AuthProvider.tsx"
click node_login "https://github.com/anup4944/vinstagram/blob/master/client/src/pages/Login.tsx"
click node_feedpage "https://github.com/anup4944/vinstagram/blob/master/client/src/pages/Posts.tsx"
click node_postview "https://github.com/anup4944/vinstagram/blob/master/client/src/components/Post.tsx"
click node_postedit "https://github.com/anup4944/vinstagram/blob/master/client/src/components/EditPostModal.tsx"
click node_profile "https://github.com/anup4944/vinstagram/blob/master/client/src/pages/UserProfile.tsx"
click node_search "https://github.com/anup4944/vinstagram/blob/master/client/src/components/Search.tsx"
click node_poststate "https://github.com/anup4944/vinstagram/blob/master/client/src/context/PostProvider.tsx"
click node_userstate "https://github.com/anup4944/vinstagram/blob/master/client/src/context/UserProvider.tsx"
click node_posthook "https://github.com/anup4944/vinstagram/blob/master/client/src/hooks/usePosts.ts"
click node_authhook "https://github.com/anup4944/vinstagram/blob/master/client/src/hooks/useAuth.ts"
click node_protected "https://github.com/anup4944/vinstagram/blob/master/client/src/components/ProtectedRoute.tsx"
click node_server "https://github.com/anup4944/vinstagram/blob/master/server/server.ts"
click node_authroutes "https://github.com/anup4944/vinstagram/blob/master/server/routes/authRoutes.ts"
click node_authcontroller "https://github.com/anup4944/vinstagram/blob/master/server/contollers/authController.ts"
click node_postroutes "https://github.com/anup4944/vinstagram/blob/master/server/routes/postRoute.ts"
click node_postcontroller "https://github.com/anup4944/vinstagram/blob/master/server/contollers/postController.ts"
click node_userroutes "https://github.com/anup4944/vinstagram/blob/master/server/routes/userRoutes.ts"
click node_usercontroller "https://github.com/anup4944/vinstagram/blob/master/server/contollers/userContoller.ts"
click node_authmw "https://github.com/anup4944/vinstagram/blob/master/server/middleware/auth.ts"
click node_db "https://github.com/anup4944/vinstagram/blob/master/server/config/prisma.ts"
click node_cloudinary "https://github.com/anup4944/vinstagram/blob/master/server/config/cloudinary.ts"
click node_email "https://github.com/anup4944/vinstagram/blob/master/server/utils/sendEmail.ts"
click node_mailer "https://github.com/anup4944/vinstagram/blob/master/server/config/nodemailer.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_app,node_authui,node_login,node_feedpage,node_postview,node_postedit,node_profile,node_search,node_poststate,node_userstate,node_posthook,node_authhook,node_protected,node_user toneBlue
class node_server,node_authroutes,node_authcontroller,node_postroutes,node_postcontroller,node_userroutes,node_usercontroller,node_authmw toneAmber
class node_db,node_cloudinary,node_email,node_mailer toneMint
```

## Components

### Web client

- [Route application](https://github.com/anup4944/vinstagram/blob/master/client/src/App.tsx): `client/src/App.tsx`
- [Auth state](https://github.com/anup4944/vinstagram/blob/master/client/src/context/AuthProvider.tsx): `client/src/context/AuthProvider.tsx`
- [Login and signup](https://github.com/anup4944/vinstagram/blob/master/client/src/pages/Login.tsx): `client/src/pages/Login.tsx`
- [Feed page](https://github.com/anup4944/vinstagram/blob/master/client/src/pages/Posts.tsx): `client/src/pages/Posts.tsx`
- [Post interactions](https://github.com/anup4944/vinstagram/blob/master/client/src/components/Post.tsx): `client/src/components/Post.tsx`
- [Post editing](https://github.com/anup4944/vinstagram/blob/master/client/src/components/EditPostModal.tsx): `client/src/components/EditPostModal.tsx`
- [Profile management](https://github.com/anup4944/vinstagram/blob/master/client/src/pages/UserProfile.tsx): `client/src/pages/UserProfile.tsx`
- [Search](https://github.com/anup4944/vinstagram/blob/master/client/src/components/Search.tsx): `client/src/components/Search.tsx`
- [Post state](https://github.com/anup4944/vinstagram/blob/master/client/src/context/PostProvider.tsx): `client/src/context/PostProvider.tsx`
- [User state](https://github.com/anup4944/vinstagram/blob/master/client/src/context/UserProvider.tsx): `client/src/context/UserProvider.tsx`
- [Post hook](https://github.com/anup4944/vinstagram/blob/master/client/src/hooks/usePosts.ts): `client/src/hooks/usePosts.ts`
- [Auth hook](https://github.com/anup4944/vinstagram/blob/master/client/src/hooks/useAuth.ts): `client/src/hooks/useAuth.ts`
- [Route protection](https://github.com/anup4944/vinstagram/blob/master/client/src/components/ProtectedRoute.tsx): `client/src/components/ProtectedRoute.tsx`

### API and domain

- [HTTP server](https://github.com/anup4944/vinstagram/blob/master/server/server.ts): `server/server.ts`
- [Auth routes](https://github.com/anup4944/vinstagram/blob/master/server/routes/authRoutes.ts): `server/routes/authRoutes.ts`
- [Authentication](https://github.com/anup4944/vinstagram/blob/master/server/contollers/authController.ts): `server/contollers/authController.ts`
- [Post routes](https://github.com/anup4944/vinstagram/blob/master/server/routes/postRoute.ts): `server/routes/postRoute.ts`
- [Posts and comments](https://github.com/anup4944/vinstagram/blob/master/server/contollers/postController.ts): `server/contollers/postController.ts`
- [User routes](https://github.com/anup4944/vinstagram/blob/master/server/routes/userRoutes.ts): `server/routes/userRoutes.ts`
- [Profiles and follows](https://github.com/anup4944/vinstagram/blob/master/server/contollers/userContoller.ts): `server/contollers/userContoller.ts`
- [Token verification](https://github.com/anup4944/vinstagram/blob/master/server/middleware/auth.ts): `server/middleware/auth.ts`

### Persistence and integrations

- [Relational data](https://github.com/anup4944/vinstagram/blob/master/server/config/prisma.ts): `server/config/prisma.ts`
- [Media storage](https://github.com/anup4944/vinstagram/blob/master/server/config/cloudinary.ts): `server/config/cloudinary.ts`
- [Reset email](https://github.com/anup4944/vinstagram/blob/master/server/utils/sendEmail.ts): `server/utils/sendEmail.ts`
- [Mail transport](https://github.com/anup4944/vinstagram/blob/master/server/config/nodemailer.ts): `server/config/nodemailer.ts`

### Other components

- **User**

## Connections

- User → Route application: uses (evidence: `client/src/App.tsx`)
- Route application → Login and signup: routes to (evidence: `client/src/App.tsx`)
- Route application → Feed page: routes to (evidence: `client/src/App.tsx`)
- Route application → Profile management: routes to (evidence: `client/src/App.tsx`)
- Route application → Route protection: guards pages (evidence: `client/src/App.tsx`)
- Login and signup → Auth hook: uses (evidence: `client/src/pages/Login.tsx`)
- Auth hook → Auth state: reads context (evidence: `client/src/hooks/useAuth.ts`)
- Feed page → Search: renders (evidence: `client/src/pages/Posts.tsx`)
- Feed page → Post interactions: renders (evidence: `client/src/pages/Posts.tsx`)
- Feed page → Post hook: reads state (evidence: `client/src/pages/Posts.tsx`)
- Post editing → Post hook: updates posts (evidence: `client/src/components/EditPostModal.tsx`)
- Profile management → Post editing: opens (evidence: `client/src/pages/UserProfile.tsx`)
- Profile management → Post hook: reads state (evidence: `client/src/pages/UserProfile.tsx`)
- Profile management → Auth hook: reads state (evidence: `client/src/pages/UserProfile.tsx`)
- Search → Auth hook: uses (evidence: `client/src/components/Search.tsx`)
- Search → Post hook: searches posts (evidence: `client/src/components/Search.tsx`)
- Route protection → Auth hook: checks session (evidence: `client/src/components/ProtectedRoute.tsx`)
- HTTP server → Auth routes: registers (evidence: `server/server.ts`)
- HTTP server → Post routes: registers (evidence: `server/server.ts`)
- HTTP server → User routes: registers (evidence: `server/server.ts`)
- Auth routes → Authentication: dispatches (evidence: `server/routes/authRoutes.ts`)
- Post routes → Posts and comments: dispatches (evidence: `server/routes/postRoute.ts`)
- User routes → Profiles and follows: dispatches (evidence: `server/routes/userRoutes.ts`)
- Post routes → Token verification: protects routes (evidence: `server/routes/postRoute.ts`)
- User routes → Token verification: protects routes (evidence: `server/routes/userRoutes.ts`)
- Authentication → Relational data: reads and writes (evidence: `server/contollers/authController.ts`)
- Posts and comments → Relational data: reads and writes (evidence: `server/contollers/postController.ts`)
- Profiles and follows → Relational data: reads and writes (evidence: `server/contollers/userContoller.ts`)
- Authentication → Media storage: uploads avatars (evidence: `server/contollers/authController.ts`)
- Posts and comments → Media storage: manages images (evidence: `server/contollers/postController.ts`)
- Authentication → Reset email: sends reset link (evidence: `server/contollers/authController.ts`)
- Reset email → Mail transport: uses transport (evidence: `server/utils/sendEmail.ts`)
- Auth state → HTTP server: calls API
- Post state → HTTP server: calls API
- User state → HTTP server: calls API
