asaka

module
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2026 License: MIT

README

Asaka

CI Go Reference

The Go-native Server-Driven Admin for Laravel Go + PostgreSQL (MySQL and SQLite are experimental) + Inertia v3 + React.

Built for Go from day one — not ported from PHP abstractions. Declare a resource once as a plain Go struct and ship a single ~55 MB binary with goroutine-parallel dashboard widgets, O(1) constant-memory streaming CSV, zero-dependency native PDF export, real-time SSE notifications, and drop-in React extensibility.

Live Demo (10,000 PostgreSQL rows) · Website & Docs

Asaka Dashboard

Asaka Orders Table

Why Asaka?

  • Your model's hooks and events run when someone edits in the panel: Bind a resource to a Laravel for Go model (Model: asaka.Model[models.Order]()) and every create, edit, inline edit, delete, bulk delete, soft delete and restore goes through model.Create / model.Update / model.Delete. Your Creating / Updating / Deleting hooks run and your model.Created / Updated / Deleted listeners fire, just as they do for writes in your own handlers. Integer, UUID and ULID primary keys work. See Models, hooks and events for the writes that do not dispatch events.
  • Built for Go, not ported from PHP: No trait hierarchies, magic containers, or Livewire compatibility layers — just plain, type-safe Go structs you can read in minutes.
  • Single static binary: go build produces one binary with no PHP-FPM, Node runtime, headless Chromium, or Redis required for core features. The author runs it on a small VPS and has seen roughly 30–55 MB of idle RAM there; this is an observation, not something CI measures.
  • Young, PostgreSQL-first: First public release 2026-12-03. PostgreSQL is the primary target; MySQL and SQLite are experimental (see Status). Includes asaka:doctor schema checks and the asakatest helpers. The Playwright E2E suite lives in the separate asaka-demo repository and is not run by this repository's CI.
  • Built for AI-assisted development: Flat Go struct schemas, fast Go rebuilds, and a bundled Agent Skill (.agents/skills/asaka) let coding agents scaffold complete resources accurately.
  • Drop-in React ecosystem: Declare 90% of your admin in Go, and plug any React component (shadcn/ui, TanStack, Recharts, WarpUI) into fields, widgets, or custom pages in 10 lines via registerAsakaField / registerAsakaWidget.

Status and tested databases

Asaka is young: the first public release was on 2026-12-03, so expect rough edges and API changes between minor versions.

What CI runs on every push to main and every pull request:

  • go vet ./... and go test -race ./... (unit tests; no database is involved).
  • Real-database smoke tests (TestRealDB in asaka/realdb_test.go) against PostgreSQL 16, MySQL 8.4, and SQLite, each in its own job. They mount a panel on a real database and drive it over HTTP: list, search, sort, create, update, delete, soft delete, bulk delete, CSV export, CSV import, and database notifications. They are skipped unless ASAKA_TEST_DRIVER and ASAKA_TEST_DSN are set.

Measured coverage: as of 2026-12-05, go test -cover ./asaka/... reports 59.0% of statements for asaka and 97.7% for asaka/asakatest, without a database (the real-database tests are skipped). Treat these as a snapshot, not a guarantee.

Databases

Database Status Notes
PostgreSQL Primary target Smoke tests in CI (PostgreSQL 16). The author's demo and benchmarks run on PostgreSQL 14.
MySQL Experimental Smoke tests in CI (MySQL 8.4) cover only the features listed above.
SQLite Experimental Smoke tests in CI cover only the features listed above.

Known unsupported or untested on MySQL and SQLite. These features are not covered by the smoke tests, and their SQL is still written for PostgreSQL (RETURNING, unnest, to_regclass, ILIKE, NULLS LAST), so expect failures until they are ported and tested:

  • Built-in Auth and Profile pages, and opt-in RBAC tables
  • Relation managers
  • Async CSV export and import jobs (v0.18 ported the notification, export query and no-Model import SQL; they are covered by tests on MySQL and SQLite)
  • Query builder
  • Dashboard widgets that query your tables and global search (Cmd+K)
  • Live-form option creation, drag-and-drop reorder, and restoring soft-deleted rows
  • PDF export with search

