Moheeb Zara de51000584 feat: forum, polymorphic comments, custom tiers, multi-invite, secrets encryption
Big feature batch driven by the super-audit findings and the user's
follow-up requests.

Schema migration 021 (folded into schema.sql Section 13):
- forum_threads + polymorphic comments table keyed on (entity_type,
  entity_id). Entity types: forum_thread, proposal, incident, policy.
  Trigger maintains forum_threads.comment_count and last_comment_at.
- space_tiers per-space with monthly_price_cents, billing_cadence,
  is_system, sort_order. Trigger seeds plus/basic/associate on every
  space INSERT and backfills existing spaces. space_members.tier_id FK
  added and backfilled from the legacy enum value.
- space_role_labels (rename/recolor built-in roles per space).
  space_custom_roles + space_member_custom_roles for non-privileged
  extra labels. RLS gates by admin/board.
- space_invites: multi-code invites with expires_at, max_uses,
  uses_count, is_enabled. Legacy spaces.invite_code backfilled as a
  permanent enabled invite.
- secrets.encrypted_value bytea + encryption_version. Secrets RLS
  tightened. New comms_channels INSERT policy: any member can create;
  default channels are protected from deletion.
- knowledge_base.render_markdown boolean (default true).

Secrets encryption-at-rest:
- AES-256-GCM in lib/secrets/crypto.ts. Master key from
  SECRETS_ENCRYPTION_KEY env (64 hex chars).
- New revealSecret(id) server action: only path to plaintext, writes
  secret.revealed to activity_log.
- /ops/page.tsx no longer selects value or encrypted_value on the list
  endpoint - the original screenshot bug where ciphertext was already
  in the page bundle before "Reveal" is fixed.

UI:
- /forum index, /forum/new, /forum/[id]. Pin/lock/delete actions for
  admin/board.
- CommentThread component embedded on /proposals/[id], /incidents/[id],
  /policies/[slug]. Markdown rendering via react-markdown + remark-gfm.
- /comms sidebar: inline "+ New channel" form.
- /ops KB: row click opens markdown-rendering viewer modal.
- /settings: new Tiers tab and Invites tab. Inline price edit and
  archive/delete on tiers; copy/enable/disable/delete on invites.
- AtlasLogo replaces the terminal icon on the landing nav and footer.
  public/logo.svg wired as the favicon in app/layout.tsx metadata.
- Sidebar has a Forum nav link.

Server actions added:
- lib/actions/forum.ts, comms.ts, tiers.ts, roles.ts, invites.ts.
- lib/actions/secrets.ts rewritten with updateSecret + revealSecret.

Auth flow:
- joinSpace honors codes from space_invites first (enabled, expiry,
  use cap), falls back to legacy spaces.invite_code, increments
  uses_count on success.

Env:
- SECRETS_ENCRYPTION_KEY documented in .env.example and set on the
  Droplet's /opt/hackerspace-ops/.env.production.

