# thisisnabi/blogger architecture

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

- Interactive diagram: https://gitdiagram.com/thisisnabi/blogger
- Repository: https://github.com/thisisnabi/blogger

## Overview

##### Main Components
- API Layer (Blogger.APIs): This layer exposes HTTP endpoints grouped by features (Articles, Comments, Subscribers) and serves as the entry point for client requests. It includes endpoints, mapping profiles, validators, and integrates with dependency injection.
- Application Layer (Blogger.Application): Contains business logic and handles use cases via commands and queries. This layer implements handlers for operations like creating articles, making comments, and managing drafts.
- Domain Layer (Blogger.Domain): Models core business entities and aggregates such as ArticleAggregate, CommentAggregate, and SubscriberAggregate. It also encapsulates domain rules, events, and strongly-typed IDs.
- Building Blocks (Blogger.BuildingBlocks): Provides shared abstractions like AggregateRoot, Entity, ValueObject, and domain exception classes that are used across the domain.
- Infrastructure Layer (Blogger.Infrastructure): Handles persistence (using EF Core), repository implementations, external services (email sending, link generation), and configurations. This layer interacts with the database and other external systems.
- Tests (Unit, Integration, Functional, and Load Testing): Although not plotted in the runtime architecture, these folders demonstrate that significant test coverage (unit, integration, functional) supports the application.

##### Relationships and Data Flow
- Client/Consumer (could be the linked Blogger.UI or any client application) sends HTTP requests, which are first received by the API Layer.
- The API Layer routes requests to appropriate endpoints that use dependency injection to call handlers in the Application Layer.
- The Application Layer then processes these requests by executing commands/queries. It coordinates with the Domain Layer to enact business rules and processes domain events.
- The Domain Layer contains the core business entities and logic, making sure the invariant rules of the blog (e.g., article status or comment approval) are enforced.
- Persistence and external integrations are handled by the Infrastructure Layer. Repositories in Infrastructure implement domain repository interfaces to persist the state in the SQL database via EF Core.
- Shared abstractions in Building Blocks support common functionality across layers (e.g., base classes and exception handling).

##### Architectural Patterns and Design Principles
- Clean Architecture / Onion Architecture: Layers are clearly separated, ensuring that high-level policy (Domain and Application logic) is independent of lower-level concerns (Infrastructure and API).
- Domain-Driven Design (DDD): The domain model, aggregates, value objects, and domain events are clearly defined to enforce business rules.
- CQRS: Commands and queries are used in the Application Layer to separate write and read operations.
- Dependency Injection: Each layer leverages DI for inversion of control, as evidenced by the multiple DependencyInjection.cs files.
- Testing: A robust set of unit, integration, and functional tests promote confidence in each layer’s behavior.

##### Incorporate Relevant Technologies, Frameworks, or Libraries
- ASP.NET Core 8 serves as the framework for the API.
- EF Core is used in the Infrastructure Layer for persistence.
- Mapping libraries (e.g., AutoMapper, based on the “MappingProfile” files) are in use to convert between domain objects and data transfer objects.
- The project structure hints at modular separation (multiple projects in the solution) to maintain bounded contexts and clean separation.

##### Instructing the Principal Software Engineer on What
- Within the API layer, further subdivide into endpoints—group them by functional areas such as Articles, Comments, and Subscribers.
- Callouts or side notes emphasizing the use of CQRS (separating commands and queries) as well as key DDD elements (aggregates, domain events, etc.).
- Don’t forget to include the dependency injection mechanism that ties these layers together, which is set up in the Startup/Program files and various DependencyInjection.cs files.

- At the core, place “Blogger.Domain” and “Blogger.BuildingBlocks” to reflect the domain rules and foundational elements.
- On the right or bottom, include “Blogger.Infrastructure” that handles persistence via EF Core and interacts with external services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Clients/Consumers"]:::client

    subgraph "API Layer"
        API["Blogger.APIs"]:::api
        Art["Articles Endpoint"]:::api
        Comm["Comments Endpoint"]:::api
        Subs["Subscribers Endpoint"]:::api
        API -->|"Includes"| Art
        API -->|"Includes"| Comm
        API -->|"Includes"| Subs
    end

    subgraph "Application Layer"
        App["Blogger.Application"]:::application
    end

    subgraph "Domain Core"
        Domain["Blogger.Domain"]:::domain
        Blocks["Blogger.BuildingBlocks"]:::buildingblocks
        Domain -->|"Uses_BuildingBlocks"| Blocks
    end

    subgraph "Infrastructure Layer"
        Infra["Blogger.Infrastructure"]:::infrastructure
        Ext["External Services"]:::infrastructure
        Infra -->|"ExternalIntegration"| Ext
    end

    Tests["Tests(Unit/Integration/Functional)"]:::tests

    Client -->|"HTTP_Request"| API
    Art -->|"Calls"| App
    Comm -->|"Calls"| App
    Subs -->|"Calls"| App
    App -->|"Processes_CommandQuery"| Domain
    Domain -->|"RepositoryCall"| Infra
    Infra -->|"Response"| Domain

    App ---|"TestedBy"| Tests
    API ---|"TestedBy"| Tests
    Domain ---|"TestedBy"| Tests
    Infra ---|"TestedBy"| Tests

    click API "https://github.com/thisisnabi/blogger/blob/main/src/Blogger.APIs"
    click App "https://github.com/thisisnabi/blogger/blob/main/src/Blogger.Application"
    click Domain "https://github.com/thisisnabi/blogger/blob/main/src/Blogger.Domain"
    click Blocks "https://github.com/thisisnabi/blogger/blob/main/src/Blogger.BuildingBlocks"
    click Infra "https://github.com/thisisnabi/blogger/blob/main/src/Blogger.Infrastructure"
    click Tests "https://github.com/thisisnabi/blogger/tree/main/tests"

    classDef client fill:#fadbd8,stroke:#c0392b,stroke-width:2px;
    classDef api fill:#f9e79f,stroke:#d68910,stroke-width:2px;
    classDef application fill:#aed6f1,stroke:#2980b9,stroke-width:2px;
    classDef domain fill:#abebc6,stroke:#27ae60,stroke-width:2px;
    classDef buildingblocks fill:#d7bde2,stroke:#8e44ad,stroke-width:2px;
    classDef infrastructure fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef tests fill:#d5f5e3,stroke:#1e8449,stroke-width:2px;
```
