# amrut-pol-mp/grpcservice architecture

> Architecture diagram of the GitHub repository amrut-pol-mp/grpcservice, 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/grpcservice
- Repository: https://github.com/amrut-pol-mp/grpcservice

## Overview

##### Project type and purpose
- This solution contains two collaborating .NET Core 8.0 services:
- GrpcService: a gRPC microservice exposing CRUD operations for Organization, User, and User-Organization Association.
- HttpService: an ASP.NET Core Web API acting as an HTTP façade that forwards incoming REST calls to GrpcService via generated gRPC clients.
- Purpose: decouple domain logic (in GrpcService) from HTTP/REST transport (in HttpService), host SQL Server in Docker, and auto-migrate schema on startup.

##### File structure
- Top-level:
- GrpcService/
– Protos/: .proto definitions for each service
– Controllers/: gRPC endpoints implementers
– Services/: business logic interfaces + implementations per aggregate
– Data/: EF Core DbContext, Entities, Repositories
– Common/: shared helpers (DI, pagination, result wrappers)
– Migrations/: auto-generated EF Core migration snapshots
– Program.cs + appsettings*.json + launch settings
- (HttpService would mirror a standard ASP.NET Web API layout with Controllers, Clients/Protos, Startup/Program)
- Architectural pattern: layered (Presentation→Service→Repository→Database), with gRPC transport, EF Core ORM, DI.

##### README for additional insights
- Confirms a dual-project setup (GrpcService + HttpService)
- Docker-hosted SQL Server with automatic EF Core migrations
- Tech stack: .NET Core 8.0, gRPC, ASP.NET Core Web API, Docker, SQL Server

## Diagram (Mermaid)

```mermaid
flowchart TD
    direction TB

    Client["HTTP Client\n(Browser, Postman)"]:::external

    subgraph "HttpService"
        direction TB
        HttpController["HttpService.Controllers\n(ASP.NET Core Web API)"]:::http
        GrpcClient["gRPC Client\n(generated Protos)"]:::grpc
    end

    subgraph "GrpcService"
        direction TB
        subgraph "Protos"
            direction TB
            ProtoOrg["OrganizationServices.proto"]:::proto
            ProtoUser["UserServices.proto"]:::proto
            ProtoAssoc["UserOrganizationAssociationServices.proto"]:::proto
        end
        subgraph "GrpcService.Controllers"
            direction TB
            OrgCtrl["OrganizationController"]:::ctrl
            UserCtrl["UserController"]:::ctrl
            AssocCtrl["UserOrganizationAssociationController"]:::ctrl
        end
        subgraph "Service Layer"
            direction TB
            OrgSvc["OrganizationService"]:::svc
            UserSvc["UserService"]:::svc
            AssocSvc["UserOrganizationAssociationService"]:::svc
        end
        subgraph "Repository Layer"
            direction TB
            OrgRepo["OrganizationRepository"]:::repo
            UserRepo["UserRepository"]:::repo
            AssocRepo["UserOrganizationAssociationRepository"]:::repo
        end
        DbContext["GrpcServiceDbContext\n(EF Core DbContext)"]:::db
    end

    subgraph "SQL Server (Docker)"
        SQLServer["SQL Server 2022"]:::database
    end

    Client -->|REST over HTTPS| HttpController
    HttpController -->|gRPC over HTTP/2| GrpcClient

    GrpcClient -->|gRPC| OrgCtrl
    GrpcClient -->|gRPC| UserCtrl
    GrpcClient -->|gRPC| AssocCtrl

    OrgCtrl --> OrgSvc
    UserCtrl --> UserSvc
    AssocCtrl --> AssocSvc

    OrgSvc --> OrgRepo
    UserSvc --> UserRepo
    AssocSvc --> AssocRepo

    OrgRepo --> DbContext
    UserRepo --> DbContext
    AssocRepo --> DbContext

    DbContext -->|SQL| SQLServer

    click ProtoOrg "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Protos/OrganizationServices.proto"
    click ProtoUser "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Protos/UserServices.proto"
    click ProtoAssoc "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Protos/UserOrganizationAssociationServices.proto"

    click OrgCtrl "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Controllers/OrganizationController.cs"
    click UserCtrl "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Controllers/UserController.cs"
    click AssocCtrl "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Controllers/UserOrganizationAssociationController.cs"

    click DbContext "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Data/GrpcServiceDbContext.cs"

    click OrgSvc "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Services/Organization/OrganizationService.cs"
    click UserSvc "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Services/User/UserService.cs"
    click AssocSvc "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Services/UserOrganizationAssociation/UserOrganizationAssociation.cs"

    click OrgRepo "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Data/Repositories/Organization/OrganizationRepository.cs"
    click UserRepo "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Data/Repositories/User/UserRepository.cs"
    click AssocRepo "https://github.com/amrut-pol-mp/grpcservice/blob/main/GrpcService/Data/Repositories/UserOrganizationAssociation/UserOrganizationAssociationRepository.cs"

    classDef external fill:#f9f,stroke:#333,stroke-width:2px
    classDef http fill:#bbf,stroke:#333,stroke-width:1px
    classDef grpc fill:#bfb,stroke:#333,stroke-width:1px
    classDef proto fill:#fcf,stroke:#333,stroke-width:1px
    classDef ctrl fill:#ffb,stroke:#333,stroke-width:1px
    classDef svc fill:#fbf,stroke:#333,stroke-width:1px
    classDef repo fill:#fbb,stroke:#333,stroke-width:1px
    classDef db fill:#bbf,stroke:#333,stroke-width:1px
    classDef database fill:#fdd,stroke:#900,stroke-width:2px
```
