# verplanckeo/eventstore architecture

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

- Interactive diagram: https://gitdiagram.com/verplanckeo/eventstore
- Repository: https://github.com/verplanckeo/eventstore

## Overview

- An Angular-based frontend (found under the “App” folder) that offers various features (account management, tickets, users, video, etc.) using Angular routing modules, components, and services.
- A .NET backend that implements an event sourcing–driven API (mainly in the “EventStore.Api” project and its companion libraries such as EventStore.Application, EventStore.Core, and EventStore.Infrastructure) which follows a layered DDD/CQRS/Mediator pattern.

##### Main Components
a. Frontend Component (Angular App)
– The “App” folder houses an Angular application. Break this down into submodules such as the “features” (account, tickets, alerts, etc.), shared assets, and routing modules.
b. Backend API Component (EventStore.Api)
– This is the entry point for API calls. Controllers (e.g., TicketsController.cs, UsersController.cs) expose HTTP endpoints.
c. Application and Business Logic Layer (EventStore.Application)
– Contains the mediator commands, query handlers, and business rules. It acts as the bridge between the API and the domain.
d. Domain/Core Layer (EventStore.Core)
– Contains domain entities, aggregates, events, and state machine logic for tickets and users. This is where the event-sourcing mechanism lives.
e. Infrastructure/Persistence Layer (EventStore.Infrastructure.Persistence)
– Manages database configurations, migrations, and repository implementations (such as ReadTicketRepository.cs, UserRepository.cs) that interact with the SQL Server backend.
f. Supporting Services and Helpers
– Regards cross-cutting concerns, like Http interceptors in the Angular app and security/JWT modules in the backend.
g. Test Projects
– Various test projects (EventStore.Application.Test, EventStore.Core.Test, etc.) that ensure component integrity.

##### Relationships and Interactions
- The API controllers receive HTTP requests from the frontend and forward commands/queries via the Mediator pattern (see the EventStore.Application’s Mediator components).
- Application services and handlers then invoke domain logic from EventStore.Core to handle events, validations, and business rules.
- The Infrastructure layer (Persistence and HTTP utilities) works with the application and domain layers to save and retrieve data from the MS SQL Server. Represent the SQL Server as a database component that is connected to infrastructure.
- External services are minimal in this project; however, there’s a Dockerized deployment aspect (Dockerfile files) and potential integration with Azure (as noted in the README for SQL Azure resources). If needed, add these as ancillary components.

##### Architectural Patterns and Principles
– Emphasize the use of the Mediator pattern within the application layer to decouple controllers and business logic.
– Note that the event sourcing mechanism—which includes capturing state transitions via domain events—is central to the design.
– The Angular application follows standard SPA modular structure with feature modules, routing, and component hierarchies.

##### Technologies, Frameworks, and Tools
- Angular (TypeScript, Karma, Protractor, etc.) for the frontend.
- .NET (likely .NET Core/5/6) for the backend, with ASP.NET Core for the API.
- MS SQL Server as the database backend (with support for migrations and possibly Dockerized deployment).
- Docker utilization for containerized services (as seen from the Dockerfile.EventStoreApi).
- Testing frameworks for both Angular and .NET projects.

##### Final Detailed Picture
– The separation of the frontend (view components, modules) and the backend (API controllers, mediated business logic, domain events, and persistence repositories).
– The layered architectural approach used in the .NET backend which supports an event-sourced design.
– Dependency and communication flows:
- HTTP requests from Angular to API endpoints.
- API controllers delegating tasks to the application layer (via mediator interfaces).
- Domain commands and events handling within the core, encapsulating business rules.
- Infrastructure handling for database (MSSQL) migrations and data access.
– Ancillary details like testing frameworks and containerization support.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Angular Frontend Subgraph
    subgraph "Angular Frontend"
        AF["Angular Frontend"]:::angular
        FM["Feature Modules (account,tickets,users,video,alert,home)"]:::angular
        AR["Routing Module"]:::angular
        HS1["HTTP Interceptors"]:::angular
        HS2["Supporting Services"]:::angular
        %% Angular Testing subgraph
        subgraph "Angular Testing"
            AT_E2E["e2e Tests"]:::test
            AT_UNIT["Unit Tests"]:::test
        end
    end

    %% .NET Backend Subgraph
    subgraph ".NET Backend"
        AP["API Controllers"]:::backend
        AI["API Infra & Mediator Setup"]:::backend
        AB["Application/Business Logic Layer"]:::backend
        DC["Domain Event Sourcing"]:::backend
        IP["Infrastructure/Persistence Layer"]:::backend
        SI1["HTTP Helpers"]:::backend
        SI2["General Helpers"]:::backend
        DOCK["Docker Deployment"]:::docker
        %% Backend Tests subgraph
        subgraph "Backend Tests"
            BTA["Application Tests"]:::test
            BTC["Domain Tests"]:::test
            BTIP["Persistence Tests"]:::test
            BTS["Service Tests"]:::test
            BTSH["Shared Tests"]:::test
        end
    end

    %% External Component
    DB["MS SQL Database"]:::db

    %% Connections between Angular and Backend layers
    AR -->|"HTTP_CALLS"| AP

    %% Backend internal flow
    AP -->|"delegates"| AI
    AI -->|"invokes"| AB
    AB -->|"executes"| DC
    DC -->|"persists_events"| IP
    IP <-->|"CRUD_ops"| DB
    AB -->|"utilizes"| SI1
    AB -->|"utilizes"| SI2
    DOCK --- AP

    %% Testing connections (dashed lines)
    AT_E2E -.-> AF
    AT_UNIT -.-> AF
    BTA -.-> AB
    BTC -.-> DC
    BTIP -.-> IP
    BTS -.-> SI1
    BTSH -.-> AI

    %% Click Events for Angular components
    click AF "https://github.com/verplanckeo/eventstore/tree/master/App/"
    click FM "https://github.com/verplanckeo/eventstore/tree/master/App/src/app/features/"
    click AR "https://github.com/verplanckeo/eventstore/blob/master/App/src/app/app-routing.module.ts"
    click HS1 "https://github.com/verplanckeo/eventstore/tree/master/App/src/app/seedwork/"
    click HS2 "https://github.com/verplanckeo/eventstore/tree/master/App/src/app/services/"
    click AT_E2E "https://github.com/verplanckeo/eventstore/tree/master/App/e2e/"
    click AT_UNIT "https://github.com/verplanckeo/eventstore/blob/master/App/src/test.ts"

    %% Click Events for Backend components
    click AP "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Api/"
    click AI "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Api/Infra/"
    click AB "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Application/"
    click DC "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Core/"
    click IP "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Infrastructure.Persistence/"
    click SI1 "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Infrastructure.Http/"
    click SI2 "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Infrastructure/Infra/"
    click DOCK "https://github.com/verplanckeo/eventstore/blob/master/EventStore.Api/Dockerfile.EventStoreApi"
    click BTA "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Application.Test/"
    click BTC "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Core.Test/"
    click BTIP "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Infrastructure.Persistence.Test/"
    click BTS "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Services.Test/"
    click BTSH "https://github.com/verplanckeo/eventstore/tree/master/EventStore.Shared.Test/"

    %% Styles
    classDef angular fill:#DAF7A6,stroke:#333,stroke-width:2px;
    classDef backend fill:#FFCCCB,stroke:#333,stroke-width:2px;
    classDef test fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef db fill:#F6E3CE,stroke:#333,stroke-width:2px;
    classDef docker fill:#D5F5E3,stroke:#333,stroke-width:2px;
```
