# sbusanelli/automind architecture

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

- Interactive diagram: https://gitdiagram.com/sbusanelli/automind
- Repository: https://github.com/sbusanelli/automind

## Overview

1. **Repository shape**
   - This is a monorepo with three real runtime areas: `backend/` for the API, `frontend/` for the client UI, and `infrastructure/` for container/AWS deployment. The rest of the repo is mostly automation, security tooling, docs, and demos.

2. **Primary runtime architecture**
   - The backend is the main system of record and orchestration layer. The frontend is a very thin React/TypeScript surface, centered on an `AIAssistant` component, that calls the backend for intelligence and operations actions.
   - The README describes a broader AI-ops platform, but the checked-in code tree is much more focused: backend AI/zero-trust services plus a minimal UI.

3. **Backend entrypoint and request flow**
   - `backend/src/index.ts` is the application bootstrap point.
   - Requests likely enter through Express, pass through `middleware/zeroTrustMiddleware.ts`, then route into `routes/zeroTrustRoutes.ts`, and from there into controllers such as `zeroTrustController.ts` and `aiController.ts`.
   - Controllers delegate business logic to services rather than talking directly to storage or external systems.

4. **Backend functional subsystems**
   - `services/aiService.ts` handles AI-facing operations such as analysis, prediction, explanation, or chat-style interactions.
   - `services/zeroTrustService.ts` implements the policy/decision layer for zero-trust behavior.
   - `services/credentialService.ts` and `services/vaultService.ts` indicate a credential-management boundary, likely isolating secrets handling from request logic.
   - `config/zeroTrustConfig.ts` centralizes policy/configuration for the security model.

5. **Security and policy boundary**
   - Zero-trust is a first-class architectural concern, not just an add-on. The middleware, config, controller, and logger all suggest that requests are evaluated and audited as they move through the system.
   - `utils/zeroTrustLogger.ts` indicates a dedicated security event log stream separate from normal application logging.

6. **Data model**
   - `models/Job.ts` is the only visible model, so the backend’s domain data appears to center on jobs/workflows rather than a broad set of business entities.
   - The README references PostgreSQL and Redis, but the tree only proves a job model and service layer; the architecture diagram should treat persistence as job-centric, with any cache/queue behavior as implied rather than explicit in source here.

7. **Frontend boundary**
   - `frontend/src/components/AIAssistant.tsx` suggests the client is intentionally narrow: a conversational or guided interface for AI-driven operations.
   - There is no large frontend app structure visible in the tree, so the UI should be drawn as a small consumer of backend APIs rather than a full independent product tier.

8. **Testing strategy**
   - The backend has unit, integration, and e2e test folders under `backend/src/tests/`, including a workflow E2E test and an API integration test.
   - This implies the main validation path is backend-centric, with tests covering service behavior, API contracts, and end-to-end operational workflows.

9. **Deployment and runtime packaging**
   - `infrastructure/docker/` contains a multi-stage Dockerfile, docker-compose, entrypoint, and health check scripts, so local and production-like execution is containerized.
   - `infrastructure/aws/cloudformation.yml` shows at least one cloud deployment target on AWS.
   - The README and GitHub Actions files also indicate multi-cloud deployment automation, but AWS is the only concrete infra template in the tree.

10. **CI/CD and repo automation**
    - GitHub Actions workflows cover testing, security scanning, dependency updates, credential rotation, and deployment.
    - There is also a `.gitlab-ci.yml`, so CI is not limited to GitHub; the repository supports multiple automation surfaces.
    - Scripts in `scripts/` enforce security and compliance checks, suggesting build-time policy gates are part of the architecture.

11. **Security toolchain**
    - The `security/` folder contains SAST and DAST configs, while `pmd-ruleset.xml` and the bundled PMD binaries show static analysis is part of the repo’s workflow.
    - Additional scripts check hardcoded env usage, API-key patterns, and vault compliance, which reinforces that secret handling and policy enforcement are architectural concerns, not just operational ones.

12. **Documentation and support assets**
    - `docs/`, `wiki/`, and `simulation/` provide architecture diagrams, deployment guidance, security guidance, and demo flows.
    - These are not runtime dependencies, but they are important for understanding intended boundaries and for drawing an accurate diagram of the system as designed versus the smaller code surface currently present.

