# jezzsantos/saastack architecture

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

- Interactive diagram: https://gitdiagram.com/jezzsantos/saastack
- Repository: https://github.com/jezzsantos/saastack

## Overview

##### Core system components
- Frontend WebUI (labeled “Frontend”): Although marked “Under Construction” in the README, the codebase includes a ClientApp (in WebsiteHost/ClientApp) that represents the web UI layer.
- Backend APIs / Application Gateways: These include several API projects like “ApiHost1”, “AzureFunctions.Api.WorkerHost”, and “AWSLambdas.Api.WorkerHost”. They are providers of HTTP endpoints and integration delivery.
- Modular Domain Components (Subdomains): Modules such as Cars, Bookings, EndUsers, Organizations, Subscriptions, and UserProfiles are each implemented as their own set of projects. They represent the bounded contexts where Domain-Driven Design, Aggregates, Domain Events, and Event Sourcing are applied.
- Infrastructure Adapters and Technical Services: These include persistence layers (e.g., SQL, AWS, Azure adapters), integration adapters for third-party services (billing, identity, messaging, notifications), and adapters that abstract polyglot persistence. Also include common supporting libraries like Infrastructure.Eventing, Infrastructure.Hosting, and adapters under the “Tools” folder.
- Shared/Common Layers: These are the cross-cutting concerns such as Application.Common, Domain.Common, Infrastructure.Common, and shared libraries for logging, configuration, dependency injection, exception handling, and testing.

##### Relationships and interactions
- That each subdomain (Cars, Bookings, etc.) is composed of several layers: the Domain Layer (with aggregates, events, validations), the Application Layer (with services and handlers), and the Infrastructure Layer (with persistence, external adapters, API controllers). Use layered “onion” or “clean architecture” circles to indicate that the domain is at the center and is isolated from technical concerns.
- Test projects (unit tests, integration tests, architecture tests) as supporting components that validate the layers but are not directly deployed. You might include them to show that every major module is fully tested.

##### Architectural patterns and design principles
- Denote that the architecture is influenced by Clean Architecture, Onion Architecture, and Hexagonal Architecture – emphasize that the Domain Model is at the center, protected by application and then infrastructure layers.
- Mention that the template supports Domain-Driven Design (with Aggregates and Domain Events) and Event Sourcing. For example, attach a small “event trail” or “history” node near domain modules.

