# revarine/eventsapi architecture

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

- Interactive diagram: https://gitdiagram.com/revarine/eventsapi
- Repository: https://github.com/revarine/eventsapi

## Overview

Based on your provided file tree and README, this is a .NET-based Events Management API that employs a layered architecture (with explicit separations for API controllers, application logic using CQRS patterns, domain models, and infrastructure concerns such as data access). The project is intended for managing events—allowing users to create, update, retrieve, and delete event-related information, and it is containerizable via Docker.

##### Main Components
- API Layer: Represented by the Events.API project. This layer contains controllers (e.g., AdminController, AuthController, UsersController, etc.) which expose endpoints for client interactions.
- Application Layer: Captured in the Events.Application project. It implements the CQRS pattern with separate folders for commands, queries, and notifications concerning events, event participants, and users. This layer contains the business logic and command/query handlers.
- Domain Layer: Found in the Events.Domain project. This includes domain entities (e.g., Event, EventParticipant, User) and custom exceptions that enforce business rules.
- Infrastructure Layer: Implemented in the Events.Infrastructure project. It handles data persistence (using SQLite) with the repositories for events, event participants, and users. It also contains migrations and configurations to set up the database.
- Testing: Represent the tests located in the tests directory (Events.UnitTests) for domain, application, and infrastructure unit tests.
- External/Supporting Services:
- Docker and Docker Compose for containerized deployment.
- External integrations for email service, JWT, and password handling (found in common services within the application).

##### Relationships and Data Flow
- Controllers then invoke application layer components (CQRS commands and queries) to process requests.
- The application layer interacts with the domain layer to enforce business rules and with the infrastructure layer (repositories) to persist or retrieve data.
- Infrastructure components interact directly with the SQLite database.
- Feedback (such as error handling, as implemented in global exception middleware) that returns results to the client.
- For containerized deployment, show how Docker (using docker-compose) encapsulates the API, persists data via volumes, and how logs or external services are accessed.

##### Architectural Patterns and Design Principles
- Layered Architecture: Each layer (API, Application, Domain, Infrastructure) is isolated to ensure separation of concerns.
- CQRS Pattern: Commands and queries are segregated. For instance, the Events.Application/CQRS folder depicts commands for creating, updating, and deleting events and queries for retrieving data.
- Dependency Injection: Both the application and infrastructure layers use dependency injection (as seen in the DependencyInjection.cs files), promoting modularity.
- Repository Pattern & Unit of Work: Seen in the infrastructure code, these patterns abstract the details of data persistence.
- Middleware for global exception handling in the API (GlobalExceptionHandlingMiddleware) shows cross-cutting concerns addressed centrally.

##### Relevant Technologies & Frameworks
- .NET 8.0 for the API.
- SQLite as the data store.
- Docker and Docker Compose for container orchestration.
- Swagger for API documentation.
- AutoMapper for DTO mapping (in the application common services).
- Testing frameworks using dotnet test commands.

##### Elements
- Clear Labels: Each component (e.g., “Events.API – Controllers”, “Events.Application – CQRS Handlers”, “Events.Domain – Entities”, “Events.Infrastructure – Repositories”, “SQLite Database”, “Docker Container”) should be clearly marked.
- From clients (web/mobile) → API endpoints.
- From controllers → Application layer (commands/queries).
- From Application layer → Domain and Infrastructure layers.
- From Infrastructure → Database.

- Next, expand on details in the API and Application layers if needed by breaking down key components like the different command/query handlers and how they interact.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client("Client (Web/Mobile)"):::external

    subgraph "API Layer"
        API("Events.API - Controllers"):::api
        Middleware("Global Exception Handling Middleware"):::api
    end

    subgraph "Application Layer"
        CQRS("Events.Application - CQRS Handlers"):::application
        Common("Events.Application - Common Services & Validators"):::application
    end

    subgraph "Domain Layer"
        Domain("Events.Domain - Domain Models & Exceptions"):::domain
    end

    subgraph "Infrastructure Layer"
        Infra("Events.Infrastructure - Data Persistence & Repositories"):::infrastructure
        Database("SQLite Database"):::database
    end

    subgraph "Testing"
        Testing("Events.UnitTests - Unit Tests"):::testing
    end

    subgraph "Docker Containerization"
        Docker1("Dockerfile"):::docker
        Docker2("docker-compose.yml"):::docker
    end

    Client -->|"HTTP_Request"| API
    API -->|"invokes"| CQRS
    API -->|"handles"| Middleware
    Middleware -->|"error_response"| Client
    CQRS -->|"processes"| Domain
    CQRS -->|"persists_or_retrieves"| Infra
    CQRS -->|"utilizes"| Common
    Infra -->|"reads/writes"| Database
    Testing -->|"tests"| Domain
    Testing -->|"tests"| CQRS
    Testing -->|"tests"| Infra
    Docker1 -->|"builds"| API
    Docker2 -->|"orchestrates"| API
    Docker2 -->|"manages"| Infra

    click API "https://github.com/revarine/eventsapi/tree/main/src/Events.API/Controllers"
    click Middleware "https://github.com/revarine/eventsapi/blob/main/src/Events.API/Middlewares/GlobalExceptionHandlingMiddleware.cs"
    click CQRS "https://github.com/revarine/eventsapi/tree/main/src/Events.Application/CQRS"
    click Common "https://github.com/revarine/eventsapi/tree/main/src/Events.Application/Common/Services"
    click Domain "https://github.com/revarine/eventsapi/blob/main/src/Events.Domain"
    click Infra "https://github.com/revarine/eventsapi/blob/main/src/Events.Infrastructure"
    click Testing "https://github.com/revarine/eventsapi/blob/main/tests/Events.UnitTests"
    click Docker1 "https://github.com/revarine/eventsapi/tree/main/Dockerfile"
    click Docker2 "https://github.com/revarine/eventsapi/blob/main/docker-compose.yml"

    classDef external fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef api fill:#FF9999,stroke:#CC0000,stroke-width:2px;
    classDef application fill:#99CCFF,stroke:#003399,stroke-width:2px;
    classDef domain fill:#99FF99,stroke:#009900,stroke-width:2px;
    classDef infrastructure fill:#FFD699,stroke:#FF6600,stroke-width:2px;
    classDef database fill:#66CCCC,stroke:#003333,stroke-width:2px;
    classDef testing fill:#CCCCCC,stroke:#666666,stroke-width:2px;
    classDef docker fill:#CCFFCC,stroke:#009900,stroke-width:2px;
```