README: live site link added (https://hackerspace.sh).

266/266 unit tests pass. Production build clean. Migration 021 will be
applied on the next deploy via /opt/hackerspace-ops/deploy.sh's
idempotent migration runner.
2026-05-14 17:47:52 -07:00
2026-03-11 04:44:48 +00:00
2026-03-11 04:44:48 +00:00
2026-03-11 04:44:48 +00:00
2026-03-11 04:44:48 +00:00
2026-03-11 08:00:22 +00:00

hackerspace-management

License: MIT Next.js Supabase

A multi-tenant operating system for hackerspaces, makerspaces, and member-run shops. One installation can host many independent spaces. Each space owns its own members, tasks, projects, payments, knowledge base, proposals, incidents, policies, and chat channels. All data access is enforced at the database with row-level security.

Features

  • Members and tiers. Roster, tiers (Plus, Basic, Associate), roles (admin, board, treasurer, member, associate), state (current, late, inactive, unverified), per-member skills, certifications, and badges.
  • Tasks and projects. Project boards, task assignment, status, area tagging, priority, comments.
  • Operations. Knowledge base, secrets vault, area leads, equipment, maintenance log.
  • Payments and financials. Per-member payment ledger, integration credentials per space, exports, monthly financial summary.
  • Governance. Proposals with vote tracking and expiry, incident reports, policy library, area-of-interest configuration.
  • Communications. Multi-channel chat with realtime delivery.
  • Recruitment. Public-facing recruitment page per space.
  • API. PostgREST-generated REST for every table, gated by RLS. Optional webhooks with HMAC-signed deliveries.

Stack

Layer Technology
App Next.js 16, React 19, TypeScript, Tailwind v4, shadcn/ui
Data PostgreSQL 17 via self-hosted Supabase
Auth Supabase GoTrue, JWT, email + password
Realtime Supabase Realtime (Phoenix channels over WebSocket)
Storage Block volume on the host (database), local FS (uploads)
Email Resend (SMTP)
Reverse proxy Caddy 2 (automatic Let's Encrypt)
Tests Vitest (unit), Playwright (end to end)

Quick start (local development)

Requirements: Node.js 20 or later, pnpm 10 or later, Docker (for the local Supabase CLI), git.

git clone https://github.com/virgilvox/hackerspace-management.git
cd hackerspace-management
pnpm install
cp .env.example .env.local

Edit .env.local with values from your local Supabase project (see docs/LOCAL_DEV.md to start one in seconds using the Supabase CLI), then:

pnpm dev

Open http://localhost:3000, sign up, create a space, you land on the dashboard.

Detailed local setup: docs/LOCAL_DEV.md.

Production deployment

The supported production target is a single DigitalOcean Droplet running self-hosted Supabase plus the Next.js app behind Caddy with Let's Encrypt. No managed Supabase, no third-party application data store.

End-to-end guide: docs/DEPLOY_DO_SELFHOSTED.md.

Summary:

  1. Provision a Droplet (4 GB RAM, 2 vCPU, 80 GB disk recommended).
  2. Attach a block volume mounted at /mnt/data for the Postgres data directory and backups.
  3. Point DNS A records for your domain, www, supabase, studio at the Droplet.
  4. Run the bootstrap script in scripts/ to install Docker, Supabase, Node, Caddy, the app, the systemd unit, backup cron, and the deploy hook.
  5. Push to main. GitHub Actions runs deploy.sh on the Droplet over SSH: pull, install, apply pending migrations, build, restart.

The deploy script is idempotent and tracked: every numbered migration in scripts/ is recorded in public._migrations_applied. New migrations are applied automatically on push.

Database

scripts/schema.sql is the canonical, idempotent, full schema. Run it once on a fresh Supabase project. Subsequent changes are added as numbered migrations (scripts/021_*.sql, 022_*.sql, etc.) and applied incrementally.

Topic Doc
Conventions scripts/README.md
Full reference docs/DATABASE_SCHEMA.md
Column map DB_SCHEMA_MAP.md

Documentation

File Contents
docs/ARCHITECTURE.md System design, project structure, auth flow
docs/DATABASE_SCHEMA.md Tables, enums, indexes, RLS policies
docs/API_REFERENCE.md Server actions and REST endpoints
docs/COMPONENT_REFERENCE.md UI components and props
docs/DEPLOY_DO_SELFHOSTED.md End to end production deploy
docs/LOCAL_DEV.md Fresh clone to running locally
docs/GOVERNANCE_FEATURES.md Proposals, incidents, policies
docs/WEBHOOKS.md Webhook payload, signing, verification
TESTING.md Test commands and coverage
CONTRIBUTING.md How to contribute
CHANGELOG.md Notable changes per release
SECURITY.md Vulnerability disclosure
LICENSE MIT

Scripts

pnpm dev          # development server
pnpm build        # production build
pnpm start        # serve production build
pnpm lint         # eslint
pnpm test         # vitest watch mode
pnpm test:ui      # vitest UI
pnpm test:e2e     # playwright end-to-end

Project status

The system is feature-functional and serving production traffic at hackerspace.sh. See docs/AUDIT.md for the latest audit and the open issues list.

Contributing

Contributions are welcome. Please read CONTRIBUTING.md before opening a pull request. Security issues: see SECURITY.md.

License

MIT. See LICENSE.

S
Description
No description provided
Readme MIT
3.8 MiB
Languages
TypeScript 89.7%
PLpgSQL 6.4%
CSS 1.8%
JavaScript 1.3%
Shell 0.7%
Other 0.1%