2025-11-10 02:59:45 +00:00
# Core Element Template
2026-03-14 09:49:41 +00:00
Starter template for building custom HTML elements backed by a Go API. Part of the [Core ecosystem ](https://core.help ).
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
## Quick Start
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
```bash
# Clone and rename
git clone https://forge.lthn.ai/core/element-template.git my-element
cd my-element
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
# Install UI dependencies and build
cd ui & & npm install & & npm run build & & cd ..
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
# Run
go run . --port 8080
```
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
Open `http://localhost:8080` — you'll see the `<core-demo-element>` fetching data from the Go API.
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
## What's Included
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
| Component | Technology | Purpose |
|-----------|-----------|---------|
| Go backend | core/go-api (Gin) | REST API with CORS, middleware |
| Custom element | Lit 3 | Self-contained web component |
| Build config | `.core/build.yaml` | Cross-platform binary builds |
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
## Making It Yours
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
1. Update `go.mod` module path
2. Rename `DemoProvider` in `provider.go` — implement your API
3. Rename `CoreDemoElement` in `ui/src/index.ts` — implement your UI
4. Update the element tag in `ui/index.html`
## Service Provider Pattern
The `DemoProvider` implements `api.RouteGroup` :
```go
func (p *DemoProvider) Name() string { return "demo" }
func (p *DemoProvider) BasePath() string { return "/api/v1/demo" }
func (p *DemoProvider) RegisterRoutes(rg *gin.RouterGroup) {
rg.GET("/hello", p.hello)
}
```
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
Register it with `engine.Register(&DemoProvider{})` and it gets middleware, CORS, and OpenAPI for free. The same provider can plug into core/ide's registry.
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
## Licence
2025-11-10 02:59:45 +00:00
2026-03-14 09:49:41 +00:00
EUPL-1.2