13. **How to diagram this repo**
    - Draw a frontend client that talks to a backend API.
    - Inside the backend, show a request pipeline: Express/bootstrap → zero-trust middleware/config → controllers → services.
    - Separate the AI path from the credential/vault/security path.
    - Show job data as the primary domain entity.
    - Surround the system with containerization, AWS deployment, and CI/security automation as external operational layers.

Main entry points: [`backend/src/services/zeroTrustService.ts`](https://github.com/sbusanelli/automind/blob/main/backend/src/services/zeroTrustService.ts) (Policy Service), [`backend/src/index.ts`](https://github.com/sbusanelli/automind/blob/main/backend/src/index.ts) (App Bootstrap), [`backend/src/routes/zeroTrustRoutes.ts`](https://github.com/sbusanelli/automind/blob/main/backend/src/routes/zeroTrustRoutes.ts) (Zero-Trust Routes), [`security/sast-config.yml`](https://github.com/sbusanelli/automind/blob/main/security/sast-config.yml) (Security Checks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_frontend_aiassistant["AI Assistant<br/>react ui<br/>[AIAssistant.tsx]"]
end

subgraph group_backend["Backend"]
  node_backend_bootstrap["App Bootstrap<br/>express entrypoint<br/>[index.ts]"]
  node_backend_middleware["Zero-Trust MW<br/>request guard"]
  node_backend_routes["Zero-Trust Routes<br/>api routes<br/>[zeroTrustRoutes.ts]"]
  node_backend_controllers["Controllers<br/>api layer"]
  node_backend_ai_controller["AI Controller<br/>api layer<br/>[aiController.ts]"]
  node_backend_services_ai["AI Service<br/>business service<br/>[aiService.ts]"]
  node_backend_services_zero_trust["Policy Service<br/>security service"]
  node_backend_services_credential["Credential Service<br/>secret service"]
  node_backend_services_vault["Vault Service<br/>secret service<br/>[vaultService.ts]"]
  node_backend_config["Zero-Trust Config<br/>policy config<br/>[zeroTrustConfig.ts]"]
  node_backend_logger["Security Logger<br/>audit log<br/>[zeroTrustLogger.ts]"]
  node_backend_model_job[("Job Model<br/>domain model<br/>[Job.ts]")]
  node_backend_tests["Backend Tests<br/>test suite"]
end

subgraph group_ops["Operations"]
  node_infra_docker["Docker Runtime<br/>container packaging<br/>[Dockerfile.multi]"]
  node_infra_aws["AWS Deploy<br/>cloud template<br/>[cloudformation.yml]"]
end

subgraph group_automation["Automation"]
  node_automation_ci["CI Pipelines<br/>workflow automation<br/>[test.yml]"]
  node_automation_security["Security Checks<br/>security automation<br/>[sast-config.yml]"]
  node_automation_scripts["Repo Scripts<br/>policy scripts"]
end

node_frontend_aiassistant -->|"API calls"| node_backend_bootstrap
node_backend_bootstrap -->|"uses"| node_backend_middleware
node_backend_middleware -->|"forwards"| node_backend_routes
node_backend_routes -->|"dispatches"| node_backend_controllers
node_backend_routes -->|"dispatches"| node_backend_ai_controller
node_backend_controllers -->|"delegates"| node_backend_services_zero_trust
node_backend_ai_controller -->|"delegates"| node_backend_services_ai
node_backend_services_zero_trust -->|"reads policy"| node_backend_config
node_backend_services_zero_trust -->|"audits"| node_backend_logger
node_backend_services_zero_trust -->|"coordinates"| node_backend_services_credential
node_backend_services_credential -->|"stores in"| node_backend_services_vault
node_backend_services_ai -->|"operates on"| node_backend_model_job
node_backend_services_zero_trust -->|"governs"| node_backend_model_job
node_backend_bootstrap -.->|"validated by"| node_backend_tests
node_backend_bootstrap -->|"packaged by"| node_infra_docker
node_infra_docker -->|"deployed to"| node_infra_aws
node_automation_ci -->|"runs"| node_backend_tests
node_automation_ci -->|"triggers"| node_automation_security
node_automation_scripts -->|"supports"| node_automation_security
node_automation_scripts -->|"checks"| node_backend_services_vault
node_automation_security -.->|"verifies"| node_backend_logger

click node_frontend_aiassistant "https://github.com/sbusanelli/automind/blob/main/frontend/src/components/AIAssistant.tsx"
click node_backend_bootstrap "https://github.com/sbusanelli/automind/blob/main/backend/src/index.ts"
click node_backend_middleware "https://github.com/sbusanelli/automind/blob/main/backend/src/middleware/zeroTrustMiddleware.ts"
click node_backend_routes "https://github.com/sbusanelli/automind/blob/main/backend/src/routes/zeroTrustRoutes.ts"
click node_backend_controllers "https://github.com/sbusanelli/automind/blob/main/backend/src/controllers/zeroTrustController.ts"
click node_backend_ai_controller "https://github.com/sbusanelli/automind/blob/main/backend/src/controllers/aiController.ts"
click node_backend_services_ai "https://github.com/sbusanelli/automind/blob/main/backend/src/services/aiService.ts"
click node_backend_services_zero_trust "https://github.com/sbusanelli/automind/blob/main/backend/src/services/zeroTrustService.ts"
click node_backend_services_credential "https://github.com/sbusanelli/automind/blob/main/backend/src/services/credentialService.ts"
click node_backend_services_vault "https://github.com/sbusanelli/automind/blob/main/backend/src/services/vaultService.ts"
click node_backend_config "https://github.com/sbusanelli/automind/blob/main/backend/src/config/zeroTrustConfig.ts"
click node_backend_logger "https://github.com/sbusanelli/automind/blob/main/backend/src/utils/zeroTrustLogger.ts"
click node_backend_model_job "https://github.com/sbusanelli/automind/blob/main/backend/src/models/Job.ts"
click node_backend_tests "https://github.com/sbusanelli/automind/tree/main/backend/src/tests"
click node_infra_docker "https://github.com/sbusanelli/automind/blob/main/infrastructure/docker/Dockerfile.multi"
click node_infra_aws "https://github.com/sbusanelli/automind/blob/main/infrastructure/aws/cloudformation.yml"
click node_automation_ci "https://github.com/sbusanelli/automind/blob/main/.github/workflows/test.yml"
click node_automation_security "https://github.com/sbusanelli/automind/blob/main/security/sast-config.yml"
click node_automation_scripts "https://github.com/sbusanelli/automind/blob/main/scripts/check-vault-compliance.sh"

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_frontend_aiassistant toneBlue
class node_backend_bootstrap,node_backend_middleware,node_backend_routes,node_backend_controllers,node_backend_ai_controller,node_backend_services_ai,node_backend_services_zero_trust,node_backend_services_credential,node_backend_services_vault,node_backend_config,node_backend_logger,node_backend_model_job,node_backend_tests toneAmber
class node_infra_docker,node_infra_aws toneMint
class node_automation_ci,node_automation_security,node_automation_scripts toneRose
```

## Components

### Client

Thin UI surface

- [AI Assistant](https://github.com/sbusanelli/automind/blob/main/frontend/src/components/AIAssistant.tsx): react ui · Thin client entry point for AI-driven operations · `frontend/src/components/AIAssistant.tsx`

### Backend

API, policy, and domain services

- [App Bootstrap](https://github.com/sbusanelli/automind/blob/main/backend/src/index.ts): express entrypoint · Backend application startup and wiring · `backend/src/index.ts`
- [Zero-Trust MW](https://github.com/sbusanelli/automind/blob/main/backend/src/middleware/zeroTrustMiddleware.ts): request guard · Request-time security and policy enforcement · `backend/src/middleware/zeroTrustMiddleware.ts`
- [Zero-Trust Routes](https://github.com/sbusanelli/automind/blob/main/backend/src/routes/zeroTrustRoutes.ts): api routes · HTTP routing for security and operational endpoints · `backend/src/routes/zeroTrustRoutes.ts`
- [Controllers](https://github.com/sbusanelli/automind/blob/main/backend/src/controllers/zeroTrustController.ts): api layer · Request handlers that delegate to services · `backend/src/controllers/zeroTrustController.ts`
- [AI Controller](https://github.com/sbusanelli/automind/blob/main/backend/src/controllers/aiController.ts): api layer · API surface for AI-oriented operations · `backend/src/controllers/aiController.ts`
- [AI Service](https://github.com/sbusanelli/automind/blob/main/backend/src/services/aiService.ts): business service · Analysis, prediction, explanation, and chat-style logic · `backend/src/services/aiService.ts`
- [Policy Service](https://github.com/sbusanelli/automind/blob/main/backend/src/services/zeroTrustService.ts): security service · Zero-trust decision and enforcement logic · `backend/src/services/zeroTrustService.ts`
- [Credential Service](https://github.com/sbusanelli/automind/blob/main/backend/src/services/credentialService.ts): secret service · Credential handling boundary · `backend/src/services/credentialService.ts`
- [Vault Service](https://github.com/sbusanelli/automind/blob/main/backend/src/services/vaultService.ts): secret service · Secret storage and retrieval boundary · `backend/src/services/vaultService.ts`
- [Zero-Trust Config](https://github.com/sbusanelli/automind/blob/main/backend/src/config/zeroTrustConfig.ts): policy config · Centralized security and policy settings · `backend/src/config/zeroTrustConfig.ts`
- [Security Logger](https://github.com/sbusanelli/automind/blob/main/backend/src/utils/zeroTrustLogger.ts): audit log · Dedicated zero-trust audit/event logging · `backend/src/utils/zeroTrustLogger.ts`
- [Job Model](https://github.com/sbusanelli/automind/blob/main/backend/src/models/Job.ts): domain model · Primary domain entity for jobs/workflows · `backend/src/models/Job.ts`
- [Backend Tests](https://github.com/sbusanelli/automind/tree/main/backend/src/tests): test suite · Unit, integration, and end-to-end validation · `backend/src/tests`

### Operations

Container and cloud deployment

- [Docker Runtime](https://github.com/sbusanelli/automind/blob/main/infrastructure/docker/Dockerfile.multi): container packaging · Multi-stage container build and local compose runtime · `infrastructure/docker/Dockerfile.multi`
- [AWS Deploy](https://github.com/sbusanelli/automind/blob/main/infrastructure/aws/cloudformation.yml): cloud template · CloudFormation deployment target · `infrastructure/aws/cloudformation.yml`

### Automation

CI, scanning, and repo checks

- [CI Pipelines](https://github.com/sbusanelli/automind/blob/main/.github/workflows/test.yml): workflow automation · GitHub Actions and GitLab CI execution surfaces · `.github/workflows/test.yml`
- [Security Checks](https://github.com/sbusanelli/automind/blob/main/security/sast-config.yml): security automation · SAST, DAST, dependency, and compliance scanning · `security/sast-config.yml`
- [Repo Scripts](https://github.com/sbusanelli/automind/blob/main/scripts/check-vault-compliance.sh): policy scripts · Custom checks for vault, keys, env usage, and PMD · `scripts/check-vault-compliance.sh`

## Connections

- AI Assistant → App Bootstrap: API calls · UI sends operational and AI requests to the backend
- App Bootstrap → Zero-Trust MW: uses · Bootstrap wires request middleware into the app
- Zero-Trust MW → Zero-Trust Routes: forwards · Validated requests continue into route handling
- Zero-Trust Routes → Controllers: dispatches · Routes map requests to controllers
- Zero-Trust Routes → AI Controller: dispatches · AI-related endpoints reach the AI controller
- Controllers → Policy Service: delegates · Controllers push policy decisions into services
- AI Controller → AI Service: delegates · AI endpoints invoke AI business logic
- Policy Service → Zero-Trust Config: reads policy · Policy service consumes centralized zero-trust settings
- Policy Service → Security Logger: audits · Security decisions are written to the audit log
- Policy Service → Credential Service: coordinates · Policy decisions may involve credential handling
- Credential Service → Vault Service: stores in · Credential handling relies on vault boundaries
- AI Service → Job Model: operates on · AI logic centers on job/workflow domain data
- Policy Service → Job Model: governs · Security policy influences job-centric operations
- App Bootstrap → Backend Tests: validated by · Application behavior is covered by backend test suites
- App Bootstrap → Docker Runtime: packaged by · Backend runs inside container packaging
- Docker Runtime → AWS Deploy: deployed to · Containerized runtime is targeted for AWS deployment
- CI Pipelines → Backend Tests: runs · CI executes backend validation workflows
- CI Pipelines → Security Checks: triggers · Pipelines include security scanning and checks
- Repo Scripts → Security Checks: supports · Repo scripts reinforce security/compliance gates
- Repo Scripts → Vault Service: checks · Scripts validate vault and secret-handling rules
- Security Checks → Security Logger: verifies · Security tooling aligns with audit and logging concerns
