|
| 1 | +# Contributing / Developer Guide |
| 2 | + |
| 3 | +This guide explains how to work on the Happy self-hosted setup. |
| 4 | + |
| 5 | +## Repository Structure |
| 6 | + |
| 7 | +This repo uses git submodules to combine three separate repositories: |
| 8 | + |
| 9 | +``` |
| 10 | +happy/ # React Native webapp (Expo) - rrnewton/happy fork |
| 11 | +happy-cli/ # CLI tool - rrnewton/happy-cli fork |
| 12 | +happy-server/ # Node.js server - rrnewton/happy-server fork |
| 13 | +``` |
| 14 | + |
| 15 | +Each submodule tracks `origin/rrnewton` (our fork) and can rebase on `upstream/main` (slopus upstream). |
| 16 | + |
| 17 | +## Branch Conventions |
| 18 | + |
| 19 | +- **Parent repo**: `happy` branch for mainline development |
| 20 | +- **Submodules**: `rrnewton` branch tracks our changes |
| 21 | +- **Features**: `happy-X` in parent, `feature-X` in submodules |
| 22 | + |
| 23 | +## Development Workflow |
| 24 | + |
| 25 | +### Inside the Container |
| 26 | + |
| 27 | +Once inside the devcontainer, use `happy-launcher.sh` to manage services: |
| 28 | + |
| 29 | +```bash |
| 30 | +./happy-launcher.sh start # Start all services (server + webapp) |
| 31 | +./happy-launcher.sh start-backend # Start backend only |
| 32 | +./happy-launcher.sh start-webapp # Start webapp only |
| 33 | +./happy-launcher.sh stop # Stop services |
| 34 | +./happy-launcher.sh status # Check what's running |
| 35 | +./happy-launcher.sh logs server # View server logs |
| 36 | +./happy-launcher.sh cleanup # Stop everything including databases |
| 37 | +``` |
| 38 | + |
| 39 | +### Slot System |
| 40 | + |
| 41 | +The launcher supports multiple isolated instances via `--slot`: |
| 42 | + |
| 43 | +```bash |
| 44 | +./happy-launcher.sh --slot 1 start # Slot 1: ports 10001-10004, DB handy_test_1 |
| 45 | +./happy-launcher.sh --slot 2 start # Slot 2: ports 10011-10014, DB handy_test_2 |
| 46 | +``` |
| 47 | + |
| 48 | +Slot 0 (default) uses standard ports (3005, 8081) and the `handy` database. |
| 49 | + |
| 50 | +### Running Tests |
| 51 | + |
| 52 | +```bash |
| 53 | +./scripts/validate.sh # Full validation (builds + unit + E2E) |
| 54 | +./scripts/validate.sh --quick # Quick mode (builds + unit tests only) |
| 55 | +``` |
| 56 | + |
| 57 | +## Makefile Targets |
| 58 | + |
| 59 | +```bash |
| 60 | +make build # Build all TypeScript (CLI and server) |
| 61 | +make server # Start all services |
| 62 | +make stop # Stop all services (daemon + cleanup all slots) |
| 63 | +make logs # View server logs |
| 64 | +make validate # Run validation tests |
| 65 | +make push # Push all repos to origin |
| 66 | +``` |
| 67 | + |
| 68 | +### Repository Management |
| 69 | + |
| 70 | +```bash |
| 71 | +make setup # Configure submodule remotes |
| 72 | +make status # Show branch status for all repos |
| 73 | +make rebase-upstream # Rebase submodules on upstream/main |
| 74 | +make feature-start FEATURE=name # Start feature branch |
| 75 | +make feature-end # End feature, return to mainline |
| 76 | +``` |
| 77 | + |
| 78 | +## Key Scripts |
| 79 | + |
| 80 | +| Script | Purpose | |
| 81 | +|--------|---------| |
| 82 | +| `happy-launcher.sh` | Main service control script | |
| 83 | +| `scripts/validate.sh` | CI validation (builds + tests) | |
| 84 | +| `scripts/setup-test-credentials.mjs` | Create test auth without browser | |
| 85 | +| `e2e-web-demo.sh` | Full E2E demo with browser tests | |
| 86 | + |
| 87 | +## Service URLs (Slot 0) |
| 88 | + |
| 89 | +| Service | URL | |
| 90 | +|---------|-----| |
| 91 | +| Server API | http://localhost:3005 | |
| 92 | +| Webapp | http://localhost:8081 | |
| 93 | +| MinIO Console | http://localhost:9001 (minioadmin/minioadmin) | |
| 94 | +| PostgreSQL | postgresql://postgres:postgres@localhost:5432/handy | |
| 95 | +| Redis | redis://localhost:6379 | |
| 96 | + |
| 97 | +## Environment Variables |
| 98 | + |
| 99 | +For CLI development: |
| 100 | + |
| 101 | +```bash |
| 102 | +export HAPPY_HOME_DIR=~/.happy-dev |
| 103 | +export HAPPY_SERVER_URL=http://localhost:3005 |
| 104 | +export HAPPY_WEBAPP_URL=http://localhost:8081 |
| 105 | +``` |
| 106 | + |
| 107 | +## Test Credentials (Headless Testing) |
| 108 | + |
| 109 | +For automated testing without a browser: |
| 110 | + |
| 111 | +```bash |
| 112 | +node scripts/setup-test-credentials.mjs |
| 113 | +``` |
| 114 | + |
| 115 | +This creates credentials in `~/.happy-dev-test/` by simulating the full auth flow. |
0 commit comments