Running anything beyond the smoke-tested features on MySQL or SQLite is at your own risk. Bug reports with the failing SQL are welcome.

Backup (experimental, opt-in). WithBackupEnabled(true) exposes GET {prefix}/backup.sql.gz, a gzipped data-only INSERT dump of your registered resource tables (no schema, sequences, indexes or other tables). It is not a replacement for pg_dump / mysqldump. With tenancy configured the dump contains only the current tenant's rows and SkipTenant (shared) resources are excluded; with RBAC enabled only the super-admin role can download it. Reads run in one read-only transaction; if anything fails the archive is left truncated and has no -- Asaka backup complete line. Its tests run on SQLite only.

Access control. Export downloads and per-user jobs (panel.StartJob) are visible only to the user and tenant that created them. Users are told apart by WithNotificationRecipient, else RBAC ResolveUserID, else the built-in Auth user; a panel that cannot tell users apart shares them. Uploaded files are public to anyone who has the (unguessable) URL, and fully public if your web server serves public/ directly.

Highlights

  • Go-Native Superpowers: Built-in asaka.RuntimeWidget() (live heap RAM, goroutines, GC pause, uptime at 0 ms SQL cost), concurrent goroutine widget resolution, O(1) constant-memory streaming CSV export (up to 50k rows via web.Stream), and single-binary deployment (go build).
  • Built for Real Data Volume: Measured once by the author on a VPS running PostgreSQL 14 with 10,000 rows, at up to 1,000 rows per page: ~9 ms LEFT JOIN query, ~11 ms full Dashboard aggregation, ~3.9 ms Cmd+K global search. These numbers are not produced by CI and are not guaranteed on other hardware or databases. Supports O(log N) Cursor / Keyset Pagination (asaka.PaginationCursor) and COUNT(*)-free PaginationSimple, plus experimental DialectMySQL and DialectSQLite dialects.
  • Zero-External-Daemon Stack: Real-time SSE Notifications (EventSource, no polling/Redis required), Native PDF 1.4 Export (table reports & single-record sheets with optional TrueType CJK/UTF-8 embedding, no Chromium/wkhtmltopdf), column-mapped async CSV imports (SAVEPOINTs), built-in Auth/Profile, opt-in RBAC, per-record Policy, Multi-Panel, and Multi-Tenancy UI.
  • Declarative Schema & All 20 Form Fields: Familiar declarative model if you know Filament — CRUD tables, dedicated Create/View (Infolists)/Edit pages, Action Modals & Slide-Overs, Soft Deletes, Relation Managers, Clusters, all 20 form fields (Builder, Repeater, FileUpload, RichEditor, MarkdownEditor, CodeEditor, CustomField, etc.), and server-driven live() reactivity.
  • Global-Ready RTL & Custom i18n: First-class RTL layout (Panel.WithRTL(true) + header LTR/RTL toggle), built-in en / ja / ar dictionaries, and server-side translation overrides.
  • Drop-in React Extensibility: Register any custom React field (registerAsakaField) or dashboard widget (registerAsakaWidget) in 10 lines without touching Asaka core.

Defining a Resource

