🧪 Alpha Software: Datapages is still in early development 🚧.
APIs are subject to change and you may encounter bugs.
A Templ + Go + Datastar web framework for building dynamic, server-rendered web applications in pure Go.
Focus on your business logic, generate the boilerplate Datapages parses your app source package and generates all the wiring. Routing, sessions and authentication, SSE streams, CSRF protection, type-safe URL and action helpers - so your application code stays clean and takes full advantage of Go's strong static typing and high performance.
go install github.com/romshark/datapages@latestdatapages init| Command | Description |
|---|---|
datapages init |
Initialize a new project with scaffolding and configuration. |
datapages gen |
Parse the app model and generate the datapages package. |
datapages watch |
Start the live-reloading development server. |
datapages lint |
Validate the app model without generating code. |
datapages version |
Print CLI version information. |
Datapages reads configuration from datapages.yaml in the module root:
app: app # Path to the app source package (default)
gen:
package: datapagesgen # Path to the generated package (default)
prometheus: true # Enable Prometheus metrics generation (default)
cmd: cmd/server # Path to the server cmd package (default)When prometheus is set to false, the generated server code will not include
Prometheus imports, metric variables, or the WithPrometheus server option.
Use datapages init --prometheus=false to scaffold a project without Prometheus.
The optional watch section configures the development server
(host, proxy timeout, TLS, compiler flags, custom watchers, etc.).
This repository features a demo application resembling an online classifieds marketplace
under example/classifieds.
The code you'd write is in
example/classifieds/app
(the "source package").
The code that the generator produces is in
example/classifieds/datapagesgen.
To run the demo in development mode, use:
cd example/classifieds
make devYou can then access:
- Preview: http://localhost:52000/
- Grafana Dashboards: http://localhost:3000/
- Prometheus UI: http://localhost:9091/
You can install k6 and run make load in the background
to generate random traffic.
Increase the number of virtual users (VU) to apply more load to the server when needed.
To run the demo in production mode, use:
make stageSee SPECIFICATION.md for the full source package specification, including handler signatures, parameters, return values, events, sessions, and modules.
- For now, with CSRF protection enabled, you will not be able to use plain HTML forms,
since the CSRF token is auto-injected for Datastar
fetchrequests (whereDatastar-Requestheader istrue). You must use Datastar actions for any sort of server interactivity.
Datapages ships pluggable modules with swappable implementations:
SessionManager[S]MessageBrokerTokenManagerhmac- HMAC-SHA256 with BREACH-resistant masking
TokenGeneratorsesstokgen- Cryptographically random session tokens (256-bit)
- Go (see version in
go.mod)
See CLAUDE.md for code style, testing conventions, commit message format, and project structure.
Use the example/classifieds/ application as a real-world
test fixture when developing Datapages.