Skip to content

pubky/homegate

Repository files navigation

Homegate

This is a two day hackathon project. DO NOT USE IN PRODUCTION.

A monorepo for the Homegate project - your gateway to sign up and join the Pubky homeserver network.

Live demo for the Staging homeserver: homegate.live

Features

  • Three-tier signup system: Free (math captcha), Basic (50k sats), Pro (200k sats)
  • Bot protection with math captcha verification and SMS verification via Prelude
  • Lightning Network payments for Basic and Pro plans
  • Real-time payment notifications via WebSocket
  • Invite code generation system for homeserver access
  • Simple user profile creation with a name and image
  • Sign in with an existing user
  • User dashboard showing the user's plan

External Dependencies

πŸš€ Quick Start

# Start with Docker (recommended)
make dev              # Development mode with logs
# or
make up               # Background mode

# Access: http://localhost:8882 (frontend)

Add the PRELUDE_API_TOKEN to front-end/.env.local for SMS verification.

That's it! The frontend and backend and phoenixd will be running.

Project Structure

homegate/
β”œβ”€β”€ front-end/         # Next.js 16 web application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/       # Next.js App Router pages and API routes
β”‚   β”‚   β”œβ”€β”€ components/ # React components and UI elements
β”‚   β”‚   β”œβ”€β”€ contexts/  # React context providers
β”‚   β”‚   β”œβ”€β”€ hooks/     # Custom React hooks
β”‚   β”‚   └── lib/       # Utility functions and configurations
β”‚   └── public/        # Static assets
β”œβ”€β”€ back-end/          # Express.js API server
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controllers/ # Request handlers
β”‚   β”‚   β”œβ”€β”€ routes/     # API route definitions
β”‚   β”‚   └── services/   # Business logic and WebSocket service
β”‚   └── dist/          # Compiled TypeScript output
└── phoenixd/          # Phoenix Lightning node data (git-ignored)

Packages

🎨 Front-end

Next.js 16 web application with shadcn/ui for the homeserver signup gateway.

Tech Stack:

  • Next.js 16.0.0 with App Router
  • React 19.2.0
  • TypeScript 5 (strict mode)
  • Tailwind CSS v4
  • shadcn/ui components (button, dialog)
  • @prelude.so/sdk for SMS verification
  • @synonymdev/pubky for Pubky integration
  • React Hook Form with Zod validation
  • Lucide React icons

Get Started:

cd front-end
npm install
npm run dev

See the front-end directory for detailed documentation.

βš™οΈ Back-end

Express.js REST API server with WebSocket support for handling Lightning invoices and payments.

Tech Stack:

  • Express.js 4.21.2
  • TypeScript 5.7.2
  • WebSocket support (ws package)
  • Phoenix daemon integration
  • CORS enabled
  • ts-node-dev for development

API Endpoints:

  • /health - Health check with WebSocket status
  • /api/invoice - Lightning invoice management
  • /api/webhook - Webhook handling
  • /ws - WebSocket connection for real-time updates

Get Started:

cd back-end
npm install
npm run dev

See the back-end directory for detailed documentation.

Development

Prerequisites

  • Node.js 18+ (for local development)
  • npm, yarn, or pnpm (for local development)
  • Docker & Docker Compose (for containerized development)

Option 1: Docker (Recommended) 🐳

The easiest way to run the entire stack:

# Quick start with Makefile
make dev              # Start with logs (recommended for development)
make up               # Start in background

# Or use Docker Compose directly
docker compose up     # Start with logs
docker compose up -d  # Start in background

Access the application:

Other useful commands:

make logs      # View logs
make down      # Stop services
make restart   # Restart services
make help      # See all available commands

See the docker-compose.yml file for complete Docker configuration.

Option 2: Local Development

  1. Clone the repository
git clone <repository-url>
cd homegate
  1. Set up the frontend
cd front-end
npm install
npm run dev
  1. Open your browser

Monorepo Structure

This is set up as a monorepo to accommodate multiple packages:

  • front-end: Next.js web application
  • back-end: Express.js API server
  • phoenixd: Lightning Network node (managed by Docker)

Docker Services

The project includes Docker Compose configuration with the following services:

🌐 Frontend Service

  • Port: 8882
  • Container: Next.js 16 application
  • Features: Hot reload, volume mounting for live development
  • Image: Custom build from front-end/Dockerfile

βš™οΈ Backend Service

  • Port: 8881
  • Container: Express.js API server with WebSocket support
  • Features: Hot reload with ts-node-dev, REST API endpoints, WebSocket connections
  • Image: Custom build from back-end/Dockerfile
  • Endpoints: /api/invoice, /api/webhook, /health, /ws

⚑ phoenixd Service

  • Port: 9740
  • Container: Lightning Network node
  • Features: Data persistence, automatic restart
  • Image: acinq/phoenixd:latest
  • Volume: ./phoenixd (automatically created, git-ignored)

Quick Commands

Command Description
make dev Start services with logs (best for development)
make up Start services in background
make down Stop all services
make logs View all logs
make frontend View frontend logs only
make backend View backend logs only
make phoenixd View phoenixd logs only
make restart Restart all services
make build Rebuild services
make clean Stop and remove everything
make shell Open shell in frontend container
make shell-be Open shell in backend container
make install Install npm packages in frontend
make npm-run Run npm commands in frontend
make help Show all available commands

πŸ’‘ Tip: Use make dev for active development to see logs in real-time.

About

Your Gateway to Freedom!

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages