Skip to content

Commit 058c4b9

Browse files
Initial release — Sprout Nostr relay with enterprise extensions (#2)
1 parent f158b72 commit 058c4b9

153 files changed

Lines changed: 33675 additions & 24 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# =============================================================================
2+
# Sprout Backend — Local Development Environment
3+
# =============================================================================
4+
# Copy this file to .env and adjust as needed:
5+
# cp .env.example .env
6+
#
7+
# All defaults here work with `docker compose up` out of the box.
8+
#
9+
# Service ports (defaults):
10+
# MySQL → localhost:3306
11+
# Redis → localhost:6379
12+
# Typesense → localhost:8108
13+
# Adminer → localhost:8082 (DB browser UI)
14+
#
15+
# Note: If port 8082 conflicts, change the adminer port in docker-compose.yml
16+
# =============================================================================
17+
18+
# -----------------------------------------------------------------------------
19+
# Database (MySQL 8.0)
20+
# -----------------------------------------------------------------------------
21+
DATABASE_URL=mysql://sprout:sprout_dev@localhost:3306/sprout
22+
MYSQL_ROOT_PASSWORD=sprout_dev
23+
MYSQL_USER=sprout
24+
MYSQL_PASSWORD=sprout_dev
25+
MYSQL_DATABASE=sprout
26+
27+
# -----------------------------------------------------------------------------
28+
# Redis 7
29+
# -----------------------------------------------------------------------------
30+
REDIS_URL=redis://localhost:6379
31+
32+
# -----------------------------------------------------------------------------
33+
# Typesense (search)
34+
# -----------------------------------------------------------------------------
35+
TYPESENSE_API_KEY=sprout_dev_key
36+
TYPESENSE_URL=http://localhost:8108
37+
38+
# -----------------------------------------------------------------------------
39+
# Relay (WebSocket server)
40+
# -----------------------------------------------------------------------------
41+
# Bind address for the relay (host:port)
42+
SPROUT_BIND_ADDR=0.0.0.0:3000
43+
# Public WebSocket URL — used in NIP-42 auth challenges
44+
RELAY_URL=ws://localhost:3000
45+
# Set to true in production to require bearer token authentication
46+
SPROUT_REQUIRE_AUTH_TOKEN=false
47+
48+
# -----------------------------------------------------------------------------
49+
# Auth
50+
# -----------------------------------------------------------------------------
51+
# Set to false for dev (accepts NIP-42 without JWT, allows X-Pubkey header).
52+
# Set to true in production to require bearer token authentication.
53+
SPROUT_REQUIRE_AUTH_TOKEN=false
54+
55+
# JWKS endpoint for verifying JWT access tokens.
56+
# Claim that carries the user's Nostr public key (hex, 32 bytes).
57+
OKTA_PUBKEY_CLAIM=nostr_pubkey
58+
59+
# ── Keycloak (local OAuth testing — stands in for Okta in prod) ──────────────
60+
# Keycloak is NOT a production dependency. It lets you test the full OAuth
61+
# flow locally without needing an Okta tenant. Run `docker compose up -d`
62+
# then `./scripts/setup-keycloak.sh` to create the realm, client, and users.
63+
#
64+
# Admin UI: http://localhost:8180 (admin / admin)
65+
# Get a token:
66+
# curl -s -X POST http://localhost:8180/realms/sprout/protocol/openid-connect/token \
67+
# -d 'client_id=sprout-desktop&grant_type=password&username=tyler&password=password123' \
68+
# | jq -r .access_token
69+
OKTA_JWKS_URI=http://localhost:8180/realms/sprout/protocol/openid-connect/certs
70+
OKTA_ISSUER=http://localhost:8180/realms/sprout
71+
OKTA_AUDIENCE=sprout-desktop
72+
73+
# ── Okta (production / staging) ──────────────────────────────────────────────
74+
# Uncomment and fill in when deploying against a real Okta tenant.
75+
# OKTA_JWKS_URI=https://dev-example.okta.com/oauth2/default/v1/keys
76+
# OKTA_ISSUER=https://dev-example.okta.com/oauth2/default
77+
# OKTA_AUDIENCE=sprout-api
78+
# OKTA_PUBKEY_CLAIM=nostr_pubkey
79+
80+
# -----------------------------------------------------------------------------
81+
# Logging / Tracing
82+
# -----------------------------------------------------------------------------
83+
RUST_LOG=sprout_relay=debug,sprout_db=debug,sprout_auth=debug,sprout_pubsub=debug,tower_http=debug
84+
85+
# OTLP tracing endpoint (optional — leave unset to disable)
86+
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
87+
88+
# -----------------------------------------------------------------------------
89+
# sqlx (offline mode for Docker builds — set to true in CI/Docker)
90+
# -----------------------------------------------------------------------------
91+
SQLX_OFFLINE=false
92+
93+
# -----------------------------------------------------------------------------
94+
# Huddle (LiveKit integration)
95+
# -----------------------------------------------------------------------------
96+
# LIVEKIT_API_KEY=devkey
97+
# LIVEKIT_API_SECRET=devsecret
98+
# LIVEKIT_URL=ws://localhost:7880

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [main, release]
5+
pull_request:
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
check:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 30
14+
steps:
15+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
16+
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
17+
with:
18+
components: rustfmt, clippy
19+
- uses: Swatinem/rust-cache@ad397744b0d591a723ab90405b7247fac0e6b8db # v2
20+
- run: cargo fmt --all -- --check
21+
- run: cargo clippy --workspace --all-targets -- -D warnings
22+
- run: cargo test --workspace
23+
- run: cargo install cargo-audit --locked
24+
- run: cargo audit --ignore RUSTSEC-2023-0071 --ignore RUSTSEC-2024-0384
25+
- run: cargo install cargo-deny --locked
26+
- run: cargo deny check

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Build artifacts
2+
/target/
3+
4+
# Environment files (may contain secrets)
5+
.env
6+
.env.local
7+
.env.*.local
8+
9+
# Editor / IDE
10+
.idea/
11+
.vscode/
12+
*.swp
13+
*.swo
14+
*~
15+
.*.sw?
16+
17+
# OS artifacts
18+
.DS_Store
19+
Thumbs.db
20+
21+
# Scratch / working files (AI reviews, notes, drafts)
22+
.scratch/
23+
24+
# sqlx offline query data (generated, not portable)
25+
.sqlx/
26+
27+
# Docker volumes (if mounted locally)
28+
mysql-data/
29+
typesense-data/
30+
31+
# Hermit (toolchain manager cache)
32+
.hermit/
33+
doc/

0 commit comments

Comments
 (0)