# carteruysl/grpc-fiber architecture

> Architecture diagram of the GitHub repository carteruysl/grpc-fiber, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/carteruysl/grpc-fiber
- Repository: https://github.com/carteruysl/grpc-fiber

## Overview

##### Project type and purpose
- This is a small Go‐based microservice demo that exposes a Unary gRPC service (Add, Mult) and also provides an HTTP/REST facade (using the Fiber framework) for ease of testing with curl or other HTTP clients.  It is organized as two distinct binaries (Client and Server) plus a shared `proto` directory for the service contract.

##### File structure
- Top level
- Client/… → Go program that acts as a gRPC client
- Server/… → Go program that hosts both the gRPC server and an HTTP server (Fiber)
- proto/…   → Protocol Buffer definition (`file.proto`) and the generated Go stubs (`file.pb.go`, `file_grpc.pb.go`)
- go.mod, go.sum → module and dependency management for the server
- Key patterns
- Service contract in proto files
- Separation of client and server executables
- Dual‐face server: gRPC + HTTP

##### README for additional insights
- Instructions to install protoc‐gen‐go and protoc‐gen‐go‐grpc
- Commands to regenerate the stubs
- How to launch server (`go run server/main.go`) and client (`go run client/main.go`)
- HTTP endpoints documented:
GET /add/:a/:b → returns sum
GET /mult/:a/:b → returns product

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    subgraph "External Clients"
        HTTPClient["HTTP Client<br/>(curl/Postman)"]:::httpClient
        GoClient["Go Client Binary"]:::client
    end

    %% Shared Proto Definitions
    subgraph "Shared Proto"
        ProtoIDL["file.proto"]:::proto
        Stubs1["file.pb.go"]:::proto
        Stubs2["file_grpc.pb.go"]:::proto
    end

    %% Server Binary Components
    subgraph "Server Binary" 
        Fiber["Fiber HTTP Server<br/>(HTTP:3000)"]:::http
        GRPCStub["gRPC Client Stub"]:::grpcClient
        GRPCServer["gRPC Server<br/>(gRPC:50051)"]:::grpcServer
        ServiceImpl["Service Implementation"]:::service
    end

    %% Documentation
    subgraph "Documentation"
        README["README.md"]:::docs
        LICENSE["LICENSE"]:::docs
    end

    %% Interactions
    HTTPClient -->|"GET /add/:a/:b<br/>GET /mult/:a/:b"| Fiber
    Fiber -->|"unary RPC Add/Mult"| GRPCStub
    GRPCStub -->|"Add/Mult RPC"| GRPCServer
    GRPCServer -->|"executes logic"| ServiceImpl
    ServiceImpl -->|"gRPC response"| GRPCServer
    GRPCServer -->|"returns RPC result"| GRPCStub
    GRPCStub -->|"JSON wrapper"| Fiber
    Fiber -->|"JSON response"| HTTPClient

    GoClient -->|"unary RPC Add/Mult"| GRPCServer

    %% Proto usage
    ProtoIDL --> GRPCStub
    Stubs1 --> GRPCStub
    Stubs2 --> GRPCServer
    ProtoIDL --> ServiceImpl
    Stubs1 --> ServiceImpl
    ProtoIDL --> GoClient

    %% Click Events
    click Fiber "https://github.com/carteruysl/grpc-fiber/blob/master/Server/main.go"
    click GoClient "https://github.com/carteruysl/grpc-fiber/blob/master/Client/main.go"
    click ProtoIDL "https://github.com/carteruysl/grpc-fiber/blob/master/proto/file.proto"
    click Stubs1 "https://github.com/carteruysl/grpc-fiber/blob/master/proto/file.pb.go"
    click Stubs2 "https://github.com/carteruysl/grpc-fiber/blob/master/proto/file_grpc.pb.go"
    click README "https://github.com/carteruysl/grpc-fiber/blob/master/README.md"
    click LICENSE "https://github.com/carteruysl/grpc-fiber/tree/master/LICENSE"

    %% Styles
    classDef httpClient fill:#AED6F1,stroke:#3498DB,color:#1B4F72;
    classDef client fill:#FCF3CF,stroke:#F1C40F,color:#7D6608;
    classDef http fill:#D6EAF8,stroke:#5DADE2,color:#154360;
    classDef grpcClient fill:#D5F5E3,stroke:#58D68D,color:#1D8348;
    classDef grpcServer fill:#D5F5E3,stroke:#58D68D,color:#1D8348;
    classDef service fill:#E8DAEF,stroke:#AF7AC5,color:#512E5F;
    classDef proto fill:#F2F3F4,stroke:#CACFD2,color:#566573;
    classDef docs fill:#FDEDEC,stroke:#E74C3C,color:#78281F;
```
