|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Hypergraph is a local-first framework for building web3 consumer applications that focuses on privacy-preserving apps with interoperable data using the GRC-20 standard. The project is currently in Developer Preview status. |
| 8 | + |
| 9 | +## Common Development Commands |
| 10 | + |
| 11 | +### Development |
| 12 | +```bash |
| 13 | +# Run specific apps |
| 14 | +cd apps/events && pnpm dev # Events demo app |
| 15 | +cd apps/server && pnpm dev # Backend sync server |
| 16 | +cd apps/typesync && pnpm dev # TypeSync development |
| 17 | +cd apps/connect && pnpm dev # Geo Connect auth app |
| 18 | +``` |
| 19 | + |
| 20 | +### Testing |
| 21 | +```bash |
| 22 | +pnpm test # Run all tests with Vitest |
| 23 | +vitest # Direct vitest usage |
| 24 | +vitest run path/to/test.ts # Run specific test file |
| 25 | +``` |
| 26 | + |
| 27 | +### Linting & Type Checking |
| 28 | +```bash |
| 29 | +pnpm lint # Check code with Biome |
| 30 | +pnpm lint:fix # Auto-fix linting issues |
| 31 | +pnpm check # TypeScript type checking |
| 32 | +``` |
| 33 | + |
| 34 | +### Database |
| 35 | +```bash |
| 36 | +pnpm db:migrate:dev # Run database migrations |
| 37 | +pnpm db:studio # Open Prisma Studio |
| 38 | +``` |
| 39 | + |
| 40 | +### Building |
| 41 | +```bash |
| 42 | +pnpm build # Build all packages and apps |
| 43 | +pnpm clean # Clean all build artifacts |
| 44 | +``` |
| 45 | + |
| 46 | +## High-Level Architecture |
| 47 | + |
| 48 | +### Monorepo Structure |
| 49 | +- **packages/** - Core libraries |
| 50 | + - `hypergraph/` - Main SDK with entity management, encryption, spaces, and inboxes |
| 51 | + - `hypergraph-react/` - React hooks and components |
| 52 | + - `typesync/` - Schema management utilities |
| 53 | +- **apps/** - Complete applications |
| 54 | + - `server/` - Backend sync server (Express + Prisma + SQLite/PostgreSQL) |
| 55 | + - `events/` - Demo app showcasing the framework (Vite + React) |
| 56 | + - `connect/` - Geo Connect authentication app |
| 57 | + - `typesync/` - CLI and web interface for schema development |
| 58 | + - `create-hypergraph/` - Project scaffolding tool |
| 59 | + - `next-example/` - Next.js integration example |
| 60 | +- **docs/** - Docusaurus documentation site |
| 61 | + |
| 62 | +### Core Architecture Patterns |
| 63 | + |
| 64 | +1. **Local-First with CRDTs** |
| 65 | + - Uses Automerge for conflict-free replicated data types |
| 66 | + - Offline-capable with sync when online |
| 67 | + - Data stored locally with optional server sync |
| 68 | + |
| 69 | +2. **Privacy-Preserving** |
| 70 | + - Client-side encryption/decryption |
| 71 | + - Uses Noble cryptographic libraries |
| 72 | + - Secure key management patterns |
| 73 | + |
| 74 | +3. **Space-Based Organization** |
| 75 | + - User data organized in "spaces" (private/public) |
| 76 | + - Each space has its own encryption keys |
| 77 | + - Spaces can be shared with other users |
| 78 | + |
| 79 | +4. **Identity Management** |
| 80 | + - Ethereum-based authentication with Privy |
| 81 | + - Smart account support via Permissionless |
| 82 | + |
| 83 | +5. **Knowledge Graph (GRC-20)** |
| 84 | + - Structured data format for interoperability |
| 85 | + - Entity-based data model |
| 86 | + - Schema-driven development with TypeSync |
| 87 | + |
| 88 | +### Key Technologies |
| 89 | +- **TypeScript** with strict mode |
| 90 | +- **Effect** for functional programming patterns |
| 91 | +- **React** for UI applications |
| 92 | +- **Automerge** for CRDT implementation |
| 93 | +- **Viem** for Ethereum interactions |
| 94 | +- **Prisma** for database ORM |
| 95 | +- **GraphQL** for API queries |
| 96 | +- **Biome** for linting/formatting |
| 97 | + |
| 98 | +### Development Patterns |
| 99 | + |
| 100 | +1. **Effect Usage** |
| 101 | + - Use Effect for error handling and async operations |
| 102 | + - Prefer functional patterns with immutable data |
| 103 | + - Use Effect testing utilities in tests |
| 104 | + |
| 105 | +2. **Module Structure** |
| 106 | + - Each module exports clear public API |
| 107 | + - Use barrel exports (index.ts) |
| 108 | + - Separate concerns by feature |
| 109 | + |
| 110 | +3. **Testing Strategy** |
| 111 | + - Tests in `./test` directories |
| 112 | + - Test both success and error scenarios |
| 113 | + - Mock external dependencies appropriately |
| 114 | + |
| 115 | +4. **Type Safety** |
| 116 | + - Use branded types for domain identifiers |
| 117 | + - Discriminated unions for state management |
| 118 | + - Strict TypeScript configuration |
| 119 | + |
| 120 | +5. **Naming Conventions** |
| 121 | + - snake_case for service names and API endpoints |
| 122 | + - camelCase for variables and functions |
| 123 | + - PascalCase for types and components |
0 commit comments