# kumarsai12383/devsnippet architecture

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

- Interactive diagram: https://gitdiagram.com/kumarsai12383/devsnippet
- Repository: https://github.com/kumarsai12383/devsnippet

## Overview

DevSnippet is a personal code-snippet vault. The main workflow is account registration or sign-in, then a user manages and searches their snippets in the dashboard; optional AI metadata generation turns pasted code into suggested snippet fields. The graph preserves the documented UI capabilities and the sampled API, authentication, persistence, and AI boundaries. Some frontend wiring is documented only at the feature/API level, so those edges cite the README rather than implying unsampled calls were inspected.

Main entry points: [`frontend/src/pages/Dashboard.jsx`](https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/pages/Dashboard.jsx) (Snippet Dashboard), [`backend/server.js`](https://github.com/kumarsai12383/devsnippet/blob/main/backend/server.js) (Express API), [`frontend/src/App.jsx`](https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/App.jsx) (React App), [`backend/routes/auth.js`](https://github.com/kumarsai12383/devsnippet/blob/main/backend/routes/auth.js) (Authentication Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Workspace UI"]
  node_app["React App<br/>[App.jsx]"]
  node_dashboard["Snippet Dashboard<br/>[Dashboard.jsx]"]
  node_authpages["Login and Register"]
  node_authcontext["Auth State<br/>[AuthContext.jsx]"]
  node_navbar["Navigation Bar<br/>[Navbar.jsx]"]
  node_sidebar["Sidebar Navigation<br/>[Sidebar.jsx]"]
  node_snippetcard["Snippet Card<br/>[SnippetCard.jsx]"]
  node_snippetmodal["Snippet Editor<br/>[SnippetModal.jsx]"]
  node_welcome["Welcome Dialog<br/>[WelcomeModal.jsx]"]
  node_httpclient["API Client<br/>[axios.js]"]
end

subgraph group_api["API Services"]
  node_server["Express API<br/>[server.js]"]
  node_authroutes["Authentication Routes<br/>[auth.js]"]
  node_snippetroutes["Snippet Routes<br/>[snippets.js]"]
end

subgraph group_identity["Identity and Data"]
  node_authmiddleware["JWT Guard<br/>[auth.js]"]
  node_users[("User Records<br/>[User.js]")]
  node_snippets[("Snippet Records<br/>[Snippet.js]")]
  node_seeder["Starter Snippets<br/>[seedSnippets.js]"]
  node_dbconnector["Mongo Connector<br/>[db.js]"]
end

subgraph group_ai["AI Integration"]
  node_airoute["Metadata Generation<br/>[ai.js]"]
end

node_developer(("Developer"))
node_mongodb[("MongoDB")]
node_foundry["Microsoft Foundry"]

node_developer -->|"uses"| node_app
node_app -->|"shows"| node_dashboard
node_app -->|"routes"| node_authpages
node_dashboard -->|"provides navigation"| node_navbar
node_dashboard -->|"provides navigation"| node_sidebar
node_dashboard -->|"displays snippets"| node_snippetcard
node_dashboard -->|"edits snippets"| node_snippetmodal
node_dashboard -->|"shows first-use dialog"| node_welcome
node_snippetmodal -->|"requests"| node_httpclient
node_authpages -->|"updates session"| node_authcontext
node_app -->|"uses provider"| node_authcontext
node_httpclient -->|"sends API requests"| node_server
node_server -->|"connects before listening"| node_dbconnector
node_server -->|"mounts routes"| node_authroutes
node_server -->|"mounts routes"| node_snippetroutes
node_server -->|"mounts routes"| node_airoute
node_authroutes -->|"creates and checks"| node_users
node_authroutes -->|"seeds on registration"| node_seeder
node_seeder -->|"inserts starter records"| node_snippets
node_snippetroutes -->|"guards routes"| node_authmiddleware
node_snippetroutes -->|"queries and updates"| node_snippets
node_authroutes -->|"guards profile route"| node_authmiddleware
node_authmiddleware -->|"loads account"| node_users
node_airoute -->|"guards generation"| node_authmiddleware
node_airoute -->|"checks and debits credits"| node_users
node_airoute -->|"requests completions"| node_foundry
node_dbconnector -->|"connects"| node_mongodb

click node_app "https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/App.jsx"
click node_dashboard "https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/pages/Dashboard.jsx"
click node_authpages "https://github.com/kumarsai12383/devsnippet/tree/main/frontend/src/pages"
click node_authcontext "https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/context/AuthContext.jsx"
click node_navbar "https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/components/Navbar.jsx"
click node_sidebar "https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/components/Sidebar.jsx"
click node_snippetcard "https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/components/SnippetCard.jsx"
click node_snippetmodal "https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/components/SnippetModal.jsx"
click node_welcome "https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/components/WelcomeModal.jsx"
click node_httpclient "https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/api/axios.js"
click node_server "https://github.com/kumarsai12383/devsnippet/blob/main/backend/server.js"
click node_authroutes "https://github.com/kumarsai12383/devsnippet/blob/main/backend/routes/auth.js"
click node_snippetroutes "https://github.com/kumarsai12383/devsnippet/blob/main/backend/routes/snippets.js"
click node_airoute "https://github.com/kumarsai12383/devsnippet/blob/main/backend/routes/ai.js"
click node_authmiddleware "https://github.com/kumarsai12383/devsnippet/blob/main/backend/middleware/auth.js"
click node_users "https://github.com/kumarsai12383/devsnippet/blob/main/backend/models/User.js"
click node_snippets "https://github.com/kumarsai12383/devsnippet/blob/main/backend/models/Snippet.js"
click node_seeder "https://github.com/kumarsai12383/devsnippet/blob/main/backend/utils/seedSnippets.js"
click node_dbconnector "https://github.com/kumarsai12383/devsnippet/blob/main/backend/config/db.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_app,node_dashboard,node_authpages,node_authcontext,node_navbar,node_sidebar,node_snippetcard,node_snippetmodal,node_welcome,node_httpclient toneBlue
class node_server,node_authroutes,node_snippetroutes,node_mongodb toneAmber
class node_authmiddleware,node_users,node_snippets,node_seeder,node_dbconnector toneMint
class node_airoute toneRose
class node_developer,node_foundry toneIndigo
```

## Components

### Workspace UI

- [React App](https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Snippet Dashboard](https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Login and Register](https://github.com/kumarsai12383/devsnippet/tree/main/frontend/src/pages): `frontend/src/pages`
- [Auth State](https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Navigation Bar](https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Sidebar Navigation](https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [Snippet Card](https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/components/SnippetCard.jsx): `frontend/src/components/SnippetCard.jsx`
- [Snippet Editor](https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/components/SnippetModal.jsx): `frontend/src/components/SnippetModal.jsx`
- [Welcome Dialog](https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/components/WelcomeModal.jsx): `frontend/src/components/WelcomeModal.jsx`
- [API Client](https://github.com/kumarsai12383/devsnippet/blob/main/frontend/src/api/axios.js): `frontend/src/api/axios.js`

### API Services

- [Express API](https://github.com/kumarsai12383/devsnippet/blob/main/backend/server.js): `backend/server.js`
- [Authentication Routes](https://github.com/kumarsai12383/devsnippet/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Snippet Routes](https://github.com/kumarsai12383/devsnippet/blob/main/backend/routes/snippets.js): `backend/routes/snippets.js`

### Identity and Data

- [JWT Guard](https://github.com/kumarsai12383/devsnippet/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [User Records](https://github.com/kumarsai12383/devsnippet/blob/main/backend/models/User.js): `backend/models/User.js`
- [Snippet Records](https://github.com/kumarsai12383/devsnippet/blob/main/backend/models/Snippet.js): `backend/models/Snippet.js`
- [Starter Snippets](https://github.com/kumarsai12383/devsnippet/blob/main/backend/utils/seedSnippets.js): `backend/utils/seedSnippets.js`
- [Mongo Connector](https://github.com/kumarsai12383/devsnippet/blob/main/backend/config/db.js): `backend/config/db.js`

### AI Integration

- [Metadata Generation](https://github.com/kumarsai12383/devsnippet/blob/main/backend/routes/ai.js): `backend/routes/ai.js`

### Other components

- **Developer**
- **MongoDB**
- **Microsoft Foundry**

## Connections

- Developer → React App: uses (evidence: `README.md`)
- React App → Snippet Dashboard: shows (evidence: `README.md`)
- React App → Login and Register: routes (evidence: `README.md`)
- Snippet Dashboard → Navigation Bar: provides navigation (evidence: `README.md`)
- Snippet Dashboard → Sidebar Navigation: provides navigation (evidence: `README.md`)
- Snippet Dashboard → Snippet Card: displays snippets (evidence: `README.md`)
- Snippet Dashboard → Snippet Editor: edits snippets (evidence: `README.md`)
- Snippet Dashboard → Welcome Dialog: shows first-use dialog (evidence: `README.md`)
- Snippet Editor → API Client: requests (evidence: `frontend/src/components/SnippetModal.jsx`)
- Login and Register → Auth State: updates session (evidence: `frontend/src/pages/Register.jsx`)
- React App → Auth State: uses provider (evidence: `frontend/src/main.jsx`)
- API Client → Express API: sends API requests (evidence: `README.md`)
- Express API → Mongo Connector: connects before listening (evidence: `backend/server.js`)
- Express API → Authentication Routes: mounts routes (evidence: `backend/server.js`)
- Express API → Snippet Routes: mounts routes (evidence: `backend/server.js`)
- Express API → Metadata Generation: mounts routes (evidence: `backend/server.js`)
- Authentication Routes → User Records: creates and checks (evidence: `backend/routes/auth.js`)
- Authentication Routes → Starter Snippets: seeds on registration (evidence: `backend/routes/auth.js`)
- Starter Snippets → Snippet Records: inserts starter records (evidence: `backend/utils/seedSnippets.js`)
- Snippet Routes → JWT Guard: guards routes (evidence: `backend/routes/snippets.js`)
- Snippet Routes → Snippet Records: queries and updates (evidence: `backend/routes/snippets.js`)
- Authentication Routes → JWT Guard: guards profile route (evidence: `backend/routes/auth.js`)
- JWT Guard → User Records: loads account (evidence: `backend/middleware/auth.js`)
- Metadata Generation → JWT Guard: guards generation (evidence: `backend/routes/ai.js`)
- Metadata Generation → User Records: checks and debits credits (evidence: `backend/routes/ai.js`)
- Metadata Generation → Microsoft Foundry: requests completions (evidence: `backend/routes/ai.js`)
- Mongo Connector → MongoDB: connects (evidence: `backend/config/db.js`)
