# soulchildtc/mcp-server-demo architecture

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

- Interactive diagram: https://gitdiagram.com/soulchildtc/mcp-server-demo
- Repository: https://github.com/soulchildtc/mcp-server-demo

## Overview

##### Project type and purpose
- This is a standalone Go‐based microservice (“mcp-server-demo”) built with the mcp‐go framework. It exposes HTTP endpoints (health check, weather) and is containerized for Kubernetes deployment.
- There is no user‐facing UI; it is purely a backend API service demonstrating configuration management, routing, business logic, data modeling, and logging.

##### File structure
- cmd/server: application entry point (main.go). Initializes config, router, logging, and starts HTTP server.
- internal/config: configuration loader and environment variable mapping.
- internal/handler: HTTP handlers (health.go, weather.go) that decode requests, invoke the service layer, and marshal responses.
- internal/service: business logic (weather.go) that may interact with external APIs or perform computations.
- internal/model: domain models (weather.go) defining data structures.
- pkg/log: shared logging library used across the app.
- deploy: Dockerfile and Kubernetes manifests (Deployment, Ingress) for container build and cluster deployment.
- go.mod/go.sum: Go module dependencies.

##### Readme insights
- Describes a simple mcp-go server demo.
- Shows that the app is invoked via `go run cmd/server`.

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Client
    Client["External Client (curl/HTTP)"]:::external

    %% Kubernetes Ingress
    Ingress["K8s Ingress"]:::infra

    %% Kubernetes Service
    K8sService["K8s Service (ClusterIP)"]:::infra

    %% Kubernetes Deployment and Pod
    subgraph "Kubernetes Deployment" 
        Deployment["Deployment"]:::infra
        Pod["Pod"]:::infra
        ContainerNode["Docker Container"]:::infra
    end

    %% Docker Build
    DockerfileNode["Dockerfile"]:::infra

    %% Go Application Container
    subgraph "Go Application" 
        subgraph "cmd/server"
            Main["main.go"]:::app
        end
        subgraph "internal/config"
            Config["config.go"]:::app
        end
        subgraph "pkg/log"
            LogImpl["log.go"]:::app
            LogTest["example_test.go"]:::app
        end
        subgraph "internal/handler"
            HealthHandler["health.go"]:::app
            WeatherHandler["weather.go"]:::app
        end
        subgraph "internal/service"
            ServiceLogic["weather.go"]:::app
        end
        subgraph "internal/model"
            Model["weather.go"]:::app
        end
    end

    %% External API
    ExternalAPI["External Weather API"]:::external

    %% Flow Arrows
    Client -->|"HTTP GET /weather"| Ingress
    Ingress -->|routing| K8sService
    K8sService -->|forward| Pod
    Pod -->|runs in| ContainerNode
    DockerfileNode -->|build image| ContainerNode

    %% In-Container Initialization
    ContainerNode -->|executes| Main
    Main -->|"LoadConfig()"\| Config
    Main -->|"InitLogger()"\| LogImpl
    Main -->|"RegisterHandlers()"\| HealthHandler
    Main -->|"RegisterHandlers()"\| WeatherHandler

    %% Request Handling
    WeatherHandler -->|"calls"| ServiceLogic
    ServiceLogic -->|"uses"| Model
    ServiceLogic -->|"HTTP call"| ExternalAPI
    WeatherHandler -->|"marshal JSON"| Client

    %% Logging
    HealthHandler -->|"Log.Info()"\| LogImpl
    WeatherHandler -->|"Log.Info()"\| LogImpl
    ServiceLogic -->|"Log.Info()"\| LogImpl

    %% Module defs
    GoMod["go.mod"]:::infra
    GoSum["go.sum"]:::infra
    GoMod -->|defines modules| Main
    GoSum -->|defines modules| Main

    %% Click Events
    click Main "https://github.com/soulchildtc/mcp-server-demo/blob/main/cmd/server/main.go"
    click Config "https://github.com/soulchildtc/mcp-server-demo/blob/main/internal/config/config.go"
    click HealthHandler "https://github.com/soulchildtc/mcp-server-demo/blob/main/internal/handler/health.go"
    click WeatherHandler "https://github.com/soulchildtc/mcp-server-demo/blob/main/internal/handler/weather.go"
    click ServiceLogic "https://github.com/soulchildtc/mcp-server-demo/blob/main/internal/service/weather.go"
    click Model "https://github.com/soulchildtc/mcp-server-demo/blob/main/internal/model/weather.go"
    click LogImpl "https://github.com/soulchildtc/mcp-server-demo/blob/main/pkg/log/log.go"
    click LogTest "https://github.com/soulchildtc/mcp-server-demo/blob/main/pkg/log/example_test.go"
    click DockerfileNode "https://github.com/soulchildtc/mcp-server-demo/tree/main/deploy/Dockerfile"
    click Deployment "https://github.com/soulchildtc/mcp-server-demo/blob/main/deploy/k8s-deployment.yaml"
    click Ingress "https://github.com/soulchildtc/mcp-server-demo/blob/main/deploy/k8s-ingress.yaml"
    click GoMod "https://github.com/soulchildtc/mcp-server-demo/blob/main/go.mod"
    click GoSum "https://github.com/soulchildtc/mcp-server-demo/blob/main/go.sum"

    %% Styles
    classDef infra fill:#bbf,stroke:#339,stroke-width:1px
    classDef app fill:#bfb,stroke:#393,stroke-width:1px
    classDef external fill:#feb,stroke:#f63,stroke-width:1px
```
