Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ tasks:
deps:
- prismctl
- prism-admin
- prism-web-console
- prism-loadtest
- prism-launcher
- plugin-watcher
Expand Down Expand Up @@ -120,6 +121,20 @@ tasks:
- cd cmd/prism-admin && go build -o {{.BINARIES_DIR}}/prism-admin .
- echo "✓ prism-admin built"

prism-web-console:
desc: Build prism-web-console web interface
sources:
- cmd/prism-web-console/**/*.go
- cmd/prism-web-console/go.mod
- cmd/prism-web-console/go.sum
generates:
- '{{.BINARIES_DIR}}/prism-web-console'
cmds:
- echo "Building prism-web-console..."
- mkdir -p {{.BINARIES_DIR}}
- cd cmd/prism-web-console && go build -o {{.BINARIES_DIR}}/prism-web-console .
- echo "✓ prism-web-console built"

prism-loadtest:
desc: Build prism-loadtest utility
sources:
Expand Down Expand Up @@ -292,7 +307,7 @@ tasks:
- cd prism-proxy && cargo build
- cp {{.RUST_TARGET_DIR}}/debug/prism-proxy {{.BINARIES_DIR}}/prism-proxy-debug
- |
for cmd in prismctl prism-admin prism-loadtest prism-launcher plugin-watcher; do
for cmd in prismctl prism-admin prism-web-console prism-loadtest prism-launcher plugin-watcher; do
cd cmd/$cmd && go build -o {{.BINARIES_DIR}}/$cmd-debug . && cd ../..
done
- echo "✓ Debug builds complete"
Expand Down
228 changes: 228 additions & 0 deletions cmd/prism-web-console/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
# prism-web-console

Web-based admin console for Prism data access gateway.

**Status:** Initial implementation - separated from prism-admin control plane

## Overview

`prism-web-console` provides a web-based UI for managing Prism:
- Namespace management (create, list, delete)
- Session monitoring
- Backend health dashboard
- Operational tasks

This service is separate from `prism-admin` (the control plane gRPC server) to provide:
- Clear separation of concerns (control plane vs UI)
- Independent scaling and deployment
- Technology flexibility (web framework choice independent of control plane)

## Architecture

Based on RFC-036: Minimalist Web Framework for Prism Admin UI

```
Browser → prism-web-console (:8000) → prism-admin (:8981)
(Gin + templ + htmx) (gRPC Control Plane)
```

**Technology Stack:**
- **Gin**: HTTP routing and middleware
- **templ**: Type-safe HTML templates (to be added)
- **htmx**: HTML over the wire interactions
- **Tailwind CSS**: Utility-first styling

## Installation

### Build from Source

```bash
cd cmd/prism-web-console
go build -o prism-web-console .
```

### Install Globally

```bash
cd cmd/prism-web-console
go install .
```

## Usage

### Start the Server

```bash
# Default: http://0.0.0.0:8000
prism-web-console

# Custom port
prism-web-console --port 8080

# With admin endpoint
prism-web-console --admin-endpoint localhost:8981
```

### Configuration

Configuration precedence (highest to lowest):
1. Command-line flags
2. Environment variables (prefix: `PRISM_`)
3. Config file (`~/.prism.yaml` or `./.prism.yaml`)
4. Defaults

**Environment Variables:**

```bash
export PRISM_SERVER_PORT=8000
export PRISM_SERVER_LISTEN=0.0.0.0
export PRISM_ADMIN_ENDPOINT=localhost:8981
export PRISM_LOGGING_LEVEL=info
```

**Config File** (`~/.prism.yaml`):

```yaml
server:
listen: 0.0.0.0
port: 8000
mode: release # debug or release

admin:
endpoint: localhost:8981

logging:
level: info
```

## Development

### Project Structure

```
cmd/prism-web-console/
├── main.go # Entry point, Gin setup
├── handlers/ # HTTP handlers
│ ├── namespace.go # Namespace CRUD
│ ├── session.go # Session monitoring
│ └── health.go # Backend health
├── templates/ # templ templates (to be added)
│ ├── layout.templ
│ ├── namespace.templ
│ └── session.templ
├── static/ # Static assets
│ ├── css/styles.css # Tailwind CSS
│ └── js/htmx.min.js # htmx library
├── middleware/ # Gin middleware
│ ├── auth.go # OIDC authentication
│ └── logging.go # Request logging
├── go.mod
└── README.md
```

### Running Locally

```bash
# Start prism-admin control plane
cd cmd/prism-admin
go run . serve --port 8981

# Start web console (in another terminal)
cd cmd/prism-web-console
go run . --port 8000

# Open browser
open http://localhost:8000
```

### Testing

```bash
# Run tests
go test ./...

# Run with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
```

## Docker Deployment

### Build Image

```bash
# From repository root
make docker-build-service SERVICE=prism-web-console VARIANT=scratch
```

### Run Container

```bash
docker run -p 8000:8000 \
-e PRISM_ADMIN_ENDPOINT=prism-admin:8981 \
prism-web-console:scratch
```

### Docker Compose

```yaml
services:
prism-admin:
image: prism/admin:latest
ports:
- "8981:8981"

prism-web-console:
image: prism/web-console:latest
ports:
- "8000:8000"
environment:
PRISM_ADMIN_ENDPOINT: prism-admin:8981
PRISM_LOGGING_LEVEL: info
depends_on:
- prism-admin
```

## API Endpoints

### Health Check

```bash
GET /health
```

**Response:**
```json
{
"status": "healthy",
"service": "prism-web-console"
}
```

### Web UI Routes

- `GET /` - Admin dashboard
- `GET /namespaces` - Namespace list
- `POST /namespaces` - Create namespace
- `DELETE /namespaces/:name` - Delete namespace
- `GET /sessions` - Session monitoring
- `GET /health-dashboard` - Backend health

## Authentication

OIDC authentication integration (to be implemented):
- Session-based authentication
- JWT validation
- Integration with Dex IdP (RFC-010)

## References

- RFC-036: Minimalist Web Framework for Prism Admin UI
- ADR-028: Admin UI with FastAPI and gRPC-Web
- [Gin Web Framework](https://gin-gonic.com/)
- [templ](https://templ.guide/)
- [htmx](https://htmx.org/)

## Revision History

- 2025-10-22: Initial separation from prism-admin
58 changes: 58 additions & 0 deletions cmd/prism-web-console/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module github.com/jrepp/prism-data-layer/prism-web-console

go 1.24.0

require (
github.com/gin-gonic/gin v1.10.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
)

require (
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.11.1 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.40.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.42.0 // indirect
golang.org/x/sys v0.34.0 // indirect
golang.org/x/text v0.27.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/jrepp/prism-data-layer/pkg/plugin => ../../pkg/plugin
Loading