# amrut-pol-mp/httpservice architecture

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

- Interactive diagram: https://gitdiagram.com/amrut-pol-mp/httpservice
- Repository: https://github.com/amrut-pol-mp/httpservice

## Overview

##### Project type and purpose
- This repository contains two cooperating .NET Core 8.0 services:
- GrpcService – a gRPC microservice project that implements full CRUD for Organization, User, and User-Organization Association domains.
- HttpService – an ASP.NET Core Web API that exposes those same CRUD operations over HTTP by acting as a gateway/adapter to the gRPC back end.
- The README confirms that HttpService “consumes the GrpcService” via generated gRPC clients and re-exposes endpoints for external HTTP clients.

##### File structure
- Top level:
- GrpcService (not shown in file tree but referenced by README)
- HttpService – contains Configuration, Controllers, Models, Protos, and Services directories.
- HttpService/Configuration holds startup wiring (GrpcClientRegistrationExtensions, GrpcErrorHandler).
- HttpService/Protos defines the same three service contracts.
- HttpService/Controllers maps HTTP routes to domain operations (OrganizationController, UserController, etc.).
- HttpService/Services holds per-domain adapters that encapsulate gRPC client calls behind IUserService, IOrganizationService, IUserOrganizationAssociationService interfaces.
- Models/Common define shared DTOs (Pagination, ResponseId).
- No direct database access here—all persistence is delegated to GrpcService.

##### Key insights from README
- GrpcService must be up for HttpService to work.
- HttpService acts purely as an HTTP-to-gRPC proxy/gateway.
- Technology stack: .NET Core 8.0, gRPC, ASP.NET Core Web API.

##### Main components and relationships
a. External client(s):
- Web/Mobile/UI or API consumer makes HTTP requests to HttpService.
b. HttpService (API Gateway):
- Controllers receive HTTP requests.
- Controllers call domain Services (OrganizationService, UserService, UserOrganizationAssociationService).
- Domain Services use injected gRPC clients (configured in Configuration/GrpcClientRegistrationExtensions) to send RPCs to GrpcService.
c. GrpcService (gRPC microservices):
- OrganizationService, UserService, UserOrganizationAssociationService gRPC servers process commands, perform CRUD, communicate with databases (not shown in this repo).
d. Data stores (one per service or shared)—the backing databases for Organization, User, and Association data.
e. Configuration & Cross-cutting:
- Error handling via GrpcErrorHandler.
- appsettings.json for endpoints and credentials.

