# tetra4ge/githygiene architecture

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

- Interactive diagram: https://gitdiagram.com/tetra4ge/githygiene
- Repository: https://github.com/tetra4ge/githygiene

## Overview

GitHygiene is a dependency-security platform: users sync repositories, ingest manifests, extract dependencies, scan for advisories, and review organization-scoped findings. The gateway owns persistence and integrations; the optional AI path adds advisory-surface extraction, deterministic code evidence, reachability assessment, and remediation. The README documents some capabilities whose controller internals were not sampled, so those links are limited to documented or indexed relationships; the AI service is present in source despite the README’s older “scaffolded” status.

Main entry points: [`api-gateway/routes/index.routes.js`](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/routes/index.routes.js) (API routes), [`api-gateway/controllers/osv.controller.js`](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/osv.controller.js) (Advisory matching), [`api-gateway/controllers/ai.controller.js`](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/ai.controller.js) (AI orchestration), [`api-gateway/config/db.config.js`](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/config/db.config.js) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User console"]
  node_console["Dashboard<br/>[Overview.tsx]"]
  node_auth_ui["Session state<br/>[authStore.ts]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_gateway["API and access"]
  node_gateway["REST gateway<br/>[server.js]"]
  node_routes["API routes<br/>[index.routes.js]"]
  node_auth["JWT verification<br/>[auth.middleware.js]"]
  node_rbac["Org access scope<br/>[rbac.util.js]"]
end

subgraph group_security["Dependency security"]
  node_manifest["Manifest ingestion"]
  node_parser["Dependency extraction"]
  node_manifest_parsers["Manifest parsers"]
  node_scanner["Dependency scan"]
  node_osv_scan["Advisory matching<br/>[osv.controller.js]"]
  node_osv_client["OSV integration<br/>[osv.service.js]"]
  node_registry["Version lookup"]
  node_scoring["Risk scoring<br/>[scoring.service.js]"]
end

subgraph group_intelligence["AI analysis"]
  node_ai_controller["AI orchestration<br/>[ai.controller.js]"]
  node_evidence["Code evidence search"]
  node_ai_service["AI HTTP service<br/>[ai.service.js]"]
  node_ai_routes["AI endpoints"]
  node_prompts["Analysis prompts<br/>[prompts.py]"]
  node_gemini["Structured model client<br/>[gemini_client.py]"]
  node_ai_config["Model settings<br/>[config.py]"]
  node_schemas["Response contracts<br/>[schemas.py]"]
end

subgraph group_state["Persistence and graph"]
  node_graph_service["Dependency graph<br/>[graph.service.js]"]
  node_postgres[("PostgreSQL<br/>[db.config.js]")]
  node_neo4j[("Neo4j<br/>[db.config.js]")]
end

node_maintainer(("Signed-in user"))

node_maintainer -->|"uses"| node_console
node_console -->|"tracks session"| node_auth_ui
node_console -.->|"requests data"| node_api_client
node_api_client -->|"REST calls"| node_gateway
node_gateway -->|"mounts API"| node_routes
node_routes -->|"protects endpoints"| node_auth
node_routes -.->|"routes ingest"| node_manifest
node_routes -.->|"routes extraction"| node_parser
node_routes -->|"routes scans"| node_scanner
node_routes -->|"routes advisories"| node_osv_scan
node_routes -->|"routes analysis"| node_ai_controller
node_manifest -->|"stores manifests"| node_postgres
node_parser -->|"uses parsers"| node_manifest_parsers
node_parser -->|"writes dependencies"| node_postgres
node_scanner -->|"records alerts"| node_postgres
node_osv_scan -->|"queries advisories"| node_osv_client
node_osv_scan -->|"looks up versions"| node_registry
node_osv_scan -->|"computes score"| node_scoring
node_osv_scan -->|"writes scan graph"| node_graph_service
node_osv_scan -->|"reads and writes"| node_postgres
node_graph_service -->|"queries graph"| node_neo4j
node_ai_controller -->|"checks access"| node_rbac
node_ai_controller -->|"searches code"| node_evidence
node_ai_controller -->|"gets dependency path"| node_graph_service
node_ai_controller -->|"requests analysis"| node_ai_service
node_ai_controller -->|"caches assessments"| node_postgres
node_ai_service -.->|"calls service"| node_ai_routes
node_ai_routes -->|"builds prompts"| node_prompts
node_ai_routes -->|"generates analysis"| node_gemini
node_gemini -->|"reads settings"| node_ai_config
node_ai_routes -->|"validates payloads"| node_schemas

click node_console "https://github.com/tetra4ge/githygiene/blob/main/frontend/src/pages/dashboard/Overview.tsx"
click node_auth_ui "https://github.com/tetra4ge/githygiene/blob/main/frontend/src/lib/authStore.ts"
click node_api_client "https://github.com/tetra4ge/githygiene/blob/main/frontend/src/lib/api.ts"
click node_gateway "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/server.js"
click node_routes "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/routes/index.routes.js"
click node_auth "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/middlewares/auth.middleware.js"
click node_rbac "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/utils/rbac.util.js"
click node_manifest "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/manifest.controller.js"
click node_parser "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/parser.controller.js"
click node_manifest_parsers "https://github.com/tetra4ge/githygiene/tree/main/api-gateway/services/parsers"
click node_scanner "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/scanner.controller.js"
click node_osv_scan "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/osv.controller.js"
click node_osv_client "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/osv.service.js"
click node_registry "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/registry.service.js"
click node_scoring "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/scoring.service.js"
click node_graph_service "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/graph.service.js"
click node_postgres "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/config/db.config.js"
click node_neo4j "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/config/db.config.js"
click node_ai_controller "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/ai.controller.js"
click node_evidence "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/evidence.service.js"
click node_ai_service "https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/ai.service.js"
click node_ai_routes "https://github.com/tetra4ge/githygiene/tree/main/ai-service/api/routes"
click node_prompts "https://github.com/tetra4ge/githygiene/blob/main/ai-service/llm/prompts.py"
click node_gemini "https://github.com/tetra4ge/githygiene/blob/main/ai-service/llm/gemini_client.py"
click node_ai_config "https://github.com/tetra4ge/githygiene/blob/main/ai-service/core/config.py"
click node_schemas "https://github.com/tetra4ge/githygiene/blob/main/ai-service/models/schemas.py"

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_console,node_auth_ui,node_api_client,node_maintainer toneBlue
class node_gateway,node_routes,node_auth,node_rbac toneAmber
class node_manifest,node_parser,node_manifest_parsers,node_scanner,node_osv_scan,node_osv_client,node_registry,node_scoring toneMint
class node_ai_controller,node_evidence,node_ai_service,node_ai_routes,node_prompts,node_gemini,node_ai_config,node_schemas toneRose
class node_graph_service,node_postgres,node_neo4j toneIndigo
```

## Components

### User console

- [Dashboard](https://github.com/tetra4ge/githygiene/blob/main/frontend/src/pages/dashboard/Overview.tsx): `frontend/src/pages/dashboard/Overview.tsx`
- [Session state](https://github.com/tetra4ge/githygiene/blob/main/frontend/src/lib/authStore.ts): `frontend/src/lib/authStore.ts`
- [API client](https://github.com/tetra4ge/githygiene/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### API and access

- [REST gateway](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/server.js): `api-gateway/server.js`
- [API routes](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/routes/index.routes.js): `api-gateway/routes/index.routes.js`
- [JWT verification](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/middlewares/auth.middleware.js): `api-gateway/middlewares/auth.middleware.js`
- [Org access scope](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/utils/rbac.util.js): `api-gateway/utils/rbac.util.js`

### Dependency security

- [Manifest ingestion](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/manifest.controller.js): `api-gateway/controllers/manifest.controller.js`
- [Dependency extraction](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/parser.controller.js): `api-gateway/controllers/parser.controller.js`
- [Manifest parsers](https://github.com/tetra4ge/githygiene/tree/main/api-gateway/services/parsers): `api-gateway/services/parsers`
- [Dependency scan](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/scanner.controller.js): `api-gateway/controllers/scanner.controller.js`
- [Advisory matching](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/osv.controller.js): `api-gateway/controllers/osv.controller.js`
- [OSV integration](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/osv.service.js): `api-gateway/services/osv.service.js`
- [Version lookup](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/registry.service.js): `api-gateway/services/registry.service.js`
- [Risk scoring](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/scoring.service.js): `api-gateway/services/scoring.service.js`

### AI analysis

- [AI orchestration](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/controllers/ai.controller.js): `api-gateway/controllers/ai.controller.js`
- [Code evidence search](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/evidence.service.js): `api-gateway/services/evidence.service.js`
- [AI HTTP service](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/ai.service.js): `api-gateway/services/ai.service.js`
- [AI endpoints](https://github.com/tetra4ge/githygiene/tree/main/ai-service/api/routes): `ai-service/api/routes`
- [Analysis prompts](https://github.com/tetra4ge/githygiene/blob/main/ai-service/llm/prompts.py): `ai-service/llm/prompts.py`
- [Structured model client](https://github.com/tetra4ge/githygiene/blob/main/ai-service/llm/gemini_client.py): `ai-service/llm/gemini_client.py`
- [Model settings](https://github.com/tetra4ge/githygiene/blob/main/ai-service/core/config.py): `ai-service/core/config.py`
- [Response contracts](https://github.com/tetra4ge/githygiene/blob/main/ai-service/models/schemas.py): `ai-service/models/schemas.py`

### Persistence and graph

- [Dependency graph](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/services/graph.service.js): `api-gateway/services/graph.service.js`
- [PostgreSQL](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/config/db.config.js): `api-gateway/config/db.config.js`
- [Neo4j](https://github.com/tetra4ge/githygiene/blob/main/api-gateway/config/db.config.js): `api-gateway/config/db.config.js`

### Other components

- **Signed-in user**

## Connections

- Signed-in user → Dashboard: uses (evidence: `README.md`)
- Dashboard → Session state: tracks session (evidence: `frontend/src/App.tsx`)
- Dashboard → API client: requests data
- API client → REST gateway: REST calls (evidence: `README.md`)
- REST gateway → API routes: mounts API (evidence: `api-gateway/server.js`)
- API routes → JWT verification: protects endpoints
- API routes → Manifest ingestion: routes ingest
- API routes → Dependency extraction: routes extraction
- API routes → Dependency scan: routes scans (evidence: `api-gateway/routes/index.routes.js`)
- API routes → Advisory matching: routes advisories (evidence: `api-gateway/routes/index.routes.js`)
- API routes → AI orchestration: routes analysis
- Manifest ingestion → PostgreSQL: stores manifests (evidence: `api-gateway/controllers/manifest.controller.js`)
- Dependency extraction → Manifest parsers: uses parsers (evidence: `api-gateway/controllers/parser.controller.js`)
- Dependency extraction → PostgreSQL: writes dependencies (evidence: `README.md`)
- Dependency scan → PostgreSQL: records alerts (evidence: `README.md`)
- Advisory matching → OSV integration: queries advisories (evidence: `api-gateway/controllers/osv.controller.js`)
- Advisory matching → Version lookup: looks up versions (evidence: `api-gateway/controllers/osv.controller.js`)
- Advisory matching → Risk scoring: computes score (evidence: `api-gateway/controllers/osv.controller.js`)
- Advisory matching → Dependency graph: writes scan graph (evidence: `api-gateway/controllers/osv.controller.js`)
- Advisory matching → PostgreSQL: reads and writes (evidence: `api-gateway/controllers/osv.controller.js`)
- Dependency graph → Neo4j: queries graph (evidence: `api-gateway/services/graph.service.js`)
- AI orchestration → Org access scope: checks access (evidence: `api-gateway/controllers/ai.controller.js`)
- AI orchestration → Code evidence search: searches code (evidence: `api-gateway/controllers/ai.controller.js`)
- AI orchestration → Dependency graph: gets dependency path (evidence: `api-gateway/controllers/ai.controller.js`)
- AI orchestration → AI HTTP service: requests analysis (evidence: `api-gateway/controllers/ai.controller.js`)
- AI orchestration → PostgreSQL: caches assessments (evidence: `api-gateway/controllers/ai.controller.js`)
- AI HTTP service → AI endpoints: calls service
- AI endpoints → Analysis prompts: builds prompts (evidence: `ai-service/api/routes/assess.py`)
- AI endpoints → Structured model client: generates analysis (evidence: `ai-service/api/routes/assess.py`)
- Structured model client → Model settings: reads settings (evidence: `ai-service/llm/gemini_client.py`)
- AI endpoints → Response contracts: validates payloads (evidence: `ai-service/api/routes/assess.py`)
