An open API service indexing awesome lists of open source software.

https://github.com/niklas-schmidt-dev/shipable-template-dashboard-go-clerk-postgres-redis

A backend-only Go API service with Clerk session verification, Postgres tables, and Dragonfly or Redis caching.
https://github.com/niklas-schmidt-dev/shipable-template-dashboard-go-clerk-postgres-redis

backend dashboard-go-clerk-postgres-redis shipable shipable-template

Last synced: 29 days ago
JSON representation

A backend-only Go API service with Clerk session verification, Postgres tables, and Dragonfly or Redis caching.

Awesome Lists containing this project

README

          

# Go + Clerk + Postgres + Dragonfly/Redis Dashboard

A single-binary Go dashboard with Clerk session verification, Postgres reporting tables, and a Redis-compatible cache that works with Dragonfly or Redis.

## Run locally

Use Go 1.25 or newer.

```bash
cp .env.example .env
go mod tidy
go run ./cmd/server
```

Open `http://localhost:8080`. Without `DATABASE_URL`, `REDIS_URL`, or Clerk values, the app shows preview data and clear runtime status.

## Configure data

Apply the SQL files in `db/migrations` to your Postgres database, then set `DATABASE_URL`.

Set `REDIS_URL` to either Redis or Dragonfly. Dragonfly is Redis-compatible, so the same `github.com/redis/go-redis/v9` client and URL shape work for both.

## Configure Clerk

Set these variables:

```bash
CLERK_SECRET_KEY=sk_...
CLERK_PUBLISHABLE_KEY=pk_...
```

The browser loads a pinned ClerkJS major version, gets a session token, and calls the Go API with `Authorization: Bearer `. The Go API uses Clerk's `RequireHeaderAuthorization` and `SessionClaimsFromContext` helpers for protected routes.

Routes:

- `/api/session` requires a Clerk bearer token.
- `/api/dashboard` requires a Clerk bearer token when Clerk is configured and returns preview data while Clerk is not configured.
- `/api/health` reports Postgres, Dragonfly/Redis, and Clerk configuration state.

The service sets conservative security headers, a Clerk-compatible content security policy, no-store API responses, strict method guards, and bounded server timeouts. Browser-rendered API data is written through DOM text nodes rather than HTML strings.

## Verify

```bash
go test ./...
go vet ./...
npm run build
```