##### Architectural patterns and design principles
- API Gateway pattern: HttpService fronts the gRPC back end.
- Adapter/Facade pattern: domain Services adapt gRPC clients to your own interfaces.
- Dependency Injection: Startup wiring in Program.cs and GrpcClientRegistrationExtensions.
- Separation of Concerns: Controllers (HTTP logic) vs. Services (business/gRPC logic) vs. Models (DTOs).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External client
    HTTPClient["External HTTP Client"]:::external

    %% API Gateway container
    subgraph "HttpService (API Gateway)"
        direction TB

        %% Solution & Project
        Solution["API Gateway (HttpService.sln)"]:::config
        Csproj["HttpService.csproj"]:::config
        Program["Program.cs"]:::config

        %% Configuration
        subgraph "Configuration"
            direction TB
            GrpcClientReg["GrpcClientRegistrationExtensions"]:::config
            GrpcErrorHandler["GrpcErrorHandler"]:::config
            AppSettings["appsettings.json"]:::config
            AppSettingsDev["appsettings.Development.json"]:::config
            Launch["launchSettings.json"]:::config
        end

        %% Models
        subgraph "Models/Common"
            direction TB
            Pagination["Pagination"]:::model
            ResponseId["ResponseId"]:::model
        end

        %% Protos
        subgraph "Protos"
            direction TB
            OrgProto["OrganizationServices.proto"]:::proto
            UserProto["UserServices.proto"]:::proto
            AssocProto["UserOrganizationAssociationServices.proto"]:::proto
        end

        %% Controllers
        subgraph "Controllers"
            direction TB
            OrgController["OrganizationController"]:::controller
            UserController["UserController"]:::controller
            UserOrgController["UserOrganizationAssociationController"]:::controller
        end

        %% Domain Services
        subgraph "Domain Services"
            direction TB
            IOrgService["IOrganizationService"]:::service
            OrgService["OrganizationService"]:::service
            IUserService["IUserService"]:::service
            UserService["UserService"]:::service
            IUserOrgService["IUserOrganizationAssociationService"]:::service
            UserOrgService["UserOrganizationAssociationService"]:::service
        end

        %% gRPC Clients
        subgraph "gRPC Clients"
            direction TB
            OrgGrpcClient["OrganizationServicesClient"]:::grpcclient
            UserGrpcClient["UserServicesClient"]:::grpcclient
            AssocGrpcClient["UserOrganizationAssociationServicesClient"]:::grpcclient
        end
    end

    %% gRPC Back End container
    subgraph "GrpcService (gRPC Back End)"
        direction TB
        subgraph "Organization gRPC Service"
            OrgGrpcServ["OrganizationService"]:::grpcserver
        end
        subgraph "User gRPC Service"
            UserGrpcServ["UserService"]:::grpcserver
        end
        subgraph "Association gRPC Service"
            AssocGrpcServ["UserOrganizationAssociationService"]:::grpcserver
        end
    end

    %% Databases
    subgraph "Databases"
        direction TB
        OrgDB["Organization Database"]:::db
        UserDB["User Database"]:::db
        AssocDB["Association Database"]:::db
    end

    %% Connections
    HTTPClient -->|HTTP/REST| OrgController
    HTTPClient -->|HTTP/REST| UserController
    HTTPClient -->|HTTP/REST| UserOrgController

    OrgController -->|calls| IOrgService
    UserController -->|calls| IUserService
    UserOrgController -->|calls| IUserOrgService

    IOrgService -->|uses| OrgGrpcClient
    IUserService -->|uses| UserGrpcClient
    IUserOrgService -->|uses| AssocGrpcClient

    OrgGrpcClient -->|gRPC| OrgGrpcServ
    UserGrpcClient -->|gRPC| UserGrpcServ
    AssocGrpcClient -->|gRPC| AssocGrpcServ

    OrgGrpcServ -->|CRUD| OrgDB
    UserGrpcServ -->|CRUD| UserDB
    AssocGrpcServ -->|CRUD| AssocDB

    Program -->|registers| GrpcClientReg
    Program -->|uses| GrpcErrorHandler

    %% Click Events
    click Solution "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/HttpService.sln"
    click Csproj "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/HttpService.csproj"
    click Program "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Program.cs"
    click GrpcClientReg "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Configuration/GrpcClientRegistrationExtensions.cs"
    click GrpcErrorHandler "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Configuration/GrpcErrorHandler.cs"
    click AppSettings "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/appsettings.json"
    click AppSettingsDev "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/appsettings.Development.json"
    click Launch "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Properties/launchSettings.json"
    click Pagination "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Models/Common/Pagination.cs"
    click ResponseId "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Models/Common/ResponseId.cs"
    click OrgProto "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Protos/OrganizationServices.proto"
    click UserProto "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Protos/UserServices.proto"
    click AssocProto "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Protos/UserOrganizationAssociationServices.proto"
    click OrgController "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Controllers/OrganizationController.cs"
    click UserController "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Controllers/UserController.cs"
    click UserOrgController "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Controllers/UserOrganizationAssociationController.cs"
    click IOrgService "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Services/Organization/IOrganizaitonService.cs"
    click OrgService "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Services/Organization/OrganizationService.cs"
    click IUserService "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Services/User/IUserService.cs"
    click UserService "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Services/User/UserService.cs"
    click IUserOrgService "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Services/UserOrganizationAssociation/IUserOrganizationAssociationService.cs"
    click UserOrgService "https://github.com/amrut-pol-mp/httpservice/blob/main/HttpService/Services/UserOrganizationAssociation/UserOrganizationAssociationService.cs"

    %% Styles
    classDef external fill:#ffe6e6,stroke:#ff0000
    classDef config fill:#e6ffe6,stroke:#00aa00
    classDef controller fill:#e6e6ff,stroke:#0000aa
    classDef service fill:#e6ffe6,stroke:#00aa00
    classDef grpcclient fill:#fff5cc,stroke:#cc9900
    classDef grpcserver fill:#ffe6cc,stroke:#ff6600
    classDef proto fill:#fff0b3,stroke:#e6b800
    classDef db fill:#ffccff,stroke:#cc00cc
    classDef model fill:#cce5ff,stroke:#3399ff
```
