# canvas-tech-horizon/notelink architecture

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

- Interactive diagram: https://gitdiagram.com/canvas-tech-horizon/notelink
- Repository: https://github.com/canvas-tech-horizon/notelink

## Overview

##### Project type and purpose
- This is a Go library (open-source package) named “Notelink”.
- Purpose: simplify API documentation generation and serve an interactive HTML docs UI alongside a Fiber web server.

##### File structure
- api_note.go: core API manager, route registration, server start/stop logic.
- html.go: HTML template definitions and rendering logic for the interactive docs.
- schema.go: logic that inspects Go structs and emits TypeScript interface definitions.
- types.go: shared type definitions (Config, DocumentedRouteInput, Parameter, etc.).
- go.mod / go.sum: dependency management (Fiber, JWT, godotenv).
- README.md / LICENSE / .gitignore: project documentation and policy.

##### README for additional insights
- Integrates with Fiber v2 for HTTP routing.
- Uses JWT for optional authentication middleware.
- Uses godotenv to load environment variables (JWT_SECRET).
- Exposes a `/api-docs` endpoint serving a client-side app that:
- Displays endpoints by version/path
- Renders parameter tables, schemas (TS interfaces)
- Supports in-browser testing of each endpoint

##### Detail
- Modules: Config, ApiNote Manager, Route Registry, JWT Middleware, SchemaGen, HTMLGen.
- Integration with Fiber and godotenv.
- Don’t omit the interactive testing path from the docs UI back to the real endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Consumer Application
    App["Consumer App\n(main.go)"]:::app
    App -->|"godotenv.Load()"| EnvLoader["Env Loader"]:::external
    EnvLoader -->|"NewApiNote(&Config)"| ApiNote

    %% Notelink Library
    subgraph "Notelink Library"
        Config["Config Module"]:::library
        Types["Shared Types"]:::library
        ApiNote["Core API Manager"]:::library
        JWT["JWT Middleware"]:::library
        Schema["Schema Generator"]:::library
        HTML["HTML Renderer"]:::library
    end

    %% Dependency Management
    DepMgmt["Dependency Management"]:::external
    EnvLoader --> DepMgmt
    DepMgmt -.-> FiberHTTP

    %% HTTP Server
    FiberHTTP["Fiber HTTP Server"]:::external

    %% External Services
    JWTIssuer["JWT Token Issuer"]:::external

    %% Runtime Flow
    FiberHTTP -->|"/api-docs"| HTML
    HTML -->|"serve UI"| Client
    Client["Browser Client"]:::client
    Client -->|"test API calls"| FiberHTTP

    FiberHTTP -->|"incoming request"| JWT
    JWT -->|"validate JWT"| Handler["Business Handler"]:::app
    Handler -->|"response JSON"| FiberHTTP
    FiberHTTP --> Client

    %% Connections within Library
    ApiNote -->|"register route"| Schema
    ApiNote -->|"store metadata"| Types
    ApiNote -->|"render docs"| HTML
    ApiNote --> FiberHTTP

    %% Click Events
    click Config "https://github.com/canvas-tech-horizon/notelink/blob/main/types.go"
    click Types "https://github.com/canvas-tech-horizon/notelink/blob/main/types.go"
    click ApiNote "https://github.com/canvas-tech-horizon/notelink/blob/main/api_note.go"
    click JWT "https://github.com/canvas-tech-horizon/notelink/blob/main/api_note.go"
    click Schema "https://github.com/canvas-tech-horizon/notelink/blob/main/schema.go"
    click HTML "https://github.com/canvas-tech-horizon/notelink/blob/main/html.go"
    click DepMgmt "https://github.com/canvas-tech-horizon/notelink/blob/main/go.mod"
    click DepMgmt "https://github.com/canvas-tech-horizon/notelink/blob/main/go.sum"
    click README["README.md"] "README.md"
    click LICENSE["LICENSE"] "LICENSE"
    click GITIGNORE[".gitignore"] ".gitignore"

    %% Styles
    classDef library fill:#cce5ff,stroke:#339,stroke-width:1px;
    classDef external fill:#e0e0e0,stroke:#666,stroke-width:1px;
    classDef app fill:#d4edda,stroke:#2e7d32,stroke-width:1px;
    classDef client fill:#fff3cd,stroke:#b38600,stroke-width:1px;
```
