# jensroland/kegstand architecture

> Architecture diagram of the GitHub repository jensroland/kegstand, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jensroland/kegstand
- Repository: https://github.com/jensroland/kegstand

## Overview

##### Main Components

a. CLI Layer (Command Interface)
- Main CLI commands (new, build, deploy, teardown)
- Configuration handling components
- To template system (*.tmpl files)

b. Infrastructure Layer (AWS CDK Integration)
- REST API Backend Stack
- REST API Gateway Stack
- Lambda Function handlers
- Integration with AWS CDK

c. Project Template Structure
- Standard project layout
- API organization pattern
- Build system integration (uv/Poetry support)

**┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐**
- CLI Layer     │    │Infrastructure   │    │   AWS Cloud     │
- > │     Layer       │ -> │  Resources      │
- ┘    └─────────────────┘    └─────────────────┘

##### Component Details

CLI Layer (Left):
- Template files with document symbols
- Configuration handling

Infrastructure Layer (Middle):
- CDK Stack components
- Build process
- Template processing

AWS Cloud (Right):
- API Gateway
- Lambda Functions
- Other AWS services

##### Key Relationships

a. Command Flow:
- CLI commands → Infrastructure Layer
- Infrastructure Layer → AWS Resource Creation

b. Build Process:
- Project Template → Built Lambda Functions
- Configuration → Infrastructure Deployment

c. Runtime Flow:
- API Gateway → Lambda Functions
- Service Dependencies

##### Important Elements to Highlight

- Template-based project generation
- Build system flexibility (uv/Poetry)
- AWS resource provisioning
- API Gateway configuration
- Lambda function deployment

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Define styles
    classDef cli fill:#3498db,stroke:#2980b9,color:white
    classDef infra fill:#2ecc71,stroke:#27ae60,color:white
    classDef aws fill:#e67e22,stroke:#d35400,color:white
    classDef template fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef config fill:#9b59b6,stroke:#8e44ad,color:white

    %% CLI Layer
    subgraph CLI
        CLI_Commands{"CLI Commands"}
        NewCmd["New Command"]:::cli
        BuildCmd["Build Command"]:::cli
        DeployCmd["Deploy Command"]:::cli
        TeardownCmd["Teardown Command"]:::cli
        Config["Configuration Handler"]:::config
        
        CLI_Commands --> NewCmd
        CLI_Commands --> BuildCmd
        CLI_Commands --> DeployCmd
        CLI_Commands --> TeardownCmd
        CLI_Commands --> Config
    end

    %% Template System
    subgraph Templates
        LambdaTemplate["Lambda Template"]:::template
        GatewayTemplate["API Gateway Health Check Template"]:::template
        ProjectTemplates["Project Templates"]:::template
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        InfraApp["Infrastructure App"]:::infra
        RestBackend["REST API Backend Stack"]:::infra
        RestGateway["REST API Gateway Stack"]:::infra
        InfraConfig["Infrastructure Configuration"]:::config
        
        InfraApp --> RestBackend
        InfraApp --> RestGateway
        InfraApp --> InfraConfig
    end

    %% AWS Cloud Resources
    subgraph AWS
        APIGateway["API Gateway"]:::aws
        LambdaFunctions["Lambda Functions"]:::aws
        
        APIGateway --> LambdaFunctions
    end

    %% Relationships
    NewCmd --> Templates
    Templates --> InfraApp
    BuildCmd --> InfraApp
    DeployCmd --> InfraApp
    TeardownCmd --> InfraApp
    InfraApp --> AWS

    %% Click events
    click NewCmd "https://github.com/JensRoland/kegstand/blob/main/src/kegstandcli/cli/new.py"
    click BuildCmd "https://github.com/JensRoland/kegstand/blob/main/src/kegstandcli/cli/build.py"
    click DeployCmd "https://github.com/JensRoland/kegstand/blob/main/src/kegstandcli/cli/deploy.py"
    click TeardownCmd "https://github.com/JensRoland/kegstand/blob/main/src/kegstandcli/cli/teardown.py"
    click Config "https://github.com/JensRoland/kegstand/blob/main/src/kegstandcli/cli/config.py"
    click LambdaTemplate "https://github.com/JensRoland/kegstand/blob/main/src/kegstandcli/cli/default_lambda.py.tmpl"
    click GatewayTemplate "https://github.com/JensRoland/kegstand/blob/main/src/kegstandcli/cli/rest_api_gateway_health_check.py.tmpl"
    click InfraApp "https://github.com/JensRoland/kegstand/blob/main/src/kegstandcli/infra/app.py"
    click RestBackend "https://github.com/JensRoland/kegstand/blob/main/src/kegstandcli/infra/stacks/rest_api_backend.py"
    click RestGateway "https://github.com/JensRoland/kegstand/blob/main/src/kegstandcli/infra/stacks/rest_api_gateway.py"
    click InfraConfig "https://github.com/JensRoland/kegstand/blob/main/src/kegstandcli/infra/cdk.json"
    click ProjectTemplates "https://github.com/JensRoland/kegstand/tree/main/tests/test_data/simple_project/"

    %% Legend
    subgraph Legend
        CLI_L["CLI Components"]:::cli
        INFRA_L["Infrastructure Components"]:::infra
        AWS_L["AWS Services"]:::aws
        TEMPLATE_L["Templates"]:::template
        CONFIG_L["Configuration"]:::config
    end
```
