# sumit1880/codeshield-ai architecture

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

- Interactive diagram: https://gitdiagram.com/sumit1880/codeshield-ai
- Repository: https://github.com/sumit1880/codeshield-ai

## Overview

CodeShield is a web application for analyzing pasted source code or uploaded ZIP projects and presenting security findings. The user signs in, submits a scan, and reviews results or prior scans. The backend exposes an analysis API and coordinates static analysis, specialist agents, evidence gathering, and finding verification; its manager can request code or security-knowledge searches before finishing. A separate knowledge-ingestion path builds the retrieval corpus. The README is empty, and several central backend modules were not excerpted, so some workflow links are shown as unverified rather than asserted as source-confirmed.

Main entry points: [`backend/src/orchestrator/analysis.orchestrator.ts`](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/orchestrator/analysis.orchestrator.ts) (Analysis coordinator), [`frontend/src/App.tsx`](https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/App.tsx) (Application shell), [`frontend/src/components/Workspace.tsx`](https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/components/Workspace.tsx) (Scan workspace), [`backend/src/services/rag/rag.service.ts`](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/rag/rag.service.ts) (Knowledge retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_app["Application shell<br/>[App.tsx]"]
  node_auth["Session authentication<br/>[AuthContext.tsx]"]
  node_workspace["Scan workspace<br/>[Workspace.tsx]"]
  node_results["Findings and history<br/>[ResultsView.tsx]"]
  node_client_api["API client<br/>[api.ts]"]
  node_analyze_hook["Analysis request state<br/>[useAnalyze.ts]"]
end

subgraph group_api["API and intake"]
  node_server_app["HTTP application<br/>[app.ts]"]
  node_analyze_route["Analysis endpoint<br/>[analyze.route.ts]"]
  node_zip["ZIP extraction<br/>[zip.service.ts]"]
end

subgraph group_analysis["Security analysis"]
  node_orchestrator["Analysis coordinator"]
  node_tools["Safe tool registry<br/>[tool-registry.ts]"]
  node_semgrep["Static analysis<br/>[semgrep.service.ts]"]
  node_code_context["Code context search"]
  node_code_search["Project text search"]
  node_agents["Specialist agents"]
  node_manager["Manager planner<br/>[manager.agent.ts]"]
end

subgraph group_knowledge["Knowledge and providers"]
  node_rag["Knowledge retrieval<br/>[rag.service.ts]"]
  node_ingest["Knowledge ingestion<br/>[ingest.service.ts]"]
  node_embeddings["Embedding service"]
  node_llm["LLM service<br/>[llm.service.ts]"]
  node_llm_router["Provider fallback<br/>[llm-router.ts]"]
  node_embedding_provider["Gemini embeddings"]
end

subgraph group_runtime["Runtime data"]
  node_db[("Knowledge database<br/>[prisma.ts]")]
  node_llm_provider["LLM providers"]
end

node_user(("Analyst"))

node_user -->|"uses"| node_app
node_app -->|"provides session"| node_auth
node_app -->|"renders"| node_workspace
node_workspace -->|"submits scans"| node_analyze_hook
node_workspace -->|"shows findings"| node_results
node_analyze_hook -.->|"sends requests"| node_client_api
node_client_api -.->|"calls API"| node_analyze_route
node_server_app -->|"mounts"| node_analyze_route
node_analyze_route -.->|"starts analysis"| node_orchestrator
node_orchestrator -.->|"dispatches actions"| node_tools
node_orchestrator -.->|"runs scans"| node_semgrep
node_orchestrator -.->|"requests reasoning"| node_agents
node_orchestrator -.->|"requests retrieval"| node_rag
node_orchestrator -.->|"gets context"| node_code_context
node_orchestrator -.->|"searches code"| node_code_search
node_orchestrator -.->|"prepares uploads"| node_zip
node_manager -->|"requests decision"| node_llm
node_manager -.->|"delegates dispatch"| node_tools
node_rag -->|"embeds query"| node_embeddings
node_rag -->|"queries vectors"| node_db
node_ingest -->|"embeds chunks"| node_embeddings
node_ingest -->|"stores chunks"| node_db
node_embedding_provider -->|"implements"| node_embeddings
node_llm_router -->|"tries providers"| node_llm_provider
node_llm_router -->|"implements"| node_llm

click node_app "https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/App.tsx"
click node_auth "https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/context/AuthContext.tsx"
click node_workspace "https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/components/Workspace.tsx"
click node_results "https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/components/ResultsView.tsx"
click node_client_api "https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/lib/api.ts"
click node_analyze_hook "https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/hooks/useAnalyze.ts"
click node_server_app "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/app.ts"
click node_analyze_route "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/routes/analyze.route.ts"
click node_zip "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/zip/zip.service.ts"
click node_orchestrator "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/orchestrator/analysis.orchestrator.ts"
click node_tools "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/orchestrator/tool-registry.ts"
click node_semgrep "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/semgrep/semgrep.service.ts"
click node_code_context "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/code-context/code-context.service.ts"
click node_code_search "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/code-context/code-search.service.ts"
click node_agents "https://github.com/sumit1880/codeshield-ai/tree/main/backend/src/agents"
click node_manager "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/agents/manager.agent.ts"
click node_rag "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/rag/rag.service.ts"
click node_ingest "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/rag/ingest.service.ts"
click node_embeddings "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/embeddings/embedding.service.ts"
click node_llm "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/llm/llm.service.ts"
click node_llm_router "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/llm/llm-router.ts"
click node_embedding_provider "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/embeddings/gemini-embedding.service.ts"
click node_db "https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/config/prisma.ts"
click node_llm_provider "https://github.com/sumit1880/codeshield-ai/tree/main/backend/src/services/llm/providers"

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_auth,node_workspace,node_results,node_client_api,node_analyze_hook toneBlue
class node_server_app,node_analyze_route,node_zip toneAmber
class node_orchestrator,node_tools,node_semgrep,node_code_context,node_code_search,node_agents,node_manager toneMint
class node_rag,node_ingest,node_embeddings,node_llm,node_llm_router,node_embedding_provider toneRose
class node_db,node_llm_provider,node_user toneIndigo
```

## Components

### Web interface

- [Application shell](https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Session authentication](https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [Scan workspace](https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/components/Workspace.tsx): `frontend/src/components/Workspace.tsx`
- [Findings and history](https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/components/ResultsView.tsx): `frontend/src/components/ResultsView.tsx`
- [API client](https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Analysis request state](https://github.com/sumit1880/codeshield-ai/blob/main/frontend/src/hooks/useAnalyze.ts): `frontend/src/hooks/useAnalyze.ts`

### API and intake

- [HTTP application](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [Analysis endpoint](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/routes/analyze.route.ts): `backend/src/routes/analyze.route.ts`
- [ZIP extraction](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/zip/zip.service.ts): `backend/src/services/zip/zip.service.ts`

### Security analysis

- [Analysis coordinator](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/orchestrator/analysis.orchestrator.ts): `backend/src/orchestrator/analysis.orchestrator.ts`
- [Safe tool registry](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/orchestrator/tool-registry.ts): `backend/src/orchestrator/tool-registry.ts`
- [Static analysis](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/semgrep/semgrep.service.ts): `backend/src/services/semgrep/semgrep.service.ts`
- [Code context search](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/code-context/code-context.service.ts): `backend/src/services/code-context/code-context.service.ts`
- [Project text search](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/code-context/code-search.service.ts): `backend/src/services/code-context/code-search.service.ts`
- [Specialist agents](https://github.com/sumit1880/codeshield-ai/tree/main/backend/src/agents): `backend/src/agents`
- [Manager planner](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/agents/manager.agent.ts): `backend/src/agents/manager.agent.ts`

### Knowledge and providers

- [Knowledge retrieval](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/rag/rag.service.ts): `backend/src/services/rag/rag.service.ts`
- [Knowledge ingestion](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/rag/ingest.service.ts): `backend/src/services/rag/ingest.service.ts`
- [Embedding service](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/embeddings/embedding.service.ts): `backend/src/services/embeddings/embedding.service.ts`
- [LLM service](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/llm/llm.service.ts): `backend/src/services/llm/llm.service.ts`
- [Provider fallback](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/llm/llm-router.ts): `backend/src/services/llm/llm-router.ts`
- [Gemini embeddings](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/services/embeddings/gemini-embedding.service.ts): `backend/src/services/embeddings/gemini-embedding.service.ts`

### Runtime data

- [Knowledge database](https://github.com/sumit1880/codeshield-ai/blob/main/backend/src/config/prisma.ts): `backend/src/config/prisma.ts`
- [LLM providers](https://github.com/sumit1880/codeshield-ai/tree/main/backend/src/services/llm/providers): `backend/src/services/llm/providers`

### Other components

- **Analyst**

## Connections

- Analyst → Application shell: uses
- Application shell → Session authentication: provides session (evidence: `frontend/src/App.tsx`)
- Application shell → Scan workspace: renders (evidence: `frontend/src/App.tsx`)
- Scan workspace → Analysis request state: submits scans (evidence: `frontend/src/components/Workspace.tsx`)
- Scan workspace → Findings and history: shows findings (evidence: `frontend/src/components/Workspace.tsx`)
- Analysis request state → API client: sends requests
- API client → Analysis endpoint: calls API
- HTTP application → Analysis endpoint: mounts (evidence: `backend/src/app.ts`)
- Analysis endpoint → Analysis coordinator: starts analysis
- Analysis coordinator → Safe tool registry: dispatches actions
- Analysis coordinator → Static analysis: runs scans
- Analysis coordinator → Specialist agents: requests reasoning
- Analysis coordinator → Knowledge retrieval: requests retrieval
- Analysis coordinator → Code context search: gets context
- Analysis coordinator → Project text search: searches code
- Analysis coordinator → ZIP extraction: prepares uploads
- Manager planner → LLM service: requests decision (evidence: `backend/src/agents/manager.agent.ts`)
- Manager planner → Safe tool registry: delegates dispatch
- Knowledge retrieval → Embedding service: embeds query (evidence: `backend/src/services/rag/rag.service.ts`)
- Knowledge retrieval → Knowledge database: queries vectors (evidence: `backend/src/services/rag/rag.service.ts`)
- Knowledge ingestion → Embedding service: embeds chunks (evidence: `backend/src/services/rag/ingest.service.ts`)
- Knowledge ingestion → Knowledge database: stores chunks (evidence: `backend/src/services/rag/ingest.service.ts`)
- Gemini embeddings → Embedding service: implements (evidence: `backend/src/services/embeddings/gemini-embedding.service.ts`)
- Provider fallback → LLM providers: tries providers (evidence: `backend/src/services/llm/llm-router.ts`)
- Provider fallback → LLM service: implements (evidence: `backend/src/services/llm/llm-router.ts`)
