# spicycoder/dapr-blocks architecture

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

- Interactive diagram: https://gitdiagram.com/spicycoder/dapr-blocks
- Repository: https://github.com/spicycoder/dapr-blocks

## Overview

##### High-Level Architecture Overview

a. Building Blocks Layer
- State Management
- Secret Management
- Service Invocation
- Pub/Sub
- Bindings

b. Infrastructure Layer
- Dapr Runtime & Sidecars
- Tye Orchestration
- Supporting Services (Redis, etc.)

##### Component-Specific Details

For each building block, include:

a. Service Invocation
- HeroesApi and ContactsApi as separate microservices
- Direct service-to-service communication via Dapr

b. Pub/Sub
- Publisher and Subscriber services
- Redis PubSub component

c. State Management
- StateStore service
- To Redis state store
- State persistence flow

d. Secret Management
- SecretStore service
- Connection to local secret store
- Secret retrieval flow

e. Bindings
- InputOutputBindings
- Cron and Email binding components

##### Cross-Cutting Concerns
Sections for:
- Distributed Tracing
- Logging
- Common Library (shared models)

##### Implementation Details

- Controllers within each service
- Shared models from Common/Library
- Configuration files (tye.yaml, component yamls)
- Deployment configurations

##### Relationships

Clearly indicate:
- Service-to-service communication patterns
- Data flow directions
- Component dependencies
- Infrastructure requirements

- Maintain hierarchy: Start with high-level architecture, then drill down into building blocks
- Both runtime and deployment views
- Scaling points and potential bottlenecks
- Version information for major components
- Notes about configuration requirements
- Integration points with external systems

- Service discovery
- State management
- Pub/sub messaging
- Secret management
- External bindings
- Deployment orchestration

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions while avoiding overwhelming implementation details.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Building Blocks"
        SI["Service Invocation"]
        PS["Pub/Sub"]
        SM["State Management"]
        SE["Secret Management"]
        BI["Bindings"]
    end

    subgraph "Infrastructure"
        DR["Dapr Runtime"]
        TO["Tye Orchestration"]
        Redis[(Redis)]
    end

    subgraph "Service Invocation Layer"
        HA["HeroesApi"]
        CA["ContactsApi"]
    end

    subgraph "Pub/Sub Layer"
        PUB["Publisher"]
        SUB["Subscriber"]
        PSC["PubSub Component"]
    end

    subgraph "State Management Layer"
        SS["StateStore"]
        SSC["StateStore Component"]
    end

    subgraph "Secret Management Layer"
        SES["SecretStore"]
        LSS["Local Secret Store"]
    end

    subgraph "Bindings Layer"
        IOB["InputOutputBindings"]
        CronB["Cron Binding"]
        EmailB["Email Binding"]
    end

    subgraph "Common Library"
        CM["Contact Model"]
        HM["Hero Model"]
    end

    %% Relationships
    SI --> HA & CA
    PS --> PUB & SUB
    SM --> SS
    SE --> SES
    BI --> IOB

    DR --> SI & PS & SM & SE & BI
    TO --> DR
    Redis --> PSC & SSC

    HA --> CM
    CA --> CM
    PUB --> PSC
    SUB --> PSC
    SS --> SSC
    SES --> LSS
    IOB --> CronB & EmailB

    %% Click Events
    click HA "https://github.com/spicycoder/dapr-blocks/tree/main//ServiceInvocation/HeroesApi"
    click CA "https://github.com/spicycoder/dapr-blocks/tree/main//ServiceInvocation/ContactsApi"
    click PUB "https://github.com/spicycoder/dapr-blocks/tree/main//PubSub/Publisher"
    click SUB "https://github.com/spicycoder/dapr-blocks/tree/main//PubSub/Subscriber"
    click PSC "https://github.com/spicycoder/dapr-blocks/blob/main//PubSub/components/pubsub.yaml"
    click SS "https://github.com/spicycoder/dapr-blocks/tree/main//StateManagement/StateStore"
    click SSC "https://github.com/spicycoder/dapr-blocks/blob/main//StateManagement/components/statestore.yaml"
    click SES "https://github.com/spicycoder/dapr-blocks/tree/main//SecretManagement/SecretStore"
    click LSS "https://github.com/spicycoder/dapr-blocks/blob/main//SecretManagement/components/local-secret-store.yaml"
    click IOB "https://github.com/spicycoder/dapr-blocks/tree/main//Bindings/InputOutputBindings"
    click CronB "https://github.com/spicycoder/dapr-blocks/blob/main//Bindings/components/cron.yaml"
    click EmailB "https://github.com/spicycoder/dapr-blocks/blob/main//Bindings/components/email.yaml"
    click CM "https://github.com/spicycoder/dapr-blocks/blob/main//Common/Library/Contact.cs"
    click HM "https://github.com/spicycoder/dapr-blocks/blob/main//Common/Library/Hero.cs"

    %% Styling
    classDef service fill:#3498db
    classDef infrastructure fill:#f1c40f
    classDef component fill:#2ecc71
    classDef model fill:#95a5a6
    classDef binding fill:#e74c3c

    class HA,CA,PUB,SUB,SS,SES,IOB service
    class DR,TO,Redis infrastructure
    class SI,PS,SM,SE,BI,PSC,SSC,LSS,CronB,EmailB component
    class CM,HM model

    %% Legend
    subgraph Legend
        SVC["Service"]:::service
        INF["Infrastructure"]:::infrastructure
        COM["Component"]:::component
        MOD["Model"]:::model
        BIN["Binding"]:::binding
    end
```
