Skip to content

Instantly share code, notes, and snippets.

View blinkinglight's full-sized avatar

M blinkinglight

View GitHub Profile

Microservice Specification

Name

Echo Service

Purpose

The Echo Service is a simple CQRS-based microservice that receives commands or queries via NATS, processes them (which in this case means doing nothing but passing the message along), and returns the original message.

Architecture

  • NATS: Message transport.

Microservice Specification

Name

Echo Service

Purpose

The Echo Service is a simple microservice that receives any data payload via NATS messaging and returns the exact same data payload in its response.

Requirements

  1. NATS Integration

Creating a simple microservice that responds with the same data it received using NATS.io involves several steps. Below is an example of how you can implement this in Go, leveraging CQRS (Command Query Responsibility Segregation), Templ (likely referring to Flowbite for UI components, but we'll focus on backend logic here), and DataStar for data storage.

Prerequisites

  1. NATS Server: Ensure you have a NATS server running. You can start one locally using Docker:

    docker run -d --name nats -p 4222:4222 nats
  2. Go Environment: Ensure Go is installed.

Error in user YAML: (<unknown>): mapping values are not allowed in this context at line 2 column 58
---
name: nats
description: Practical, production-minded NATS skill pack: Core NATS + JetStream + Go (nats.go) + Micro (service framework). Includes mental models, subject design, reliability patterns, security, ops, and copy‑paste Go snippets.
---

NATS SKILL

This is a high-signal field guide for building real systems with NATS:

  • Core NATS for low-latency messaging (pub/sub, request-reply, queue groups).
  • JetStream for persistence, replay, work-queues, KV, Object Store.
name description
templ
Compile-time HTML templating for Go using templ. Enforces type-safe components, layout composition, fragment rendering, and production-ready best practices for HTTP, SSE, and component-driven UI architectures.

SKILL.md — templ (https://templ.guide)

This SKILL document defines how Claude CLI and OpenCode CLI should reason about, generate, refactor, and review code that uses templ (https://templ.guide) for Go-based HTML templating.

The purpose is to ensure consistent, idiomatic, production-ready usage of templ across projects.

name description
datastar
Apply datastar best practices, idioms, and conventions from https://data-star.dev/reference/attributes. Use when writing, reviewing, or refactoring html/frontend code to ensure idiomatic, clean, and efficient implementations.

Datastar (data-star.dev) — Claude/OpenCode SKILL

Tikslas: šiame faile aprašyta, kaip teisingai ir produktyviai naudoti Datastar kuriant backend-driven (hypermedia-first) UI. Tekstas skirtas LLM „skill“ formato naudojimui: aiškios taisyklės, receptai, šablonai, „gotchas“, ir mini pavyzdžiai.

Kas yra Datastar (mentalus modelis)

@blinkinglight
blinkinglight / Caddyfile
Created January 19, 2026 07:18 — forked from vanodevium/Caddyfile
Caddy server: enable CORS for any domain
(cors) {
@cors_preflight method OPTIONS
header {
Access-Control-Allow-Origin "{header.origin}"
Vary Origin
Access-Control-Expose-Headers "Authorization"
Access-Control-Allow-Credentials "true"
}
@blinkinglight
blinkinglight / datastar-rc6-golang-prompt.md
Created November 19, 2025 23:35 — forked from njreid/datastar-rc6-golang-prompt.md
Datastar (data-star.dev) System Prompt for Version 1.0.0.RC6 with the Go SDK

Datastar + Go Development System Prompt

You are an expert in building modern web applications using Datastar (a hypermedia-driven reactive framework) with Go backends. You follow these principles and patterns:


Core Philosophy

Hypermedia-First Architecture: The backend drives the UI by sending HTML fragments and state updates over Server-Sent Events (SSE). There is NO separate REST API layer - all interactions happen through SSE streams.

@blinkinglight
blinkinglight / index.html
Last active July 25, 2025 05:57
fancy file uploader vanilla js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="script.js" defer type="module"></script>
</head>
<body>
@blinkinglight
blinkinglight / main.go
Last active June 17, 2025 17:09
bee in action
router.Get("/stream/{id}", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
id := chi.URLParam(r, "id")
sse := datastar.NewSSE(w, r)
_ = sse
ctx := bee.WithJetStream(r.Context(), js)
ctx = bee.WithNats(ctx, nc)
agg := &Aggregate{}