# ozgurkarahan/backend architecture

> Architecture diagram of the GitHub repository ozgurkarahan/backend, 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/ozgurkarahan/backend
- Repository: https://github.com/ozgurkarahan/backend

## Overview

##### Main Components
- API Backend – Represent the .NET Core web API (located in the src/Api.Poc.OAuth folder). Illustrate its internal structure by including:
– Controllers (e.g., TodoListController and ValuesController)
– Extensions (for configuring and handling Azure AD authentication)
– Models (such as the TodoItem class)
– Configuration files (appsettings.json / appsettings.Development.json) that determine environment settings.
- ARM Templates – Show this as an infrastructure/deployment component:
– The “webapptemplate.json” and its parameters to deploy the API as an Azure App.
– The “importapi.json” ARM template that imports the API (using the swagger definition) into an Azure API Management instance and adds the jwt validation policy.
- Swagger Documentation – Indicate that the swagger.json file in the src/swagger folder provides the API’s documentation, which is used during the API import process.
- Azure Active Directory (Azure AD) – Represent the third-party identity provider that issues tokens and handles the OAuth 2.0 authentication needed for JWT validation.

##### Relationships and Data Flow
- Client/Application Requests – Start with external clients that send requests to your API.
- API Gateway – Illustrate that these client requests first go to the Azure API Management gateway, which then forwards valid calls to the deployed web API.
- API Backend – The web API (hosted as an Azure App, deployed with the webapptemplate ARM template) receives those requests, and uses its integrated JWT validation logic (using extensions and Azure AD configurations) to authorize them.
- Swagger – Also, show that your swagger.json file plays a role in defining the API’s interface, which is used by the ARM template for API import into API Management.

##### Architectural Patterns and Design Principles
- Separation of Concerns – The web API is clearly separated into controllers, configuration, and utility/extensions handling authentication.
- Infrastructure as Code – The use of ARM templates demonstrates that the deployment and integration with Azure API Management are automated, emphasizing repeatable, consistent infrastructure deployment.
- Secure Gateway Pattern – The API Management instance acts as a secure API gateway: applying policies (such as JWT validation) and routing requests to the back-end service only after proper authorization.

– Client → Azure API Management → Azure App (API Backend)
– Azure API Management ← uses swagger to import API and applies JWT policies.
– API Backend ↔ Azure AD (for token validation)
– Use a different style for deployment/infrastructure elements (ARM Templates).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client / External Applications"]:::client
    B["Azure API Management"]:::apimgmt
    C["API Backend (.NET Core API) [Azure App]"]:::apiback
    D["Azure Active Directory"]:::azuread

    subgraph "API Backend (.NET Core API) Components"
        C1["Controllers (TodoListController, ValuesController)"]:::controllers
        C2["Authentication Extensions (AzureAD)"]:::extensions
        C3["Models (TodoItem)"]:::models
        C4["Configuration File (appsettings.json)"]:::config
        C5["Configuration File (appsettings.Development.json)"]:::config
    end

    subgraph "ARM Templates (Infrastructure as Code)"
        T1["API App Deployment Template"]:::armtemplate
        T2["API App Deployment Parameters"]:::armtemplate
        T3["API Import Template"]:::armtemplate
        T4["API Import Parameters"]:::armtemplate
    end

    E["Swagger Documentation (swagger.json)"]:::swagger

    %% External Flow
    A -->|"requests"| B
    B -->|"forwards"| C
    C -->|"JWT-validation"| D

    %% ARM Templates influence
    T1 -->|"deploys"| C
    T3 -->|"imports API into"| B
    E -->|"provides-API-definition-to"| T3

    %% Internal API Backend interactions
    C1 -->|"uses"| C3
    C1 -->|"calls"| C2
    C2 -->|"reads"| C4

    %% Click Events
    click C "https://github.com/ozgurkarahan/backend/blob/master/src/Api.Poc.OAuth"
    click C1 "https://github.com/ozgurkarahan/backend/tree/master/src/Api.Poc.OAuth/Controllers"
    click C2 "https://github.com/ozgurkarahan/backend/tree/master/src/Api.Poc.OAuth/Extensions"
    click C3 "https://github.com/ozgurkarahan/backend/tree/master/src/Api.Poc.OAuth/Model"
    click C4 "https://github.com/ozgurkarahan/backend/blob/master/src/Api.Poc.OAuth/appsettings.json"
    click C5 "https://github.com/ozgurkarahan/backend/blob/master/src/Api.Poc.OAuth/appsettings.Development.json"
    click T1 "https://github.com/ozgurkarahan/backend/blob/master/armtemplates/webapptemplate.json"
    click T2 "https://github.com/ozgurkarahan/backend/blob/master/armtemplates/webapptemplate.parameters.json"
    click T3 "https://github.com/ozgurkarahan/backend/blob/master/armtemplates/importapi.json"
    click T4 "https://github.com/ozgurkarahan/backend/blob/master/armtemplates/importapi.parameters.json"
    click E "https://github.com/ozgurkarahan/backend/blob/master/src/swagger/swagger.json"

    %% Styles
    classDef client fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef apimgmt fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px;
    classDef apiback fill:#FFECB3,stroke:#F57F17,stroke-width:2px;
    classDef azuread fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
    classDef armtemplate fill:#FFE0B2,stroke:#E65100,stroke-width:2px;
    classDef swagger fill:#B2EBF2,stroke:#00695C,stroke-width:2px;
    classDef controllers fill:#E1F5FE,stroke:#0277BD,stroke-width:1px;
    classDef extensions fill:#F3E5F5,stroke:#6A1B9A,stroke-width:1px;
    classDef models fill:#FFF9C4,stroke:#F9A825,stroke-width:1px;
    classDef config fill:#ECEFF1,stroke:#37474F,stroke-width:1px;
```
