# copilot-extensions/skillset-example architecture

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

- Interactive diagram: https://gitdiagram.com/copilot-extensions/skillset-example
- Repository: https://github.com/copilot-extensions/skillset-example

## Overview

##### Project type and purpose
- This is a lightweight backend service (written in Go) that implements a GitHub Copilot “Skillset” extension.
- Its sole purpose is to expose three HTTP endpoints that generate random test data by proxying requests to public APIs (whatthecommit.com, loripsum.net, randomuser.me).
- It is not a full‐stack app—there is no frontend component—nor a compiler or monolith. It’s effectively a microservice/API gateway for GitHub Copilot.

##### File structure
- Top‐level files:
- main.go – application entrypoint, HTTP server setup
- go.mod – dependency manifest
- CODE_OF_CONDUCT.md, LICENSE.txt, SECURITY.md, SUPPORT.md – docs and policy
- handlers/ directory: each file defines one endpoint’s logic:
- handlers/commit_message.go → GET /random-commit-message
- handlers/loripsum.go → GET /random-lorem-ipsum
- handlers/user.go → GET /random-user
- No frontend or data persistence layers—just HTTP routing and outbound API calls.

##### README for architecture insights
- Conceptual model: “Skillsets” vs “Agents”
- This uses the Skillset approach—straight API endpoints, no custom AI orchestration in your code.
- Deployment hints: run locally on port 8080, expose via ngrok, configure GitHub App skillset URLs.

a. Main components to represent:
- GitHub Copilot Chat subsystem (client)
- GitHub Copilot Skillset Extension (your Go service)
– HTTP server (main.go + router)
– Three handler modules
- External APIs:
– whatthecommit.com
– loripsum.net
– randomuser.me
- ngrok (tunneling layer)

b. Relationships and interactions:
1. Copilot Chat issues an HTTP call to your service’s ngrok URL + endpoint path.
2. ngrok forwards the request to your local Go server.
3. HTTP router in main.go dispatches to the appropriate handler (commit, lorem, user).
4. Handler makes an outbound HTTP request to the respective external API.
5. External API returns data → handler formats → router returns JSON/plain text back to Copilot.
6. Copilot displays the result in the user’s chat window.

c. Architectural patterns and design principles:
- Microservice / API-gateway style: each handler is a single‐responsibility module.
- HTTP routing abstraction: main.go registers routes to handler functions.
- Dependency isolation: no global state, handlers only perform stateless proxy calls.
- 12-factor app principles: environment-driven configuration, no local persistence.

d. Relevant technologies and frameworks:
- Go (net/http) for server
- Go modules (go.mod)
- Public APIs (whatthecommit.com, loripsum.net, randomuser.me)
- ngrok for exposing localhost
- GitHub Apps & Copilot Skillsets configuration

##### Details to capture
- Explicitly label environment variable dependency (the FQDN/ngrok URL).
- Stateless nature of each handler.
- That Copilot handles all AI/prompt logic; your service simply proxies calls.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Systems
    CopilotChat["GitHub Copilot Chat"]:::external
    GitHubApp["GitHub App Settings"]:::external

    %% Infrastructure
    Ngrok["ngrok Tunnel"]:::infra

    %% Skillset Service
    subgraph "Skillset Service" 
        direction TB
        HTTPServer["HTTP Server & Router (:8080)"]:::service
        click HTTPServer "https://github.com/copilot-extensions/skillset-example/blob/main/main.go"
        subgraph "Handlers"
            direction TB
            CommitHandler["Commit Message Handler<br>/random-commit-message"]:::service
            click CommitHandler "https://github.com/copilot-extensions/skillset-example/blob/main/handlers/commit_message.go"
            LoremHandler["Lorem Ipsum Handler<br>/random-lorem-ipsum"]:::service
            click LoremHandler "https://github.com/copilot-extensions/skillset-example/blob/main/handlers/loripsum.go"
            UserHandler["Random User Handler<br>/random-user"]:::service
            click UserHandler "https://github.com/copilot-extensions/skillset-example/blob/main/handlers/user.go"
        end
    end

    %% External APIs
    subgraph "External Public APIs"
        direction TB
        API1["whatthecommit.com"]:::external
        API2["loripsum.net"]:::external
        API3["randomuser.me"]:::external
    end

    %% Configuration & Docs
    subgraph "Configuration & Documentation"
        direction TB
        GoMod["go.mod"]:::code
        click GoMod "https://github.com/copilot-extensions/skillset-example/blob/main/go.mod"
        COC["CODE_OF_CONDUCT.md"]:::code
        click COC "https://github.com/copilot-extensions/skillset-example/blob/main/CODE_OF_CONDUCT.md"
        License["LICENSE.txt"]:::code
        click License "https://github.com/copilot-extensions/skillset-example/blob/main/LICENSE.txt"
        Readme["README.md"]:::code
        click Readme "https://github.com/copilot-extensions/skillset-example/blob/main/README.md"
        Security["SECURITY.md"]:::code
        click Security "https://github.com/copilot-extensions/skillset-example/blob/main/SECURITY.md"
        Support["SUPPORT.md"]:::code
        click Support "https://github.com/copilot-extensions/skillset-example/blob/main/SUPPORT.md"
    end

    %% Relationships
    CopilotChat -->|"Invokes Skillset URL"| Ngrok
    Ngrok -->|"Forward to localhost:8080"| HTTPServer

    HTTPServer -->|"route /random-commit-message"| CommitHandler
    HTTPServer -->|"route /random-lorem-ipsum"| LoremHandler
    HTTPServer -->|"route /random-user"| UserHandler

    CommitHandler -->|"GET request"| API1
    API1 -->|"Response data"| CommitHandler

    LoremHandler -->|"GET request"| API2
    API2 -->|"Response data"| LoremHandler

    UserHandler -->|"GET request"| API3
    API3 -->|"Response data"| UserHandler

    CommitHandler -->|"Return formatted data"| HTTPServer
    LoremHandler -->|"Return formatted data"| HTTPServer
    UserHandler -->|"Return formatted data"| HTTPServer

    HTTPServer -->|"Response JSON/text"| Ngrok
    Ngrok -->|"Return to caller"| CopilotChat

    GitHubApp -->|"Registers FQDN URLs"| CopilotChat

    %% Styles
    classDef service fill:#E3F2FD,stroke:#1976D2,stroke-width:2px;
    classDef external fill:#E8F5E9,stroke:#388E3C,stroke-width:2px;
    classDef infra fill:#FFF3E0,stroke:#F57C00,stroke-width:2px;
    classDef code fill:#ECEFF1,stroke:#546E7A,stroke-width:1px;
```