##### Relevant technology details
- That the system is built in .NET (Core 8+), using C#.
- Reference the common configuration using “appsettings.json” shown in configuration files across projects.
- CI/CD pipelines (e.g., GitHub Actions workflows with build.yml and deploy-azure.yml), which tie into cloud deployments.
- Optionally, show that integration with Azure and AWS is achieved via Infrastructure as Code (e.g., the “iac” folder for Azure ARM templates, SQL Server seed scripts, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Level: Client and API Gateways
    FE["Frontend WebUI"]:::frontend
    API1["API - ApiHost1"]:::api
    API2["API - Azure Functions"]:::api
    API3["API - AWS Lambdas"]:::api

    FE -->|"REST call"| API1
    FE -->|"REST call"| API2
    FE -->|"REST call"| API3

    %% Aggregator for Domain Modules routing
    DA["Domain Aggregator"]:::app
    API1 -->|"routes"| DA
    API2 -->|"routes"| DA
    API3 -->|"routes"| DA

    %% Subdomain Modules
    subgraph "Subdomain Modules"
        %% Module: Cars
        subgraph "Cars Module"
            CarsDomain["Cars Domain"]:::domain
            CarsApp["Cars Application"]:::app
            CarsInfra["Cars Infrastructure"]:::infra
            CarsDomain -->|"calls"| CarsApp
            CarsApp -->|"calls"| CarsInfra
        end

        %% Module: Bookings
        subgraph "Bookings Module"
            BookingsDomain["Bookings Domain"]:::domain
            BookingsApp["Bookings Application"]:::app
            BookingsInfra["Bookings Infrastructure"]:::infra
            BookingsDomain -->|"calls"| BookingsApp
            BookingsApp -->|"calls"| BookingsInfra
        end

        %% Module: EndUsers
        subgraph "EndUsers Module"
            EndUsersDomain["EndUsers Domain"]:::domain
            EndUsersApp["EndUsers Application"]:::app
            EndUsersInfra["EndUsers Infrastructure"]:::infra
            EndUsersDomain -->|"calls"| EndUsersApp
            EndUsersApp -->|"calls"| EndUsersInfra
        end

        %% Module: Organizations
        subgraph "Organizations Module"
            OrganizationsDomain["Organizations Domain"]:::domain
            OrganizationsApp["Organizations Application"]:::app
            OrganizationsInfra["Organizations Infrastructure"]:::infra
            OrganizationsDomain -->|"calls"| OrganizationsApp
            OrganizationsApp -->|"calls"| OrganizationsInfra
        end

        %% Module: Subscriptions
        subgraph "Subscriptions Module"
            SubscriptionsDomain["Subscriptions Domain"]:::domain
            SubscriptionsApp["Subscriptions Application"]:::app
            SubscriptionsInfra["Subscriptions Infrastructure"]:::infra
            SubscriptionsDomain -->|"calls"| SubscriptionsApp
            SubscriptionsApp -->|"calls"| SubscriptionsInfra
        end

        %% Module: UserProfiles
        subgraph "UserProfiles Module"
            UserProfilesDomain["UserProfiles Domain"]:::domain
            UserProfilesApp["UserProfiles Application"]:::app
            UserProfilesInfra["UserProfiles Infrastructure"]:::infra
            UserProfilesDomain -->|"calls"| UserProfilesApp
            UserProfilesApp -->|"calls"| UserProfilesInfra
        end
    end

    %% From Domain Aggregator to each Module's Infrastructure layer
    DA -->|"dispatches"| CarsInfra
    DA -->|"dispatches"| BookingsInfra
    DA -->|"dispatches"| EndUsersInfra
    DA -->|"dispatches"| OrganizationsInfra
    DA -->|"dispatches"| SubscriptionsInfra
    DA -->|"dispatches"| UserProfilesInfra

    %% Infrastructure Adapters and Technical Services
    IA["Infrastructure Adapters & Technical Services"]:::infra
    CarsInfra --> IA
    BookingsInfra --> IA
    EndUsersInfra --> IA
    OrganizationsInfra --> IA
    SubscriptionsInfra --> IA
    UserProfilesInfra --> IA

    %% Details for Infrastructure Adapters
    subgraph "Adapters & Persistence"
        CI["Common Infrastructure Libraries"]:::infra
        PAZ["Persistence: Azure"]:::infra
        PAW["Persistence: AWS"]:::infra
        PC["Persistence: Common"]:::infra
        IA --> CI
        IA --> PAZ
        IA --> PAW
        IA --> PC
    end

    %% Shared/Common Layers
    SL["Shared Layers"]:::shared
    CI --> SL
    PAZ --> SL
    PAW --> SL
    PC --> SL

    %% CI/CD and Deployment
    CICD["CI/CD & Deployment"]:::ci
    SL --> CICD

    %% External Cloud Services
    Cloud["Azure Platform Services"]:::infra
    CICD -->|"deploys to"| Cloud

    %% Test Suite (validating integration across layers)
    TS["Test Suite"]:::app
    TS -- "validates" --> DA

    %% Styles
    classDef frontend fill:#f9c,stroke:#333,stroke-width:2px;
    classDef api fill:#ff9,stroke:#333,stroke-width:2px;
    classDef domain fill:#9f9,stroke:#333,stroke-width:2px;
    classDef app fill:#9ff,stroke:#333,stroke-width:2px;
    classDef infra fill:#f99,stroke:#333,stroke-width:2px;
    classDef shared fill:#99f,stroke:#333,stroke-width:2px;
    classDef ci fill:#fc9,stroke:#333,stroke-width:2px;

    %% Click Events
    click FE "https://github.com/jezzsantos/saastack/tree/main/WebsiteHost/ClientApp"
    click API1 "https://github.com/jezzsantos/saastack/tree/main/src/ApiHost1"
    click API2 "https://github.com/jezzsantos/saastack/blob/main/src/AzureFunctions.Api.WorkerHost"
    click API3 "https://github.com/jezzsantos/saastack/blob/main/src/AWSLambdas.Api.WorkerHost"

    click CarsDomain "https://github.com/jezzsantos/saastack/tree/main/src/CarsDomain"
    click CarsApp "https://github.com/jezzsantos/saastack/tree/main/src/CarsApplication"
    click CarsInfra "https://github.com/jezzsantos/saastack/tree/main/src/CarsInfrastructure"

    click BookingsDomain "https://github.com/jezzsantos/saastack/tree/main/src/BookingsDomain"
    click BookingsApp "https://github.com/jezzsantos/saastack/tree/main/src/BookingsApplication"
    click BookingsInfra "https://github.com/jezzsantos/saastack/tree/main/src/BookingsInfrastructure"

    click EndUsersDomain "https://github.com/jezzsantos/saastack/tree/main/src/EndUsersDomain"
    click EndUsersApp "https://github.com/jezzsantos/saastack/tree/main/src/EndUsersApplication"
    click EndUsersInfra "https://github.com/jezzsantos/saastack/tree/main/src/EndUsersInfrastructure"

    click OrganizationsDomain "https://github.com/jezzsantos/saastack/tree/main/src/OrganizationsDomain"
    click OrganizationsApp "https://github.com/jezzsantos/saastack/tree/main/src/OrganizationsApplication"
    click OrganizationsInfra "https://github.com/jezzsantos/saastack/tree/main/src/OrganizationsInfrastructure"

    click SubscriptionsDomain "https://github.com/jezzsantos/saastack/tree/main/src/SubscriptionsDomain"
    click SubscriptionsApp "https://github.com/jezzsantos/saastack/tree/main/src/SubscriptionsApplication"
    click SubscriptionsInfra "https://github.com/jezzsantos/saastack/tree/main/src/SubscriptionsInfrastructure"

    click UserProfilesDomain "https://github.com/jezzsantos/saastack/tree/main/src/UserProfilesDomain"
    click UserProfilesApp "https://github.com/jezzsantos/saastack/tree/main/src/UserProfilesApplication"
    click UserProfilesInfra "https://github.com/jezzsantos/saastack/tree/main/src/UserProfilesInfrastructure"

    click CI "https://github.com/jezzsantos/saastack/blob/main/src/Infrastructure.Common"
    click PAZ "https://github.com/jezzsantos/saastack/blob/main/src/Infrastructure.Persistence.Azure"
    click PAW "https://github.com/jezzsantos/saastack/blob/main/src/Infrastructure.Persistence.AWS"
    click PC "https://github.com/jezzsantos/saastack/blob/main/src/Infrastructure.Persistence.Common"

    click SL "https://github.com/jezzsantos/saastack/blob/main/src/Application.Common"
    click SL "https://github.com/jezzsantos/saastack/blob/main/src/Domain.Common"
    click SL "https://github.com/jezzsantos/saastack/blob/main/src/Infrastructure.Common"

    click CICD "https://github.com/jezzsantos/saastack/tree/main/.github/workflows"
    click CICD "https://github.com/jezzsantos/saastack/tree/main/iac/Azure/ARM"
    click CICD "https://github.com/jezzsantos/saastack/tree/main/iac/Azure/SQLServer"
```
