diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000000000000000000000000000000000000..1ec1b54fb5398581f19fa7490bfaee526fbe046b --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,90 @@ +# CLAUDE.md - Hive Account Creator + +## Project Overview + +Hive Account Creator is a Node.js microservice that enables anonymous, fee-free account creation on the Hive blockchain. Users redeem one-time tokens to create accounts, with network fees covered by the API operator via configured creator accounts. + +**Key functionality:** +- Token-based account creation (one token = one account) +- Automatic cryptographic key generation (owner, active, posting, memo) +- Web-based signup UI with real-time validation +- SQLite token management + +## Tech Stack + +- **Runtime:** Node.js 18 LTS +- **Framework:** Express.js 4.18 +- **Database:** SQLite3 +- **Blockchain:** @hiveio/dhive (Hive blockchain client) +- **Frontend:** Bootstrap 5, jQuery 3.7.1 +- **Linting:** ESLint with airbnb-base config + +## Directory Structure + +``` +├── server.js # Main Express application, API endpoints +├── static/ # Frontend UI (index.html, CSS, JS, assets) +├── db/ # SQLite database storage +├── Dockerfile # Container build configuration +├── docker-compose.yml # Container orchestration +├── env.example # Environment variable template +└── .eslintrc # ESLint configuration +``` + +## Development Commands + +```bash +npm install # Install dependencies +npm start # Start server (node server.js) +npm test # Not implemented +``` + +**Docker deployment:** +```bash +docker-compose up -d # Start containerized service +``` + +## Key Files + +| File | Purpose | +|------|---------| +| `server.js` | Express app, all API endpoints, token/account logic | +| `static/index.html` | Single-page signup UI with 3-step flow | +| `env.example` | Configuration template (copy to `.env`) | +| `.eslintrc` | ESLint rules (airbnb-base with relaxed settings) | + +## Configuration + +Environment variables (set in `.env`): + +| Variable | Description | +|----------|-------------| +| `TEST_MODE` | If "true", logs operations instead of broadcasting | +| `NUM_TOKENS` | Number of tokens to generate on first run | +| `HTTP_PORT` | Server port (default: 3000) | +| `CREATOR` | Hive account used to create new accounts | +| `CREATOR_KEY` | Private key for creator account (WIF format) | + +## API Endpoints + +| Endpoint | Method | Purpose | +|----------|--------|---------| +| `/signup/check` | POST | Validate token and account name availability | +| `/signup/confirm` | POST | Create account, return generated keys | +| `/ui/` | GET | Serve signup web interface | + +## Coding Conventions + +- **JavaScript only** (no TypeScript) +- **ESLint airbnb-base** with relaxed rules: + - `console.log` allowed for diagnostics + - No line length limit + - camelCase not enforced (snake_case OK) +- **Account name validation:** 3-16 chars, lowercase alphanumeric with `-` and `.` +- **Token format:** 16-char hex strings from `crypto.randomBytes(8)` + +## CI/CD Notes + +No CI/CD configuration present. Deploy via: +- Docker Compose (recommended for production) +- Direct `npm start` with reverse proxy for SSL