diff --git a/README.md b/README.md index 231e6e0..478d68c 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,33 @@ -# ⚑Via +# Via + Real-time engine for building reactive web applications in pure Go. - ## Why Via? -Somewhere along the way, the web became tangled in layers of JavaScript, build chains, and frameworks stacked on frameworks. -Via takes a radical stance: +The web became tangled in layers of JavaScript, build chains, and frameworks stacked on frameworks. Via takes a different path. -- No templates. -- No JavaScript. -- No transpilation. -- No hydration. -- No front-end fatigue. -- Single SSE stream. -- Full reactivity. -- Built-in Brotli compression. -- Pure Go. +**Philosophy** +- No templates. No JavaScript. No transpilation. No hydration. +- Views are pure Go functions. HTML is composed with a type-safe DSL. +- A single SSE stream carries all reactivity β€” no WebSocket juggling, no polling. +**Batteries included** +- Automatic CSRF protection on every action call +- Token-bucket rate limiting (global defaults + per-action overrides) +- Cookie-based sessions backed by SQLite +- Pub/sub messaging with an embedded NATS backend +- Structured logging via zerolog +- Graceful shutdown with context draining +- Brotli compression out of the box ## Example + ```go package main import ( - "github.com/go-via/via" - "github.com/go-via/via/h" + "github.com/ryanhamamura/via" + "github.com/ryanhamamura/via/h" ) type Counter struct{ Count int } @@ -57,25 +60,43 @@ func main() { } ``` +## What's built in -## 🚧 Experimental -Via is still a newborn. Via is taking its first steps! -- Version `0.1.0` released. -- Expect a little less chaos. +- **Reactive views + signals** β€” bind state to the DOM; changes push over SSE automatically +- **Components** β€” self-contained subcontexts with their own data, actions, and signals +- **Sessions** β€” cookie-based, backed by SQLite via `scs` +- **Pub/sub** β€” embedded NATS server with JetStream; generic `Publish[T]` / `Subscribe[T]` helpers +- **CSRF protection** β€” automatic token generation and validation on every action +- **Rate limiting** β€” token-bucket algorithm, configurable globally and per-action +- **Event handling** β€” `OnClick`, `OnChange`, `OnSubmit`, `OnInput`, `OnFocus`, `OnBlur`, `OnMouseEnter`, `OnMouseLeave`, `OnScroll`, `OnDblClick`, `OnKeyDown`, and `OnKeyDownMap` for multi-key bindings +- **Timed routines** β€” `OnInterval` with start/stop/update controls, tied to context lifecycle +- **Redirects** β€” `Redirect`, `ReplaceURL`, and format-string variants +- **Plugin system** β€” `func(v *V)` hooks for integrating CSS/JS libraries +- **Structured logging** β€” zerolog with configurable levels; console output in dev, JSON in production +- **Graceful shutdown** β€” listens for SIGINT/SIGTERM, drains contexts, closes pub/sub +- **Context lifecycle** β€” background reaper cleans up disconnected contexts; configurable TTL +- **HTML DSL** β€” the `h` package provides type-safe Go-native HTML composition + +## Examples + +The `internal/examples/` directory contains 14 runnable examples: + +`chatroom` Β· `counter` Β· `countercomp` Β· `greeter` Β· `keyboard` Β· `livereload` Β· `nats-chatroom` Β· `pathparams` Β· `picocss` Β· `plugins` Β· `pubsub-crud` Β· `realtimechart` Β· `session` Β· `shakespeare` + +## Experimental + +Via is maturing β€” sessions, CSRF, rate limiting, pub/sub, and graceful shutdown are in place β€” but the API is still evolving. Expect breaking changes before `v1`. ## Contributing + - Via is intentionally minimal and opinionated β€” and so is contributing. -- If you love Go, simplicity, and meaningful abstractions β€” Come along for the ride! -- Fork, branch, build, tinker with things, submit a pull request. +- Fork, branch, build, tinker, submit a pull request. - Keep every line purposeful. - Share feedback: open an issue or start a discussion. - ## Credits -Via builds upon the work of these amazing projects: +Via builds upon the work of these projects: -- πŸš€ [Datastar](https://data-star.dev) - The hypermedia powerhouse at the core of Via. It powers browser reactivity through Signals and enables real-time HTML/Signal patches over an always-on SSE event stream. -- 🧩 [Gomponents](https://maragu.dev/gomponents) - The awesome project that gifts Via with Go-native HTML composition superpowers through the `via/h` package. - -> Thank you for building something that doesn’t just function β€” it inspires. 🫢 +- [Datastar](https://data-star.dev) β€” the hypermedia framework powering browser reactivity through signals and real-time HTML patches over SSE. +- [Gomponents](https://maragu.dev/gomponents) β€” Go-native HTML composition that powers the `via/h` package.