# eduardopires/equinoxproject architecture

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

- Interactive diagram: https://gitdiagram.com/eduardopires/equinoxproject
- Repository: https://github.com/eduardopires/equinoxproject

## Overview

##### Project Type and Purpose
- The Equinox Project is a full-stack, open-source .NET Core application.
- Its goal is to showcase best practices with technologies such as ASP.NET (MVC and WebAPI), Entity Framework Core, ASP.NET Identity, AutoMapper, MediatR, and more.
- The project implements Domain Driven Design (DDD), CQRS, Event Sourcing, and Cross-Cutting concerns via a modular, layered architecture.

##### Analyzing the File Structure
- The solution (Equinox.sln) is subdivided into multiple projects under the src directory, indicating a clearly separated architecture:
- Presentation Layer:
- Equinox.Services.Api – Offers RESTful API endpoints (with JWT, Swagger, etc.)
- Equinox.UI.Web – Implements the web presentation using ASP.NET MVC (includes Identity areas for user management).
- Application Layer:
- Equinox.Application – Contains application services, AutoMapper configurations, view models, and event normalizers.
- Domain Layer:
- Equinox.Domain.Core & Equinox.Domain – Hold domain models, commands, events, validations, and domain interfaces. This layer encapsulates the business rules, notifications, and domain events.
- Infrastructure/Cross Cutting:
- Equinox.Infra.CrossCutting.* – Handles messaging via an in-memory bus, identity (with custom JWT and ASP.NET Identity), and dependency injection (IoC).
- Infrastructure/Data:
- Equinox.Infra.Data – Manages data persistence including the Entity Framework context, migrations, repository implementations, and event sourcing via a SQL event store.
- Additional folders and scripts such as the SQL folder (for database setup) and Dockerfiles (for container deployments) indicate deployment and setup considerations.

##### Key System Components and Their Relationships
- Presentation Components:
- Equinox.Services.Api (API endpoints) and Equinox.UI.Web (web frontend) that allow client interaction.
- Application Services:
- Equinox.Application that orchestrates operations by mapping view models to domain commands and events.
- Domain Logic:
- Equinox.Domain (commands, events, and validations) and Equinox.Domain.Core handling business logic following DDD principles.
- Infrastructure and Data Persistence:
- Equinox.Infra.Data implements repositories, unit of work and event sourcing.
- Equinox.Infra.CrossCutting components handle aspects like identity, authorization, and dependency injection.
- Cross-Cutting Services:
- Identity (in Infra.CrossCutting.Identity), and In-memory Bus (for event publication using MediatR).

The typical data flow is as follows:
- The client (via browser or mobile) triggers a request to either the UI project or the API project.
- Controllers (in API or UI) call application services in Equinox.Application.
- The application services use domain classes (from Equinox.Domain) to execute business logic.
- Repositories from Equinox.Infra.Data access the database and store events (supporting event sourcing) and state.
- In addition, Domain Events are dispatched through a messaging bus (using MediatR, located in CrossCutting.Bus) to react asynchronously where required.
- Authentication and authorization aspects are supported by the ASP.NET Identity modules within the Infra.CrossCutting.Identity area.

##### Architectural Patterns and Technologies
- DDD, CQRS, Unit of Work, and Repository patterns serve as a backbone.
- Event Sourcing is implemented to track domain events.
- Dependency Injection is set up via the native .NET Core DI container and custom IoC registrations in Equinox.Infra.CrossCutting.IoC.
- AutoMapper is used to map between domain models and view models.
- MediatR plays a vital role for handling commands, notifications, and events.
- Swagger is used for API documentation and JWT is employed for token-based authentication.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Global Client
    Client["Client (Browsers, Mobile)"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        API["API (Equinox.Services.Api)"]:::presentation
        UI["Web UI (Equinox.UI.Web)"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        App["Application Services (Equinox.Application)"]:::application
        Auto["AutoMapper configurations"]:::application
        AppImpl["Application service implementations"]:::application
    end

    %% Domain Layer
    subgraph "Domain Layer"
        DomainModels["Domain Models (Equinox.Domain)"]:::domain
        DomainCore["Domain Core (Equinox.Domain.Core)"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        Data["Data Persistence (Equinox.Infra.Data)"]:::infrastructure
        EF["EF Core Context"]:::infrastructure
        Repo["Repository Implementations"]:::infrastructure
        Bus["Messaging Bus (Equinox.Infra.CrossCutting.Bus)"]:::infrastructure

        subgraph "Identity & Authorization"
            Identity["Identity & Auth (Equinox.Infra.CrossCutting.Identity)"]:::infrastructure
            JWT["API JWT Settings"]:::infrastructure
            Auth["Authorization Utilities"]:::infrastructure
        end

        IoC["Dependency Injection (IoC)"]:::infrastructure
    end

    %% Connections
    Client -->|"sends_request"| API
    Client -->|"sends_request"| UI

    API -->|"calls"| App
    UI  -->|"calls"| App

    App -->|"maps_delegates"| DomainModels
    App -->|"maps_delegates"| DomainCore

    DomainModels -->|"persist_changes"| Data
    DomainCore  -->|"persist_changes"| Data

    Data --> EF
    Data --> Repo

    DomainCore -->|"publishes_events"| Bus

    API -->|"uses_auth"| Identity
    UI  -->|"uses_auth"| Identity

    App ---|"configured_by"| IoC
    DomainModels ---|"configured_by"| IoC
    DomainCore ---|"configured_by"| IoC

    %% Click Events
    click API "https://github.com/eduardopires/equinoxproject/blob/master/src/Equinox.Services.Api"
    click UI "https://github.com/eduardopires/equinoxproject/blob/master/src/Equinox.UI.Web"
    click App "https://github.com/eduardopires/equinoxproject/blob/master/src/Equinox.Application"
    click Auto "https://github.com/eduardopires/equinoxproject/tree/master/src/Equinox.Application/AutoMapper"
    click AppImpl "https://github.com/eduardopires/equinoxproject/tree/master/src/Equinox.Application/Services"
    click DomainModels "https://github.com/eduardopires/equinoxproject/blob/master/src/Equinox.Domain"
    click DomainCore "https://github.com/eduardopires/equinoxproject/blob/master/src/Equinox.Domain.Core"
    click Data "https://github.com/eduardopires/equinoxproject/blob/master/src/Equinox.Infra.Data"
    click EF "https://github.com/eduardopires/equinoxproject/tree/master/src/Equinox.Infra.Data/Context"
    click Repo "https://github.com/eduardopires/equinoxproject/tree/master/src/Equinox.Infra.Data/Repository"
    click Bus "https://github.com/eduardopires/equinoxproject/blob/master/src/Equinox.Infra.CrossCutting.Bus"
    click Identity "https://github.com/eduardopires/equinoxproject/blob/master/src/Equinox.Infra.CrossCutting.Identity"
    click JWT "https://github.com/eduardopires/equinoxproject/tree/master/src/Equinox.Infra.CrossCutting.Identity/API"
    click Auth "https://github.com/eduardopires/equinoxproject/tree/master/src/Equinox.Infra.CrossCutting.Identity/Authorization"
    click IoC "https://github.com/eduardopires/equinoxproject/blob/master/src/Equinox.Infra.CrossCutting.IoC"

    %% Styles
    classDef external fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef presentation fill:#ffe0b2,stroke:#e65100,stroke-width:2px;
    classDef application fill:#c5e1a5,stroke:#33691e,stroke-width:2px;
    classDef domain fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef infrastructure fill:#d1c4e9,stroke:#311b92,stroke-width:2px;
```