func OrdersResource() *asaka.Resource {
	statuses := []asaka.Option{
		{Value: "pending", Label: "Pending", Color: "amber"},
		{Value: "processing", Label: "Processing", Color: "sky"},
		{Value: "shipped", Label: "Shipped", Color: "indigo"},
		{Value: "completed", Label: "Completed", Color: "emerald"},
		{Value: "cancelled", Label: "Cancelled", Color: "rose"},
	}

	return &asaka.Resource{
		Slug:          "orders",
		Model:         asaka.Model[models.Order](), // the table, key and timestamps come from the model
		Label:         "Orders",
		SingularLabel: "Order",
		Icon:          "shopping-cart",
		Group:         "Sales & Operations",
		PerPage:       25,
		Columns: []asaka.Column{
			asaka.TextColumn("order_number", "Order #").MakeSortable().MakeSearchable(),
			asaka.BelongsToColumn("customer_id", "Customer", "customers", "company_name").MakeSortable().MakeSearchable(),
			asaka.TextColumn("item_summary", "Line Item").MakeSearchable(),
			asaka.BadgeColumn("status", "Status", statuses).MakeSortable(),
			asaka.MoneyColumn("amount", "Amount").MakeSortable().MakeEditable(),
			asaka.DateColumn("due_date", "Due Date").MakeSortable().MakeEditable(),
		},
		Filters: []asaka.Filter{
			asaka.SelectFilter("status", "Status", statuses),
		},
		Fields: []asaka.Field{
			asaka.TextInput("order_number", "Order Number").MakeRequired().MakeUnique().InSection("Order Information"),
			asaka.BelongsToSelect("customer_id", "Customer", "customers", "company_name").MakeRequired().InSection("Order Information"),
			asaka.TextInput("item_summary", "Line Item").MakeRequired().InSection("Order Information"),
			asaka.SelectInput("status", "Status", statuses).MakeRequired().InSection("Order Information"),
			asaka.NumberInput("amount", "Amount (USD)").MakeRequired().WithMin(1).InSection("Schedule & Notes"),
			asaka.DateInput("due_date", "Due Date").InSection("Schedule & Notes"),
			asaka.TextareaInput("notes", "Delivery Notes").InSection("Schedule & Notes"),
		},
	}
}

System pages

Show what the framework keeps about workflow runs, failed jobs and feature flags (v0.17+). Off by default:

panel.WithSystemPages(asaka.SystemPages{
	Workflows:  true,
	FailedJobs: true,
	Features:   true,
	Authorize: func(r *web.Request, ability string) bool { // required
		return currentUser(r).IsAdmin
	},
	FeatureStore: featureStore, // optional: the same store as FEATURE_STORE, to show stored values
})

Each screen and button has its own ability (system.workflows.cancel, system.jobs.payload, ...). A panel with tenants must say AcrossTenants: true, because these pages show every tenant's data (or, for Workflows only, TenantAttribute: "tenant" to filter runs by an attribute). Batches and the schedule are not shown: the framework has no function to read them from a request.

Approvals with workflows

A row action can resume a Laravel for Go workflow that waits for a decision (v0.16+):

RowActions: []asaka.Action{
	asaka.ResumeAction("approve", "Approve",
		func(rec map[string]any) workflow.Token[workflows.Decision] {
			return workflows.DecisionFor(asaka.RecordInt(rec, "id"))
		},
		workflows.Approved,
	).WithTone("emerald").WithConfirm("Approve this order?").
		WithAuthorize(func(r *web.Request, rec map[string]any) bool { return canApprove(r) }),
},

The button appears on the record's View and Edit pages only while a run waits for that token. Pressing it checks the tenant, the record policy, Authorize and that the run still waits, then calls workflow.Resume. Wait for each token once in your workflow (or put run.ID() in it): with an asynchronous queue, two quick presses can deliver two values. Production needs workflow.CreateTables in a migration and a queue worker.

Queued CSV import & export

By default the asynchronous CSV import and export run in a goroutine of the web process, so a restart loses them. With WithQueuedCSV (v0.18+) they run as jobs of the Laravel for Go queue (asaka.import_csv, asaka.export_csv):

laravel.Options{
	Packages: []laravel.Package{
		asaka.Package(admin.NewPanel().WithQueuedCSV()), // Package, not Mount
	},
}

What you need

  • asaka.Package. Mount alone panics, because only a package can register jobs. Use one asaka.Package for all panels.
  • A queue worker (queue:work) on a real connection. On QUEUE_CONNECTION=sync the job runs inside the request and the request still answers 202.
  • A storage disk shared by the web servers and the workers, and private. The uploaded CSV (asaka/imports/<id>.csv), exports and error-row CSVs (asaka/exports/<name>) live there.
  • schedule:run in cron, for the daily asaka-csv-cleanup that deletes files older than 7 days.
