2026-01-12 00:21:22 -05:00
# NEBULA PROJECT KNOWLEDGE BASE
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
**Generated:** 2026-01-11 | **Commit: ** fcbe848 | **Branch: ** feat/pkg
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
## OVERVIEW
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
Go/Templ wallet UI framework using HTMX 4 for server-driven interactions and WebAwesome (`wa-*` ) web components. Hybrid: root is a library (`package nebula` ), `cmd/server/` is the reference app.
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
## STRUCTURE
2026-01-07 20:24:49 -05:00
```
nebula/
2026-01-12 00:21:22 -05:00
├── cmd/server/ # App entry: main.go + routes.go (handlers HERE, not handlers/)
├── views/ # Page templates (.templ) - XxxPage, XxxContent, XxxWithStepper
├── components/ # Reusable UI (sidebar, stepper, navbar, charts)
├── layouts/ # Base (HTML shell), App (dashboard), Centered (auth)
├── models/ # Data structs + DefaultXxxData() factories
├── htmx/ # HTMX 4 context/request/response helpers
├── pkg/config/ # Config models for middleware injection
├── _migrate/ # HTML prototypes pending conversion (technical debt)
├── middleware.go # Injects HTMX + Config into request context
├── mount.go # Mount() helper for handler registration
├── options.go # WithXxx() functional options
└── config.go # DefaultConfig() + Config struct
2026-01-07 20:24:49 -05:00
```
2026-01-12 00:21:22 -05:00
## WHERE TO LOOK
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
| Task | Location | Notes |
|------|----------|-------|
| Add route | `cmd/server/routes.go` | Go 1.22+ patterns: `GET /path/{param}` |
| Add page | `views/` + `models/` | Create XxxPage + model, register in routes.go |
| HTMX patterns | `HTMX.md` | `<hx-partial>` , morphing, SSE, OOB updates |
| Modify layout | `layouts/base.templ` | CDN scripts, htmx-config meta tag |
| WebAwesome ref | [webawesome.com ](https://webawesome.com ) | All `wa-*` components |
| Migrate HTML | `_migrate/` -> `views/` | See MIGRATION.md |
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
## CONVENTIONS
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
### Naming
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
| Type | Pattern | Example |
|------|---------|---------|
| Page template | `XxxPage(data)` | `DashboardPage(data, tab)` |
| Partial (HTMX) | `XxxContent` , `XxxTab` | `DashboardContent(data, tab)` |
| OOB update | `XxxWithStepper` , `XxxWithOOB` | `WelcomeStepWithStepper(step)` |
| Model | `XxxData` , `XxxState` | `DashboardData` , `LoginState` |
| Factory | `DefaultXxxData()` | `DefaultDashboardData()` |
| Handler | `handleXxx` | `handleDashboard` |
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
### HTMX 4 Request Pattern
2026-01-07 20:24:49 -05:00
```go
2026-01-12 00:21:22 -05:00
func handleXxx(w http.ResponseWriter, r *http.Request) {
data := models.DefaultXxxData()
if r.Header.Get("HX-Request") == "true" {
views.XxxContent(data).Render(r.Context(), w) // Partial
return
}
views.XxxPage(data).Render(r.Context(), w) // Full page
2026-01-07 20:24:49 -05:00
}
```
2026-01-12 00:21:22 -05:00
### OOB Updates (Multi-Target)
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
```templ
templ XxxStepWithStepper(step int) {
@XxxStepContent (step)
<div id="stepper-container" hx-swap-oob="innerHTML">
@components .Stepper(step, steps)
</div>
2026-01-07 20:24:49 -05:00
}
```
2026-01-12 00:21:22 -05:00
### Templ Syntax Quick Ref
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
```templ
if cond { } // Conditional
for _, item := range items { } // Loop
<input disabled?={ isDisabled } /> // Bool attr
<div class={ "base " + extra }> // String interpolation
@ChildComponent (props) // Composition
@templ .Raw(html) // Raw HTML (avoid)
2026-01-07 20:24:49 -05:00
```
2026-01-12 00:21:22 -05:00
## ANTI-PATTERNS (THIS PROJECT)
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
| DO NOT | Why |
|--------|-----|
| Edit `*_templ.go` files | Generated by `templ generate` - changes purged |
| Use separate `htmx-ext-*` packages | HTMX 4 bundles extensions at `/dist/ext/` |
| Rely on implicit inheritance | Use `:inherited` modifier (`hx-target:inherited` ) |
| Use `TopBar` or `TopBarStyles` | DEPRECATED - use `wa-page` slots instead |
| Manual DOM manipulation | Use `hx-*` attributes; server controls state |
| Put handlers in `handlers/` | Docs outdated - use `cmd/server/routes.go` |
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
## COMMANDS
2026-01-07 20:24:49 -05:00
```bash
2026-01-12 00:21:22 -05:00
# Generate templ (REQUIRED after .templ changes)
templ generate
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
# Dev server on :8080
go run ./cmd/server
# OR
make start
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
# Full cycle: generate + start + open browser
make all
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
# Build binary
make build # outputs ./nebula
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
# Watch mode
templ generate --watch
```
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
## STACK VERSIONS
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
- **Go**: 1.25.5 (cutting-edge)
- **templ**: v0.3.977
- **htmx**: 4.0.0-alpha5 (CDN)
- **WebAwesome**: Kit 47c7425b971f443c (CDN)
- **D3.js**: v7 (charts)
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
## NOTES
2026-01-07 20:24:49 -05:00
2026-01-12 00:21:22 -05:00
- **No tests exist** - `go test ./...` returns "no test files"
- **No CI/CD** - No `.github/workflows/`
- **SQLite WASM** mentioned in docs but not implemented
- **Documentation references `handlers/` ** - doesn't exist; handlers are in `cmd/server/routes.go`
- Config split: root `config.go` (app config) vs `pkg/config/` (HTMX feature flags)
- Middleware chain: `nebula.Middleware(opts...)(mux)` injects context for templates