# apna-college/github architecture

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

- Interactive diagram: https://gitdiagram.com/apna-college/github
- Repository: https://github.com/apna-college/github

## Overview

This MERN GitHub replica offers a web workflow for signing in, viewing a dashboard or profile, and managing repositories and issues, plus a custom version-control CLI for staging, committing, pushing, pulling, and reverting. The backend exposes HTTP routes for users, repositories, and issues; its CLI separately dispatches version-control commands. The README describes the product broadly, while sampled frontend code does not show its API calls. CLI-to-S3 behavior is documented in the command descriptions, but the storage implementation was not inspected.

Main entry points: [`frontend-main/src/Routes.jsx`](https://github.com/apna-college/github/blob/main/frontend-main/src/Routes.jsx) (Page routing), [`backend-main/index.js`](https://github.com/apna-college/github/blob/main/backend-main/index.js) (VCS command dispatcher), [`frontend-main/src/components/user/Profile.jsx`](https://github.com/apna-college/github/blob/main/frontend-main/src/components/user/Profile.jsx) (Profile), [`backend-main/routes/main.router.js`](https://github.com/apna-college/github/blob/main/backend-main/routes/main.router.js) (Main router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web client"]
  node_routes_ui["Page routing<br/>[Routes.jsx]"]
  node_auth_state["Auth state<br/>[authContext.jsx]"]
  node_login["Login<br/>[Login.jsx]"]
  node_signup["Signup<br/>[Signup.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_profile["Profile<br/>[Profile.jsx]"]
  node_heatmap["Activity heatmap<br/>[HeatMap.jsx]"]
  node_navbar["Navigation bar<br/>[Navbar.jsx]"]
end

subgraph group_api["HTTP API"]
  node_http_entry["HTTP server<br/>[index.js]"]
  node_main_router["Main router<br/>[main.router.js]"]
  node_user_routes["User routes<br/>[user.router.js]"]
  node_repo_routes["Repository routes<br/>[repo.router.js]"]
  node_issue_routes["Issue routes<br/>[issue.router.js]"]
  node_user_controller["User accounts<br/>[userController.js]"]
  node_repo_controller["Repository management<br/>[repoController.js]"]
  node_issue_controller["Issue management<br/>[issueController.js]"]
end

subgraph group_vcs["Version control"]
  node_cli["VCS command dispatcher<br/>[index.js]"]
  node_init["Initialize repository<br/>[init.js]"]
  node_add["Stage files<br/>[add.js]"]
  node_commit["Create commit<br/>[commit.js]"]
  node_push["Push commits<br/>[push.js]"]
  node_pull["Pull commits<br/>[pull.js]"]
  node_revert["Revert commit<br/>[revert.js]"]
end

subgraph group_data["Persistence"]
  node_user_model["User schema<br/>[userModel.js]"]
  node_repo_model["Repository schema<br/>[repoModel.js]"]
  node_issue_model["Issue schema<br/>[issueModel.js]"]
end

node_visitor(("User"))
node_mongodb[("MongoDB")]
node_aws[("Amazon S3")]

node_visitor -->|"opens pages"| node_routes_ui
node_routes_ui -->|"checks session"| node_auth_state
node_routes_ui -->|"routes to"| node_login
node_routes_ui -->|"routes to"| node_signup
node_routes_ui -->|"routes to"| node_dashboard
node_routes_ui -->|"routes to"| node_profile
node_login -->|"uses"| node_auth_state
node_signup -->|"uses"| node_auth_state
node_profile -->|"uses"| node_auth_state
node_profile -->|"renders"| node_heatmap
node_dashboard -->|"renders"| node_navbar
node_profile -->|"renders"| node_navbar
node_visitor -->|"submits credentials"| node_login
node_visitor -->|"registers"| node_signup
node_routes_ui -.->|"API access"| node_http_entry
node_http_entry -->|"mounts routes"| node_main_router
node_main_router -->|"mounts"| node_user_routes
node_main_router -->|"mounts"| node_repo_routes
node_main_router -->|"mounts"| node_issue_routes
node_user_routes -->|"dispatches"| node_user_controller
node_repo_routes -->|"dispatches"| node_repo_controller
node_issue_routes -->|"dispatches"| node_issue_controller
node_user_controller -->|"reads and writes"| node_mongodb
node_repo_controller -->|"queries"| node_repo_model
node_repo_controller -->|"populates owner"| node_user_model
node_repo_controller -->|"populates issues"| node_issue_model
node_issue_controller -->|"queries and saves"| node_issue_model
node_issue_controller -->|"imports"| node_repo_model
node_issue_controller -->|"imports"| node_user_model
node_cli -->|"dispatches init"| node_init
node_cli -->|"dispatches add"| node_add
node_cli -->|"dispatches commit"| node_commit
node_cli -->|"dispatches push"| node_push
node_cli -->|"dispatches pull"| node_pull
node_cli -->|"dispatches revert"| node_revert
node_push -->|"uploads commits"| node_aws
node_pull -->|"downloads commits"| node_aws

click node_routes_ui "https://github.com/apna-college/github/blob/main/frontend-main/src/Routes.jsx"
click node_auth_state "https://github.com/apna-college/github/blob/main/frontend-main/src/authContext.jsx"
click node_login "https://github.com/apna-college/github/blob/main/frontend-main/src/components/auth/Login.jsx"
click node_signup "https://github.com/apna-college/github/blob/main/frontend-main/src/components/auth/Signup.jsx"
click node_dashboard "https://github.com/apna-college/github/blob/main/frontend-main/src/components/dashboard/Dashboard.jsx"
click node_profile "https://github.com/apna-college/github/blob/main/frontend-main/src/components/user/Profile.jsx"
click node_heatmap "https://github.com/apna-college/github/blob/main/frontend-main/src/components/user/HeatMap.jsx"
click node_navbar "https://github.com/apna-college/github/blob/main/frontend-main/src/components/Navbar.jsx"
click node_http_entry "https://github.com/apna-college/github/blob/main/backend-main/index.js"
click node_main_router "https://github.com/apna-college/github/blob/main/backend-main/routes/main.router.js"
click node_user_routes "https://github.com/apna-college/github/blob/main/backend-main/routes/user.router.js"
click node_repo_routes "https://github.com/apna-college/github/blob/main/backend-main/routes/repo.router.js"
click node_issue_routes "https://github.com/apna-college/github/blob/main/backend-main/routes/issue.router.js"
click node_user_controller "https://github.com/apna-college/github/blob/main/backend-main/controllers/userController.js"
click node_repo_controller "https://github.com/apna-college/github/blob/main/backend-main/controllers/repoController.js"
click node_issue_controller "https://github.com/apna-college/github/blob/main/backend-main/controllers/issueController.js"
click node_user_model "https://github.com/apna-college/github/blob/main/backend-main/models/userModel.js"
click node_repo_model "https://github.com/apna-college/github/blob/main/backend-main/models/repoModel.js"
click node_issue_model "https://github.com/apna-college/github/blob/main/backend-main/models/issueModel.js"
click node_cli "https://github.com/apna-college/github/blob/main/backend-main/index.js"
click node_init "https://github.com/apna-college/github/blob/main/backend-main/controllers/init.js"
click node_add "https://github.com/apna-college/github/blob/main/backend-main/controllers/add.js"
click node_commit "https://github.com/apna-college/github/blob/main/backend-main/controllers/commit.js"
click node_push "https://github.com/apna-college/github/blob/main/backend-main/controllers/push.js"
click node_pull "https://github.com/apna-college/github/blob/main/backend-main/controllers/pull.js"
click node_revert "https://github.com/apna-college/github/blob/main/backend-main/controllers/revert.js"

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_routes_ui,node_auth_state,node_login,node_signup,node_dashboard,node_profile,node_heatmap,node_navbar,node_visitor toneBlue
class node_http_entry,node_main_router,node_user_routes,node_repo_routes,node_issue_routes,node_user_controller,node_repo_controller,node_issue_controller,node_mongodb,node_aws toneAmber
class node_cli,node_init,node_add,node_commit,node_push,node_pull,node_revert toneMint
class node_user_model,node_repo_model,node_issue_model toneRose
```

## Components

### Web client

- [Page routing](https://github.com/apna-college/github/blob/main/frontend-main/src/Routes.jsx): `frontend-main/src/Routes.jsx`
- [Auth state](https://github.com/apna-college/github/blob/main/frontend-main/src/authContext.jsx): `frontend-main/src/authContext.jsx`
- [Login](https://github.com/apna-college/github/blob/main/frontend-main/src/components/auth/Login.jsx): `frontend-main/src/components/auth/Login.jsx`
- [Signup](https://github.com/apna-college/github/blob/main/frontend-main/src/components/auth/Signup.jsx): `frontend-main/src/components/auth/Signup.jsx`
- [Dashboard](https://github.com/apna-college/github/blob/main/frontend-main/src/components/dashboard/Dashboard.jsx): `frontend-main/src/components/dashboard/Dashboard.jsx`
- [Profile](https://github.com/apna-college/github/blob/main/frontend-main/src/components/user/Profile.jsx): `frontend-main/src/components/user/Profile.jsx`
- [Activity heatmap](https://github.com/apna-college/github/blob/main/frontend-main/src/components/user/HeatMap.jsx): `frontend-main/src/components/user/HeatMap.jsx`
- [Navigation bar](https://github.com/apna-college/github/blob/main/frontend-main/src/components/Navbar.jsx): `frontend-main/src/components/Navbar.jsx`

### HTTP API

- [HTTP server](https://github.com/apna-college/github/blob/main/backend-main/index.js): `backend-main/index.js`
- [Main router](https://github.com/apna-college/github/blob/main/backend-main/routes/main.router.js): `backend-main/routes/main.router.js`
- [User routes](https://github.com/apna-college/github/blob/main/backend-main/routes/user.router.js): `backend-main/routes/user.router.js`
- [Repository routes](https://github.com/apna-college/github/blob/main/backend-main/routes/repo.router.js): `backend-main/routes/repo.router.js`
- [Issue routes](https://github.com/apna-college/github/blob/main/backend-main/routes/issue.router.js): `backend-main/routes/issue.router.js`
- [User accounts](https://github.com/apna-college/github/blob/main/backend-main/controllers/userController.js): `backend-main/controllers/userController.js`
- [Repository management](https://github.com/apna-college/github/blob/main/backend-main/controllers/repoController.js): `backend-main/controllers/repoController.js`
- [Issue management](https://github.com/apna-college/github/blob/main/backend-main/controllers/issueController.js): `backend-main/controllers/issueController.js`

### Version control

- [VCS command dispatcher](https://github.com/apna-college/github/blob/main/backend-main/index.js): `backend-main/index.js`
- [Initialize repository](https://github.com/apna-college/github/blob/main/backend-main/controllers/init.js): `backend-main/controllers/init.js`
- [Stage files](https://github.com/apna-college/github/blob/main/backend-main/controllers/add.js): `backend-main/controllers/add.js`
- [Create commit](https://github.com/apna-college/github/blob/main/backend-main/controllers/commit.js): `backend-main/controllers/commit.js`
- [Push commits](https://github.com/apna-college/github/blob/main/backend-main/controllers/push.js): `backend-main/controllers/push.js`
- [Pull commits](https://github.com/apna-college/github/blob/main/backend-main/controllers/pull.js): `backend-main/controllers/pull.js`
- [Revert commit](https://github.com/apna-college/github/blob/main/backend-main/controllers/revert.js): `backend-main/controllers/revert.js`

### Persistence

- [User schema](https://github.com/apna-college/github/blob/main/backend-main/models/userModel.js): `backend-main/models/userModel.js`
- [Repository schema](https://github.com/apna-college/github/blob/main/backend-main/models/repoModel.js): `backend-main/models/repoModel.js`
- [Issue schema](https://github.com/apna-college/github/blob/main/backend-main/models/issueModel.js): `backend-main/models/issueModel.js`

### Other components

- **User**
- **MongoDB**
- **Amazon S3**

## Connections

- User → Page routing: opens pages (evidence: `frontend-main/src/Routes.jsx`)
- Page routing → Auth state: checks session (evidence: `frontend-main/src/Routes.jsx`)
- Page routing → Login: routes to (evidence: `frontend-main/src/Routes.jsx`)
- Page routing → Signup: routes to (evidence: `frontend-main/src/Routes.jsx`)
- Page routing → Dashboard: routes to (evidence: `frontend-main/src/Routes.jsx`)
- Page routing → Profile: routes to (evidence: `frontend-main/src/Routes.jsx`)
- Login → Auth state: uses (evidence: `frontend-main/src/components/auth/Login.jsx`)
- Signup → Auth state: uses (evidence: `frontend-main/src/components/auth/Signup.jsx`)
- Profile → Auth state: uses (evidence: `frontend-main/src/components/user/Profile.jsx`)
- Profile → Activity heatmap: renders (evidence: `frontend-main/src/components/user/Profile.jsx`)
- Dashboard → Navigation bar: renders (evidence: `frontend-main/src/components/dashboard/Dashboard.jsx`)
- Profile → Navigation bar: renders (evidence: `frontend-main/src/components/user/Profile.jsx`)
- User → Login: submits credentials (evidence: `frontend-main/src/components/auth/Login.jsx`)
- User → Signup: registers (evidence: `frontend-main/src/components/auth/Signup.jsx`)
- Page routing → HTTP server: API access
- HTTP server → Main router: mounts routes (evidence: `backend-main/index.js`)
- Main router → User routes: mounts (evidence: `backend-main/routes/main.router.js`)
- Main router → Repository routes: mounts (evidence: `backend-main/routes/main.router.js`)
- Main router → Issue routes: mounts (evidence: `backend-main/routes/main.router.js`)
- User routes → User accounts: dispatches (evidence: `backend-main/routes/user.router.js`)
- Repository routes → Repository management: dispatches (evidence: `backend-main/routes/repo.router.js`)
- Issue routes → Issue management: dispatches (evidence: `backend-main/routes/issue.router.js`)
- User accounts → MongoDB: reads and writes (evidence: `backend-main/controllers/userController.js`)
- Repository management → Repository schema: queries (evidence: `backend-main/controllers/repoController.js`)
- Repository management → User schema: populates owner (evidence: `backend-main/controllers/repoController.js`)
- Repository management → Issue schema: populates issues (evidence: `backend-main/controllers/repoController.js`)
- Issue management → Issue schema: queries and saves (evidence: `backend-main/controllers/issueController.js`)
- Issue management → Repository schema: imports (evidence: `backend-main/controllers/issueController.js`)
- Issue management → User schema: imports (evidence: `backend-main/controllers/issueController.js`)
- VCS command dispatcher → Initialize repository: dispatches init (evidence: `backend-main/index.js`)
- VCS command dispatcher → Stage files: dispatches add (evidence: `backend-main/index.js`)
- VCS command dispatcher → Create commit: dispatches commit (evidence: `backend-main/index.js`)
- VCS command dispatcher → Push commits: dispatches push (evidence: `backend-main/index.js`)
- VCS command dispatcher → Pull commits: dispatches pull (evidence: `backend-main/index.js`)
- VCS command dispatcher → Revert commit: dispatches revert (evidence: `backend-main/index.js`)
- Push commits → Amazon S3: uploads commits
- Pull commits → Amazon S3: downloads commits
