# wuot-software-engineering-group/petshareapp architecture

> Architecture diagram of the GitHub repository wuot-software-engineering-group/petshareapp, 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/wuot-software-engineering-group/petshareapp
- Repository: https://github.com/wuot-software-engineering-group/petshareapp

## Overview

##### Project Type and Purpose
- This is a backend API application that supports a pet-sharing platform. Its purpose is to expose endpoints for managing entities like pets, adopters, announcements, shelters, and applications.
- The system uses a code-first relational SQL database with Entity Framework Core and employs OAuth and JWT for authentication and authorization.

##### Main Components
a. Domain Layer:
- Contains core business entities (e.g., Address, Admin, Adopter, Announcement, Pet, Shelter, User, etc.) and repository abstraction interfaces.
- It as the “Business / Domain Model.” This is the foundation for business logic.

b. Data Persistence Layer:
- Includes the DbContext, migrations, and concrete Repository implementations. These components are responsible for interacting with the SQL database.
- Use of Entity Framework Core with the Code First approach.

c. Cross-Cutting Concerns:
- Consists of DTOs, enums, and utilities that support data transformation, mapping, and common features across layers.
- This as “DTOs and Shared Utilities.”

d. Services Layer:
- Contains business logic implementations like AdopterService, AnnouncementService, PetService, MailService, etc.
- Acts as the “Business Logic” layer that orchestrates operations between the domain and data persistence.
- Service Wrapper that aggregates individual service calls.

e. Presentation / API Layer:
- Consists of the ASP.NET Core web API (controllers in Petshare.Presentation and Petshare.WebAPI). This layer exposes the HTTP endpoints.
- It as “API / Web Interface.”
- That it integrates authentication/authorization configurations and routing.

f. CI/CD and DevOps:
- Although not part of the runtime system, the GitHub workflows (in .github/workflows) indicate continuous integration/deployment processes.

##### Relationships and Interactions
- Front-facing HTTP requests enter through the Presentation/API layer (controllers).
- Controllers call the Services Layer to execute business logic.
- Services use Domain entities and interact with the Data Persistence Layer (repositories) to fetch/store data.
- The Data Persistence Layer communicates with the relational SQL database using Entity Framework Core.
- Cross-cutting utilities (DTO mappings, enums, etc.) are used along each of these layers to ensure consistent data transformation and management.
- External integration points such as authentication (OAuth, JWT) should be noted as part of the API configuration.
- CI/CD flows show automated testing and deployment pipelines feeding into the application’s lifecycle.

##### Architectural Patterns
- Layered (n-tier) architecture: clearly separated concerns between API, Services, Domain, and Data Access.
- Use of the Repository pattern for data abstraction.
- Mapping configurations for converting between DTOs and domain models.
- Emphasis on testability with dedicated Unit Test projects.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation / API Layer
    subgraph "Presentation / API Layer"
        A1["Petshare.Presentation (Controllers)"]:::api
        A2["Petshare.WebAPI (API Configuration)"]:::api
        A3["OAuth/JWT (Authentication)"]:::api
    end

    %% Services Layer
    subgraph "Services Layer"
        S1["Petshare.Services (Business Logic)"]:::services
        S2["Petshare.Services.Abstract (Interfaces)"]:::services
    end

    %% Domain Layer
    subgraph "Domain Layer"
        D["Domain Models (Business Entities)"]:::domain
    end

    %% Data Persistence Layer
    subgraph "Data Persistence Layer"
        DP["Petshare.DataPersistence (EF Core & DbContext)"]:::data
        R["Repositories (Concrete Implementations)"]:::data
    end

    %% Shared Utilities
    subgraph "Shared Utilities"
        X["DTOs & Shared Utilities"]:::shared
    end

    %% Infrastructure
    subgraph "Infrastructure"
        DB["SQL Database"]:::database
    end

    %% CI/CD & DevOps
    subgraph "CI/CD & DevOps"
        CI["GitHub Workflows (CI/CD)"]:::devops
    end

    %% Connections
    %% API Layer to Services Layer
    A1 -->|"routesTo"| S1
    A2 -->|"routesTo"| S1
    A3 -->|"secures"| A1

    %% Services interactions with Domain and Data Persistence
    S1 -->|"manipulates"| D
    S1 -->|"callsRepository"| R

    %% Data Persistence internal relation
    DP -->|"providesEFCore"| R
    R -->|"executesQuery"| DB

    %% Shared Utilities used across layers
    D ---|"usesUtilities"| X
    S1 ---|"usesUtilities"| X
    DP ---|"usesUtilities"| X

    %% CI/CD triggering deployment (external process)
    CI -->|"deploys"| A1

    %% Click Events
    click D "https://github.com/wuot-software-engineering-group/petshareapp/tree/main/Src/Domain"
    click DP "https://github.com/wuot-software-engineering-group/petshareapp/blob/main/Src/Petshare.DataPersistence"
    click R "https://github.com/wuot-software-engineering-group/petshareapp/tree/main/Src/Petshare.DataPersistence/Repositories"
    click X "https://github.com/wuot-software-engineering-group/petshareapp/blob/main/Src/Petshare.CrossCutting"
    click S1 "https://github.com/wuot-software-engineering-group/petshareapp/blob/main/Src/Petshare.Services"
    click S2 "https://github.com/wuot-software-engineering-group/petshareapp/blob/main/Src/Petshare.Services.Abstract"
    click A1 "https://github.com/wuot-software-engineering-group/petshareapp/blob/main/Src/Petshare.Presentation"
    click A2 "https://github.com/wuot-software-engineering-group/petshareapp/blob/main/Src/Petshare.WebAPI"
    click CI "https://github.com/wuot-software-engineering-group/petshareapp/tree/main/.github/workflows"

    %% Styles
    classDef api fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef services fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef domain fill:#FFFFE0,stroke:#FFD700,stroke-width:2px;
    classDef data fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px;
    classDef shared fill:#D3D3D3,stroke:#A9A9A9,stroke-width:2px;
    classDef devops fill:#F08080,stroke:#CD5C5C,stroke-width:2px;
    classDef database fill:#E0FFFF,stroke:#00CED1,stroke-width:2px;
```
