Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

romshark/datapages

Repository files navigation

Datapages

CI golangci-lint Coverage Status Go Report Card Go Reference License: MIT Alpha

🧪 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.

Getting Started

Install

go install github.com/romshark/datapages@latest

Initialize New Project

datapages init

CLI Commands

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.

Configuration

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.).

Demo: Classifieds

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 dev

You can then access:

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 stage

Specification

See SPECIFICATION.md for the full source package specification, including handler signatures, parameters, return values, events, sessions, and modules.

Technical Limitations

  • 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 fetch requests (where Datastar-Request header is true). You must use Datastar actions for any sort of server interactivity.

Modules

Datapages ships pluggable modules with swappable implementations:

Development

Prerequisites

  • Go (see version in go.mod)

Contributing

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.