Goroutine (default) Queued (WithQueuedCSV)
Survives a restart or deploy No Yes, the job waits in the queue
Where the CSV and exports live Local folder storage/app/private/asaka-exports The default storage disk, asaka/imports and asaka/exports
Payload In memory Path, mapping and tenant; never the CSV text
Failure Notification only Notification, and the job fails into failed_jobs (retryable)
Retry None queue:retry; a failed import keeps its CSV, a successful one deletes it
Attempts and time One, 2 minutes One (Tries: 1), 2 minutes (Timeout)
Old files Stay Deleted after 7 days by asaka-csv-cleanup
Download route and its checks Owner and tenant, else 404 The same; an older local export is still served

Limits

  • The tenant value must be a string or an integer up to int64 (it travels as text with its kind, so ids above 2^53 are exact). Another type makes the request fail and queues nothing.
  • The job has no request. The tenant is restored for the model hooks and the unique-field checks; the logged-in user and other request context values are not.
  • A job rejects a changed payload (a path that is not asaka/imports/<32 hex>.csv, a tenant column that is not the panel's) and fails permanently without touching storage.
  • A notification that cannot be stored after the import committed is logged and is not a job error, so a retry never imports rows twice.

Uploads on a storage disk

By default the upload route (POST {prefix}/upload, used by FileUploadInput) writes to public/uploads/asaka of the machine that got the request, so a second web server does not have the file. With WithUploadDisk (v0.19+) the files go to a Laravel for Go storage disk, such as s3:

asaka.New("Admin", "/admin").WithUploadDisk("s3") // a name from config.Filesystems.Disks

The file is stored at asaka/uploads/<name> on that disk. The URL does not change: the route still returns /uploads/asaka/<name>, so records and front ends made before the switch keep working, and so does a later change of disk. Files are still served by the same route, behind the panel guard, so a visitor who is not logged in gets neither the file nor a redirect.

What Served how Why
Images and PDF (png, jpg, jpeg, gif, webp, pdf) on a bucket (S3, Laravel Cloud) 302 to Disk.TemporaryURL, valid for 5 minutes The bytes go straight from the bucket, not through your app
Images and PDF on a local disk Streamed by the app, no CSP The framework serves a local disk's temporary URL with a sandbox policy, which stops a PDF from showing
SVG, CSV, txt, json Streamed by the app, never redirected, with attachment, Content-Security-Policy: sandbox and nosniff A bucket cannot send those headers, and an SVG that a browser showed from the bucket would run its script there
A bucket whose TemporaryURL fails Streamed by the app, images and PDF too There is nothing to redirect to
A file that is not on the disk, or a disk that cannot say (S3 403 without ListBucket) Looked for in public/uploads/asaka Files uploaded before the switch
  • One disk per app. Panels share one uploads route, and the first panel serves it. Every panel that sets WithUploadDisk must name the first panel's disk, or asaka.Package refuses to start. With Mount nothing checks this: use the same upload disk on every panel you mount.
  • The disk must be private. A public local disk (Public: true, such as the default public) serves its files at its mount with no guard and no signature, so asaka.Package refuses it. Use local or a disk of your own with Public: false.
  • asaka.Package also refuses a disk name that config.Filesystems.Disks does not have. With Mount there is no config to check, so the first upload or download fails with an error that names WithUploadDisk.
  • The route takes a form of up to 21 MiB (a file is at most 20 MB, so Asaka's own size check answers 422); a bigger one gets 413 from the framework, and the upload field shows "the file is too large".
  • Old local files are served until you copy public/uploads/asaka/* to asaka/uploads/ on the disk. Nothing is moved for you.
  • A temporary URL of a bucket lets whoever holds it fetch the file for 5 minutes.

Models, hooks and events

Model: asaka.Model[models.Order]() binds a resource to a Laravel for Go model. The table name, primary key type and timestamps are read from the struct, so Table can be left out (if you set it and it differs, Register panics). Without Model, a resource keeps writing with plain SQL, exactly as before.

Panel action With Model Hook Event
Create model.Create Creating model.Created
Edit, inline edit model.Update (only changed columns) Updating model.Updated (none when nothing changed)
Delete, bulk delete model.Delete, one transaction for the bulk delete Deleting model.Deleted for each row
Soft delete, restore model.Update on deleted_at Updating model.Updated (not Deleted)
Force delete model.Delete Deleting model.Deleted
CSV import (sync and async) model.Create per row Creating none by default; set ImportDispatchesEvents: true to dispatch Created
Drag-and-drop reordering plain SQL none none
Relation manager create, edit, attach plain SQL none none
Row and bulk actions your own function whatever it calls whatever it calls
  • Only the columns declared in the resource's Fields are written, plus the tenant column. Form values are converted to the struct's field types (date.Date, numeric.Decimal, uuid.UUID, db.JSON[T], pointers for nullable columns); a value that does not convert is a validation error on that field.
  • Columns of the model that are not in Fields are written by model.Create as the struct's zero value (that is how the framework creates models). Tag columns that should keep their database default db:",default", or make them pointers.
  • A hook that returns an error stops the write. The panel shows the error above the form (HTTP 422), unless the error has a StatusCode() int method, which then decides the status.
  • The tenant scope and the record lookup are one query (model.Query[T]().WhereEq(tenantColumn, tenant).Find(ctx, id)), so another tenant's id is a 404 on the model path too. Per-record policies run as before.
  • With EnableActivityLog, edits, deletes and restores write the activity log in the same transaction as the change. If your activity_logs table has a changes column (text or JSON), each entry also stores the changed columns with their old and new values (updated_at is left out).
  • Primary keys: integer keys work everywhere. UUID (uuid.UUID) and string keys (db:",uuid", db:",ulid") work for the list, view, create, edit, delete, bulk delete, soft delete, restore and cursor pagination. On those resources Register panics if you also use the int64-based Hooks (AfterCreate, BeforeUpdate, AfterUpdate, BeforeDelete, AfterDelete), RowActions, BulkActions, Relations or ReorderColumn; use the model's hooks and events instead.
  • The key column must be named id (the framework's default for the ID field).
  • asaka:doctor lists the resources without a Model as information, not as errors.

Register resources (with optional auth guard, opt-in RBAC, SQLite dialect, and multi-tenant scoping):

p := asaka.New("Asaka", "/admin").
	WithAuthGuard(requireAuth). // or .WithAuth(asaka.AuthConfig{...}); Mount panics without one of them
	// Optional: .WithTenantScope("tenant_id", resolveTenant)
	// Optional: .WithPDFRenderer(customPDFRenderer)
	// Optional: .WithNotificationRecipient(func(r *web.Request) string { ... })
	// Optional: .WithRBAC(asaka.RBACConfig{Enabled: true, RegisterRolesResource: true})
	// Optional: .WithRTL(true)
	// Optional: .WithLocale("ar").WithTranslations("fr", map[string]string{"dashboard": "Tableau de bord"})
	// Optional: .WithDialect(asaka.DialectMySQL) // or asaka.DialectSQLite
	// Optional: .WithPDFFontFile("/path/to/NotoSansJP-Regular.ttf") // or .WithPDFFont(ttfBytes) for UTF-8/CJK PDFs
	Register(
		OrdersResource(),
		CustomersResource(),
	)
p.Mount(route)

Mount panics unless the panel has WithAuthGuard(...) or an enabled WithAuth(...). For demos and local development only, WithoutAuth() mounts the panel publicly (every route, including CRUD, import, bulk delete, uploads and backup, is open to anyone).

Prerequisites

  • Go 1.27+
  • Node.js 22+
  • PostgreSQL (MySQL and SQLite are experimental, see Status)

Quick Start

A. Add to an existing Laravel Go app
go get github.com/qalainau/asaka
go run github.com/qalainau/asaka/cmd/asaka install
npm install lucide-react
  1. Enable class-based dark mode in resources/css/app.css:
@custom-variant dark (&:where(.dark, .dark *));
  1. Build the panel and list it in Packages in bootstrap/app.go:
import "github.com/qalainau/asaka/asaka"

func Options() laravel.Options {
	return laravel.Options{
		Packages: []laravel.Package{
			asaka.Package(admin.NewPanel()), // several panels: asaka.Package(admin.NewPanel(), ops.NewPanel())
		},
		// ...
	}
}

// admin/panel.go
func NewPanel() *asaka.Panel {
	return asaka.New("Admin", "/admin").
		WithAuthGuard(requireAuth). // or .WithAuth(asaka.AuthConfig{...})
		Register(OrdersResource())
}

The package mounts the panel's routes, adds the migrations of Asaka's own tables (asaka_notifications, asaka_roles, asaka_user_roles) and the asaka:doctor command. If there is no panel, two panels share a prefix, a panel has no access control, or a public (WithoutAuth()) panel is listed before a guarded one, the application refuses to start with an error naming the problem. A resource whose Model the panel cannot serve still panics in Panel.Register, when the panel is built.

activity_logs stays your application's table: create it in your own migration (columns id, resource_slug, record_id, action, summary, created_at, and optionally changes).

If you mounted the panel inside a route group with extra middleware (an IP allowlist, your own auth) and used WithoutAuth() because the group protected it, the package path does not have that group: give the panel its own guard (WithAuthGuard) before you switch.

  1. Run laravel migrate (the migrations skip Asaka tables that already exist), build your frontend assets (npm run build or npm run dev) and open /admin.

The older way still works: call panel.Mount(route) in routes/web.go instead of listing the package (asaka install --mount prints those steps). Mount panics where the package returns an error, and creates its tables at runtime.

Pass --force to asaka install to overwrite existing UI files when upgrading.

CLI Generators & Schema Doctor
go run github.com/qalainau/asaka/cmd/asaka install --force
go run github.com/qalainau/asaka/cmd/asaka make:resource Invoice
go run github.com/qalainau/asaka/cmd/asaka make:resource Invoice --from-db --table=invoices
go run github.com/qalainau/asaka/cmd/asaka make:page GeneralSettings
go run github.com/qalainau/asaka/cmd/asaka make:widget RevenueTrend --type=chart
go run github.com/qalainau/asaka/cmd/asaka make:relation-manager Customer Order

# Verify all registered resources against your live PostgreSQL schema
go run . asaka:doctor
B. Try the standalone 10,000-row demo locally

The full runnable demo application (10,000 PostgreSQL rows, Dashboard, Orders, Customers, Activity Logs, CSV/PDF exports, SSE notifications, and Playwright E2E suite) lives in its own repository: qalainau/asaka-demo.

git clone https://github.com/qalainau/asaka-demo.git
cd asaka-demo
cp .env.example .env
# Point DATABASE_URL in .env to your PostgreSQL database

npm install && npm run build
go run . migrate --seed
go run .

Open http://127.0.0.1:8000/admin.

Testing

# Go unit tests, asakatest helpers, CLI tests, and embedded stub verification
go test -race ./...

Use github.com/qalainau/asaka/asaka/asakatest to assert panel registration, route wiring, and policy enforcement in Go tests without booting a full server.

Project Structure

  • asaka/ — Core server-driven panel package (schema, CRUD/JOIN/inline handlers, global search, dashboard metrics, policy/guard, RBAC, multi-tenant scoping, native PDF/CSV exports, SSE notifications, unit tests).
  • asaka/asakatest/ — Testing helpers for asserting panel registration, routes, and policies.
  • asaka/stubs/ — Embedded React/TypeScript UI stubs installed by cmd/asaka install.
  • cmd/asaka/ — CLI installer & code generators (install, make:resource, make:page, make:widget, make:relation-manager).
  • .agents/skills/asaka/ — Official Agent Skill for AI coding assistants.

License

MIT


Built in Asaka, Japan.

Directories

Path Synopsis
Package asaka provides a Filament-inspired, server-driven admin panel framework for Laravel Go (go.laravel.com) + PostgreSQL/MySQL/SQLite + Inertia v3 + React.
Package asaka provides a Filament-inspired, server-driven admin panel framework for Laravel Go (go.laravel.com) + PostgreSQL/MySQL/SQLite + Inertia v3 + React.
cmd
asaka command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL