# sirigirineetha4/ai-powered-smart-code-translator architecture

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

- Interactive diagram: https://gitdiagram.com/sirigirineetha4/ai-powered-smart-code-translator
- Repository: https://github.com/sirigirineetha4/ai-powered-smart-code-translator

## Overview

This is a full-stack AI code workspace: users authenticate, edit code, choose an operation, receive Gemini-backed results, and can revisit saved operations. The React workspace calls API services; Express routes and controllers dispatch authentication, code operations, and history work. Account and operation records persist through MongoDB models. The README documents the main translate, analyze, explain, and optimize capabilities; controller evidence also shows debug and unit-test generation. Some route wiring and unsampled services are represented only where the README or SOURCE INDEX supports the relationship.

Main entry points: [`server/src/controllers/code.controller.js`](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/controllers/code.controller.js) (Code controller), [`client/src/pages/HomePage.jsx`](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/pages/HomePage.jsx) (Code workspace), [`server/src/routes/index.js`](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/routes/index.js) (API routes), [`server/src/services/history.service.js`](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/history.service.js) (History service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_workspace["Code workspace<br/>[HomePage.jsx]"]
  node_editor["Monaco editor<br/>[CodeEditor.jsx]"]
  node_languages["Language options<br/>[languages.js]"]
  node_results["Result display<br/>[OutputPanel.jsx]"]
  node_authui["Login and session<br/>[LoginPage.jsx]"]
  node_authcontext["Auth context<br/>[AuthContext.jsx]"]
  node_historyui["History screen<br/>[HistoryPage.jsx]"]
  node_codesvc["Code API client<br/>[codeService.js]"]
  node_authsvcui["Auth API client<br/>[authService.js]"]
  node_historysvcui["History API client<br/>[historyService.js]"]
  node_apihttp["HTTP client<br/>[api.js]"]
end

subgraph group_api["API and identity"]
  node_server["Express app<br/>[app.js]"]
  node_routes["API routes<br/>[index.js]"]
  node_authroutes["Auth routes<br/>[auth.routes.js]"]
  node_coderoutes["Code routes<br/>[code.routes.js]"]
  node_historyroutes["History routes<br/>[history.routes.js]"]
  node_authcontroller["Auth controller<br/>[auth.controller.js]"]
  node_codecontroller["Code controller<br/>[code.controller.js]"]
  node_authservice["Auth service<br/>[auth.service.js]"]
  node_authmiddleware["JWT authentication<br/>[auth.middleware.js]"]
  node_historycontroller["History controller"]
end

subgraph group_ai["AI operations"]
  node_translate["Translation"]
  node_analysis["Complexity analysis"]
  node_optimization["Optimization"]
  node_explanation["Code explanation"]
  node_debug["Bug finding<br/>[debug.service.js]"]
  node_testgen["Test generation<br/>[testGen.service.js]"]
  node_gemini["Gemini integration<br/>[gemini.service.js]"]
  node_prompts["Prompt definitions<br/>[prompts.js]"]
end

subgraph group_persistence["MongoDB persistence"]
  node_users[("User records<br/>[User.model.js]")]
  node_historyservice["History service<br/>[history.service.js]"]
  node_historymodel[("Operation records<br/>[History.model.js]")]
end

node_user(("User"))
node_google{{"Google OAuth"}}

node_user -->|"uses"| node_workspace
node_workspace -->|"renders"| node_editor
node_workspace -->|"renders"| node_results
node_editor -->|"uses map"| node_languages
node_workspace -->|"requests operation"| node_codesvc
node_codesvc -->|"sends requests"| node_apihttp
node_user -->|"signs in"| node_authui
node_authui -->|"sets session"| node_authcontext
node_authcontext -->|"checks profile"| node_authsvcui
node_authsvcui -->|"sends requests"| node_apihttp
node_user -->|"views history"| node_historyui
node_historyui -->|"loads entries"| node_historysvcui
node_historysvcui -->|"sends requests"| node_apihttp
node_apihttp -.->|"calls API"| node_server
node_server -->|"mounts routes"| node_routes
node_routes -.->|"registers"| node_authroutes
node_routes -.->|"registers"| node_coderoutes
node_routes -.->|"registers"| node_historyroutes
node_authroutes -->|"routes requests"| node_authcontroller
node_authroutes -->|"protects profile"| node_authmiddleware
node_coderoutes -->|"routes requests"| node_codecontroller
node_coderoutes -->|"protects operations"| node_authmiddleware
node_historyroutes -->|"routes requests"| node_historycontroller
node_historyroutes -->|"protects history"| node_authmiddleware
node_authcontroller -->|"delegates auth"| node_authservice
node_authservice -->|"reads and writes"| node_users
node_authservice -->|"verifies credential"| node_google
node_authmiddleware -->|"loads user"| node_users
node_codecontroller -->|"dispatches translation"| node_translate
node_codecontroller -->|"dispatches analysis"| node_analysis
node_codecontroller -->|"dispatches optimization"| node_optimization
node_codecontroller -->|"dispatches explanation"| node_explanation
node_codecontroller -->|"dispatches debugging"| node_debug
node_codecontroller -->|"dispatches tests"| node_testgen
node_codecontroller -->|"records result"| node_historyservice
node_translate -->|"uses model"| node_gemini
node_optimization -->|"uses model"| node_gemini
node_explanation -->|"uses model"| node_gemini
node_translate -->|"uses prompts"| node_prompts
node_optimization -->|"uses prompts"| node_prompts
node_explanation -->|"uses prompts"| node_prompts
node_historycontroller -->|"delegates history"| node_historyservice
node_historyservice -->|"reads and writes"| node_historymodel
node_historyservice -->|"stores entries"| node_historymodel

click node_workspace "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/pages/HomePage.jsx"
click node_editor "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/components/CodeEditor.jsx"
click node_languages "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/constants/languages.js"
click node_results "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/components/OutputPanel.jsx"
click node_authui "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/pages/LoginPage.jsx"
click node_authcontext "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/context/AuthContext.jsx"
click node_historyui "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/pages/HistoryPage.jsx"
click node_codesvc "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/services/codeService.js"
click node_authsvcui "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/services/authService.js"
click node_historysvcui "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/services/historyService.js"
click node_apihttp "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/services/api.js"
click node_server "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/app.js"
click node_routes "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/routes/index.js"
click node_authroutes "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/routes/auth.routes.js"
click node_coderoutes "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/routes/code.routes.js"
click node_historyroutes "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/routes/history.routes.js"
click node_authcontroller "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/controllers/auth.controller.js"
click node_codecontroller "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/controllers/code.controller.js"
click node_authservice "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/auth.service.js"
click node_authmiddleware "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/middleware/auth.middleware.js"
click node_translate "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/translation.service.js"
click node_analysis "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/complexity.service.js"
click node_optimization "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/optimization.service.js"
click node_explanation "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/explanation.service.js"
click node_debug "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/debug.service.js"
click node_testgen "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/testGen.service.js"
click node_gemini "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/gemini.service.js"
click node_prompts "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/constants/prompts.js"
click node_users "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/models/User.model.js"
click node_historycontroller "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/controllers/history.controller.js"
click node_historyservice "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/history.service.js"
click node_historymodel "https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/models/History.model.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_workspace,node_editor,node_languages,node_results,node_authui,node_authcontext,node_historyui,node_codesvc,node_authsvcui,node_historysvcui,node_apihttp,node_user toneBlue
class node_server,node_routes,node_authroutes,node_coderoutes,node_historyroutes,node_authcontroller,node_codecontroller,node_authservice,node_authmiddleware,node_historycontroller toneAmber
class node_translate,node_analysis,node_optimization,node_explanation,node_debug,node_testgen,node_gemini,node_prompts toneMint
class node_users,node_historyservice,node_historymodel toneRose
class node_google toneIndigo
```

## Components

### React client

- [Code workspace](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/pages/HomePage.jsx): `client/src/pages/HomePage.jsx`
- [Monaco editor](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/components/CodeEditor.jsx): `client/src/components/CodeEditor.jsx`
- [Language options](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/constants/languages.js): `client/src/constants/languages.js`
- [Result display](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/components/OutputPanel.jsx): `client/src/components/OutputPanel.jsx`
- [Login and session](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/pages/LoginPage.jsx): `client/src/pages/LoginPage.jsx`
- [Auth context](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [History screen](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/pages/HistoryPage.jsx): `client/src/pages/HistoryPage.jsx`
- [Code API client](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/services/codeService.js): `client/src/services/codeService.js`
- [Auth API client](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/services/authService.js): `client/src/services/authService.js`
- [History API client](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/services/historyService.js): `client/src/services/historyService.js`
- [HTTP client](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/client/src/services/api.js): `client/src/services/api.js`

### API and identity

- [Express app](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/app.js): `server/src/app.js`
- [API routes](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/routes/index.js): `server/src/routes/index.js`
- [Auth routes](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/routes/auth.routes.js): `server/src/routes/auth.routes.js`
- [Code routes](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/routes/code.routes.js): `server/src/routes/code.routes.js`
- [History routes](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/routes/history.routes.js): `server/src/routes/history.routes.js`
- [Auth controller](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/controllers/auth.controller.js): `server/src/controllers/auth.controller.js`
- [Code controller](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/controllers/code.controller.js): `server/src/controllers/code.controller.js`
- [Auth service](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/auth.service.js): `server/src/services/auth.service.js`
- [JWT authentication](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/middleware/auth.middleware.js): `server/src/middleware/auth.middleware.js`
- [History controller](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/controllers/history.controller.js): `server/src/controllers/history.controller.js`

### AI operations

- [Translation](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/translation.service.js): `server/src/services/translation.service.js`
- [Complexity analysis](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/complexity.service.js): `server/src/services/complexity.service.js`
- [Optimization](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/optimization.service.js): `server/src/services/optimization.service.js`
- [Code explanation](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/explanation.service.js): `server/src/services/explanation.service.js`
- [Bug finding](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/debug.service.js): `server/src/services/debug.service.js`
- [Test generation](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/testGen.service.js): `server/src/services/testGen.service.js`
- [Gemini integration](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/gemini.service.js): `server/src/services/gemini.service.js`
- [Prompt definitions](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/constants/prompts.js): `server/src/constants/prompts.js`

### MongoDB persistence

- [User records](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/models/User.model.js): `server/src/models/User.model.js`
- [History service](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/services/history.service.js): `server/src/services/history.service.js`
- [Operation records](https://github.com/sirigirineetha4/ai-powered-smart-code-translator/blob/main/server/src/models/History.model.js): `server/src/models/History.model.js`

### Other components

- **User**
- **Google OAuth**

## Connections

- User → Code workspace: uses
- Code workspace → Monaco editor: renders (evidence: `client/src/pages/HomePage.jsx`)
- Code workspace → Result display: renders (evidence: `client/src/pages/HomePage.jsx`)
- Monaco editor → Language options: uses map (evidence: `client/src/components/CodeEditor.jsx`)
- Code workspace → Code API client: requests operation (evidence: `client/src/pages/HomePage.jsx`)
- Code API client → HTTP client: sends requests (evidence: `client/src/services/codeService.js`)
- User → Login and session: signs in
- Login and session → Auth context: sets session (evidence: `client/src/pages/LoginPage.jsx`)
- Auth context → Auth API client: checks profile (evidence: `client/src/context/AuthContext.jsx`)
- Auth API client → HTTP client: sends requests (evidence: `client/src/services/authService.js`)
- User → History screen: views history
- History screen → History API client: loads entries (evidence: `client/src/pages/HistoryPage.jsx`)
- History API client → HTTP client: sends requests (evidence: `client/src/services/historyService.js`)
- HTTP client → Express app: calls API
- Express app → API routes: mounts routes (evidence: `server/src/app.js`)
- API routes → Auth routes: registers
- API routes → Code routes: registers
- API routes → History routes: registers
- Auth routes → Auth controller: routes requests (evidence: `server/src/routes/auth.routes.js`)
- Auth routes → JWT authentication: protects profile (evidence: `server/src/routes/auth.routes.js`)
- Code routes → Code controller: routes requests (evidence: `server/src/routes/code.routes.js`)
- Code routes → JWT authentication: protects operations (evidence: `server/src/routes/code.routes.js`)
- History routes → History controller: routes requests (evidence: `server/src/routes/history.routes.js`)
- History routes → JWT authentication: protects history (evidence: `server/src/routes/history.routes.js`)
- Auth controller → Auth service: delegates auth (evidence: `server/src/controllers/auth.controller.js`)
- Auth service → User records: reads and writes (evidence: `server/src/services/auth.service.js`)
- Auth service → Google OAuth: verifies credential (evidence: `server/src/services/auth.service.js`)
- JWT authentication → User records: loads user (evidence: `server/src/middleware/auth.middleware.js`)
- Code controller → Translation: dispatches translation (evidence: `server/src/controllers/code.controller.js`)
- Code controller → Complexity analysis: dispatches analysis (evidence: `server/src/controllers/code.controller.js`)
- Code controller → Optimization: dispatches optimization (evidence: `server/src/controllers/code.controller.js`)
- Code controller → Code explanation: dispatches explanation (evidence: `server/src/controllers/code.controller.js`)
- Code controller → Bug finding: dispatches debugging (evidence: `server/src/controllers/code.controller.js`)
- Code controller → Test generation: dispatches tests (evidence: `server/src/controllers/code.controller.js`)
- Code controller → History service: records result (evidence: `server/src/controllers/code.controller.js`)
- Translation → Gemini integration: uses model (evidence: `server/src/services/translation.service.js`)
- Optimization → Gemini integration: uses model (evidence: `server/src/services/optimization.service.js`)
- Code explanation → Gemini integration: uses model (evidence: `server/src/services/explanation.service.js`)
- Translation → Prompt definitions: uses prompts (evidence: `server/src/services/translation.service.js`)
- Optimization → Prompt definitions: uses prompts (evidence: `server/src/services/optimization.service.js`)
- Code explanation → Prompt definitions: uses prompts (evidence: `server/src/services/explanation.service.js`)
- History controller → History service: delegates history (evidence: `server/src/controllers/history.controller.js`)
- History service → Operation records: reads and writes (evidence: `server/src/services/history.service.js`)
- History service → Operation records: stores entries (evidence: `server/src/services/history.service.js`)
