# samuelgunda/nowaround-backend architecture

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

- Interactive diagram: https://gitdiagram.com/samuelgunda/nowaround-backend
- Repository: https://github.com/samuelgunda/nowaround-backend

## Overview

##### Main Components

A. Client Layer (External)
- Web Clients
- Mobile Clients

B. API Gateway Layer
- Azure-hosted Web API (.NET Core 9)
- Authentication/Authorization middleware (Auth0)
- Global Exception Handler

C. Application Core
- Application Services Layer
- Domain Layer
- Infrastructure Layer

D. External Services
- Mapbox Integration
- Auth0 Service
- Azure Storage
- Email Service

E. Database Layer
- MS SQL Server
- Entity Framework Core

##### Component Relationships and Architecture

**[Client Layer] → [API Gateway Layer] → [Application Core] → [Infrastructure] → [Database]**
- ↘ [External Services]

- Blue: API Gateway components
- Green: Application Core components
- Yellow: External services
- Gray: Infrastructure components
- Red: Database components

##### Detailed Component Breakdown

A. API Gateway Layer (Blue)
- Controllers:
- Establishment
- Event
- Post
- Review
- User
- MonthlyStatistic
- Middleware:
- Authentication
- Exception Handling
- CORS

B. Application Core (Green)
- Services:
- EstablishmentService
- EventService
- PostService
- ReviewService
- UserService
- MonthlyStatisticService
- Domain Models:
- Establishment
- Event
- Post
- Review
- User
- Business Hours
- Menu

C. Infrastructure Layer (Gray)
- Repositories
- Database Context
- External Service Implementations
- Configurations

D. External Services Integration (Yellow)
- Auth0 Authentication
- Mapbox Services
- Azure Storage
- Email Service

##### Additional Elements

- Azure Deployment Pipeline
- CI/CD Workflow
- Testing Infrastructure
- Storage Services

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef client fill:#e1e1e1,stroke:#333,stroke-width:2px
    classDef api fill:#5c9eff,stroke:#333,stroke-width:2px
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef external fill:#ffeb3b,stroke:#333,stroke-width:2px
    classDef infra fill:#d3d3d3,stroke:#333,stroke-width:2px
    classDef db fill:#ff9999,stroke:#333,stroke-width:2px
    
    %% Client Layer
    subgraph Clients
        WC[Web Clients]:::client
        MC[Mobile Clients]:::client
    end

    %% API Gateway Layer
    subgraph APIGateway["API Gateway Layer"]
        API[".NET Core 9 Web API"]:::api
        click API "https://github.com/SamuelGunda/NowAround-Backend/blob/main/NowAround.WebApi"
        
        subgraph Controllers
            EC["Establishment Controller"]:::api
            EVC["Event Controller"]:::api
            PC["Post Controller"]:::api
            RC["Review Controller"]:::api
            UC["User Controller"]:::api
            MC["Monthly Statistics Controller"]:::api
        end
        click Controllers "https://github.com/SamuelGunda/NowAround-Backend/tree/main/NowAround.WebApi/Controllers"
        
        MW["Middleware"]:::api
        click MW "https://github.com/SamuelGunda/NowAround-Backend/tree/main/NowAround.WebApi/Middleware"
        
        Auth["Authentication"]:::api
        click Auth "https://github.com/SamuelGunda/NowAround-Backend/blob/main/NowAround.WebApi/Extensions/AuthenticationExtensions.cs"
    end

    %% Application Core
    subgraph AppCore["Application Core"]
        subgraph Services
            ES["Establishment Service"]:::core
            EVS["Event Service"]:::core
            PS["Post Service"]:::core
            RS["Review Service"]:::core
            US["User Service"]:::core
            MS["Monthly Statistics Service"]:::core
        end
        click Services "https://github.com/SamuelGunda/NowAround-Backend/tree/main/NowAround.Application/Services"
        
        subgraph Domain
            DM["Domain Models"]:::core
            DI["Domain Interfaces"]:::core
        end
        click DM "https://github.com/SamuelGunda/NowAround-Backend/tree/main/NowAround.Domain/Models"
        click DI "https://github.com/SamuelGunda/NowAround-Backend/tree/main/NowAround.Domain/Interfaces"
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        Repo["Repositories"]:::infra
        click Repo "https://github.com/SamuelGunda/NowAround-Backend/tree/main/NowAround.Infrastructure/Repository"
        
        DBContext["Database Context"]:::infra
        click DBContext "https://github.com/SamuelGunda/NowAround-Backend/blob/main/NowAround.Infrastructure/Context/AppDbContext.cs"
        
        Config["Entity Configurations"]:::infra
        click Config "https://github.com/SamuelGunda/NowAround-Backend/tree/main/NowAround.Infrastructure/Configurations"
    end

    %% External Services
    subgraph ExternalServices["External Services"]
        Auth0["Auth0 Service"]:::external
        click Auth0 "https://github.com/SamuelGunda/NowAround-Backend/tree/main/NowAround.Infrastructure/Services/Auth0"
        
        Mapbox["Mapbox Integration"]:::external
        click Mapbox "https://github.com/SamuelGunda/NowAround-Backend/tree/main/NowAround.Infrastructure/Services/Mapbox"
        
        Storage["Azure Storage"]:::external
        click Storage "https://github.com/SamuelGunda/NowAround-Backend/blob/main/NowAround.Infrastructure/Context/StorageContext.cs"
        
        Email["Email Service"]:::external
    end

    %% Database Layer
    subgraph Database
        SQL["MS SQL Server"]:::db
        EF["Entity Framework Core"]:::db
        Migrations["Migrations"]:::db
        click Migrations "https://github.com/SamuelGunda/NowAround-Backend/tree/main/NowAround.Infrastructure/Migrations"
    end

    %% Testing Infrastructure
    subgraph Testing
        UT["Unit Tests"]:::infra
        IT["Integration Tests"]:::infra
        AT["Application Tests"]:::infra
        InfraT["Infrastructure Tests"]:::infra
        click UT "https://github.com/SamuelGunda/NowAround-Backend/blob/main/tests/NowAround.Api.UnitTests"
        click IT "https://github.com/SamuelGunda/NowAround-Backend/blob/main/tests/NowAround.IntegrationTests"
        click AT "https://github.com/SamuelGunda/NowAround-Backend/blob/main/tests/NowAround.Application.UnitTests"
        click InfraT "https://github.com/SamuelGunda/NowAround-Backend/blob/main/tests/NowAround.Infrastructure.UnitTests"
    end

    %% CI/CD
    subgraph CICD["CI/CD Pipeline"]
        AP["Azure Pipeline"]:::infra
        DP["Deployment Pipeline"]:::infra
        click AP "https://github.com/SamuelGunda/NowAround-Backend/blob/main/.github/workflows/azure-pipeline.yaml"
        click DP "https://github.com/SamuelGunda/NowAround-Backend/blob/main/.github/workflows/deploy-pipeline.yaml"
    end

    %% Relationships
    WC & MC --> API
    API --> Controllers
    Controllers --> Services
    Services --> Domain
    Domain --> Infrastructure
    Infrastructure --> Database
    API --> ExternalServices
    Infrastructure --> ExternalServices
```
