# aws-samples/bedrock-engineer architecture

> Architecture diagram of the GitHub repository aws-samples/bedrock-engineer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aws-samples/bedrock-engineer
- Repository: https://github.com/aws-samples/bedrock-engineer

## Overview

##### Main Components
- Electron Shell / Core Application – This includes the Electron main process, preload scripts, and configuration settings.
- Backend (Main Process) – Organized under “src/main” with APIs and services (e.g., bedrock, command, store). This layer handles application logic:
– API Services: Contains submodules that manage Bedrock integration (invokeBedrockAgent, image generation, etc.) and other command APIs.
– Logger Module: Structured under “src/common/logger” for consolidated logging management.
- Preload Layer – Acts as a bridge between the main process and renderer for secured API exposure (see “src/preload”).
- Frontend (Renderer Process) – Under “src/renderer”, mainly a React/Typescript-based UI that includes various pages:
– Agent Chat Interface: For interactive chat, file system operations, and tool management.
– Agent Directory: To discover and add preconfigured AI agents.
– Additional UI components, contexts, hooks, and assets which support features like internationalization and theme/settings.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Differentiate between the Electron main (backend) and renderer (frontend) processes.
- API Gateway / Service Layer: Within “src/main/api”, multiple services handle domain-specific operations such as agent management, file operations, and AWS integrations.
- Modular and Extensible Design: The presence of distinct directories such as “agents” (in .bedrock-engineer) and a variety of tools indicate a plugin-like system where new functionalities (e.g., tool integrations or agent roles) can be added with minimal friction.
- Cross-Platform Build Process: The presence of build configuration files (e.g., electron-builder.yml, specific build scripts for mac, win, linux) highlights a deployment/packaging step as part of the system’s lifecycle.

##### Technologies and Frameworks
- Electron as the core application framework.
- React (with Typescript) for the Renderer UI.
- AWS Bedrock and related APIs for AI services.
- Node.js-based backend modules; usage of configuration and build tools (webpack/ESLint/Prettier).
- Testing frameworks (Jest) indicating integrated testing of components.

##### Elements
- Core application layers (main, renderer, preload),
- UI components/pages,
- External integrations (AWS, Tavily API, file system, command execution),
- Cross-cutting utilities (Logger, Configuration, Testing).
- Annotations that specify which technologies (Electron, React, AWS Bedrock) are utilized by each module.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Electron Backend (Main Process)
    subgraph "Electron Backend (Main Process)"
        MP["Electron Main Process"]:::backend
        subgraph "API Services"
            AWSAPI["AWS Bedrock API Services"]:::backend
            CMDAPI["Command API Services"]:::backend
        end
        STORE["Store Management"]:::backend
        LOGGER["Logger Module"]:::utility
        BUILD["Build & Configuration"]:::utility
    end

    %% Preload Bridge Layer
    subgraph "Preload Bridge Layer"
        PRELOAD["Preload Bridge"]:::preload
    end

    %% Frontend UI (Renderer Process)
    subgraph "Frontend UI (Renderer Process)"
        RENDERER["Overall Renderer (React UI)"]:::frontend
        CHAT["Agent Chat Page"]:::frontend
        DIRECTORY["Agent Directory Page"]:::frontend
        WEBSITE["Website Generator Page"]:::frontend
        DIAGRAM["Diagram Generator Page"]:::frontend
        STEPFUNC["Step Functions Generator Page"]:::frontend
        SHARED["Shared UI Components & Contexts"]:::frontend
    end

    %% External Integrations and Services
    subgraph "External Integrations"
        AWS_EXT["AWS Bedrock Service"]:::external
        FILESYS["File System/Command Integration"]:::external
    end

    %% Connections between layers
    %% Frontend communicates with Backend via the Preload Bridge
    CHAT -->|"calls"| PRELOAD
    DIRECTORY -->|"calls"| PRELOAD
    WEBSITE -->|"calls"| PRELOAD
    DIAGRAM -->|"calls"| PRELOAD
    STEPFUNC -->|"calls"| PRELOAD
    SHARED -->|"supports"| RENDERER
    RENDERER -->|"routes to"| PRELOAD
    PRELOAD -->|"forwards to"| MP

    %% Within Backend: API Services, Store, Logger and Build
    MP -->|"invokes"| AWSAPI
    MP -->|"invokes"| CMDAPI
    MP -->|"manages"| STORE
    MP -->|"logs with"| LOGGER
    MP -->|"configured by"| BUILD

    %% External Integrations from API Services
    AWSAPI -->|"integrates with"| AWS_EXT
    CMDAPI -->|"triggers"| FILESYS

    %% Cross-cutting: Logger and Build used by multiple layers (dotted connections)
    LOGGER ---|"used by"| MP
    BUILD ---|"supports"| MP

    %% Click Events for Component Mapping

    %% Electron Shell / Core Application
    click MP "https://github.com/aws-samples/bedrock-engineer/blob/main/src/main/index.ts"
    click PRELOAD "https://github.com/aws-samples/bedrock-engineer/tree/main/src/preload/"
    click BUILD "https://github.com/aws-samples/bedrock-engineer/blob/main/electron-builder.yml"
    click BUILD "https://github.com/aws-samples/bedrock-engineer/blob/main/electron.vite.config.ts"

    %% Backend API Services and Store
    click AWSAPI "https://github.com/aws-samples/bedrock-engineer/tree/main/src/main/api/bedrock/"
    click CMDAPI "https://github.com/aws-samples/bedrock-engineer/blob/main/src/main/api/command/commandService.ts"
    click STORE "https://github.com/aws-samples/bedrock-engineer/tree/main/src/main/store/"

    %% Logger Module
    click LOGGER "https://github.com/aws-samples/bedrock-engineer/tree/main/src/common/logger/"

    %% Frontend Renderer and Pages
    click RENDERER "https://github.com/aws-samples/bedrock-engineer/tree/main/src/renderer/"
    click CHAT "https://github.com/aws-samples/bedrock-engineer/tree/main/src/renderer/src/pages/ChatPage/"
    click DIRECTORY "https://github.com/aws-samples/bedrock-engineer/tree/main/src/renderer/src/pages/AgentDirectoryPage/"
    click WEBSITE "https://github.com/aws-samples/bedrock-engineer/tree/main/src/renderer/src/pages/WebsiteGeneratorPage/"
    click DIAGRAM "https://github.com/aws-samples/bedrock-engineer/tree/main/src/renderer/src/pages/DiagramGeneratorPage/"
    click STEPFUNC "https://github.com/aws-samples/bedrock-engineer/tree/main/src/renderer/src/pages/StepFunctionsGeneratorPage/"
    click SHARED "https://github.com/aws-samples/bedrock-engineer/tree/main/src/renderer/src/components/"

    %% External Integration (AWS Bedrock Utils)
    click AWS_EXT "https://github.com/aws-samples/bedrock-engineer/blob/main/src/main/api/bedrock/utils/awsUtils.ts"

    %% Styles
    classDef backend fill:#f8d7da,stroke:#ad1608,stroke-width:2px
    classDef preload fill:#d1ecf1,stroke:#0c5460,stroke-width:2px
    classDef frontend fill:#d4edda,stroke:#155724,stroke-width:2px
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px
    classDef utility fill:#e2e3e5,stroke:#6c757d,stroke-width:2px
```
