|
| 1 | +# Tent of Trials -- CLAUDE.md |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +Tent of Trials is a trading and risk platform. It uses a polyglot multi-module build system powered by `python3 build.py`. **Always run `python3 build.py` after changes and include the diagnostic artifacts in your PR.** |
| 6 | + |
| 7 | +## Tech Stack Per Directory |
| 8 | + |
| 9 | +| Directory | Language | Build Command | Framework | |
| 10 | +|-----------|----------|--------------|-----------| |
| 11 | +| `backend/` | Rust | `cargo build` | Tokio + axum | |
| 12 | +| `frontend/` | TypeScript | `npm run build` | React + TanStack Query | |
| 13 | +| `market/` | Go | `go build -o market .` | Standard library | |
| 14 | +| `frailbox/` | C | `make` | Makefile | |
| 15 | +| `frailbox/engine/` | C++ | `cmake --build build` | CMake | |
| 16 | +| `compliance/` | Java | `javac -d build` | Standard library | |
| 17 | +| `v2/services/` | Ruby | `ruby -c market_stream.rb` | eventmachine | |
| 18 | +| `frailbox/nfc/` | Lua | `luac -p scanner.lua` | periphery | |
| 19 | +| `docs/openapi/` | Haskell | `ghc -fno-code` | Standard library | |
| 20 | +| `tools/` | Python | N/A (scripts) | Standard library | |
| 21 | + |
| 22 | +## Common Dev Commands |
| 23 | + |
| 24 | +``` |
| 25 | +python3 build.py # Build all modules |
| 26 | +python3 build.py -m backend # Build only the backend |
| 27 | +python3 build.py -m frontend,market # Build frontend and market |
| 28 | +python3 build.py --clean # Clean all build artifacts |
| 29 | +python3 build.py -v # Verbose output |
| 30 | +python3 build.py --list # List available modules |
| 31 | +python3 build.py --release # Release build (Rust only) |
| 32 | +python3 tools/health_check.py # Run health checks |
| 33 | +python3 tools/config_generator.py # Generate config |
| 34 | +python3 tools/terraform_import.py # Import Terraform resources |
| 35 | +``` |
| 36 | + |
| 37 | +Diagnostic artifacts are output to `diagnostic/build-<commit-id>.logd` and `diagnostic/build-<commit-id>.json`. |
| 38 | + |
| 39 | +## Coding Conventions |
| 40 | + |
| 41 | +### Python |
| 42 | +- Type hints required for all public functions |
| 43 | +- No `Any` as a type annotation |
| 44 | +- Use `dataclasses` for structured data |
| 45 | +- Use `pathlib.Path` over `os.path` |
| 46 | +- Return WARNING/CRITICAL/OK tuple pattern for health checks |
| 47 | +- Catch specific exceptions, not bare except |
| 48 | + |
| 49 | +### Rust |
| 50 | +- Use `anyhow::Result` for fallible functions |
| 51 | +- Clap for CLI argument parsing |
| 52 | +- Tracing with `EnvFilter` for logging |
| 53 | +- Modular structure: one module per concern |
| 54 | + |
| 55 | +### TypeScript |
| 56 | +- React 18 with TanStack Query for data fetching |
| 57 | +- React Router v6 for routing |
| 58 | +- Named exports preferred |
| 59 | + |
| 60 | +### Go |
| 61 | +- Standard Go project layout |
| 62 | +- `go.mod` for dependency management |
| 63 | + |
| 64 | +## Known Pitfalls |
| 65 | + |
| 66 | +1. **encryptly preflight**: Build requires encryptly to run. If it fails, increase timeout or check binary path. |
| 67 | +2. **Health check on macOS/Windows**: /proc/meminfo and /proc/loadavg are Linux-only; must use psutil/os.getloadavg() fallbacks. |
| 68 | +3. **Terraform hyphenated names**: Resource names with hyphens corrupt Terraform state. Always validate before import. |
| 69 | +4. **Missing prerequisites**: Each module needs specific tooling. Run `python3 build.py` to see what is missing. |
| 70 | +5. **Diagnostic artifacts**: Always commit diagnostic/ output in PRs. Maintainers may ask to remove them before merging. |
| 71 | + |
| 72 | +## Where to Start |
| 73 | + |
| 74 | +| Module | First File | |
| 75 | +|--------|-----------| |
| 76 | +| Backend | `backend/src/main.rs` | |
| 77 | +| Frontend | `frontend/src/main.tsx` | |
| 78 | +| Health Check | `tools/health_check.py` | |
| 79 | +| Build System | `build.py` | |
| 80 | +| Terraform Import | `tools/terraform_import.py` | |
| 81 | +| Log Aggregator | `tools/log_aggregator.py` | |
| 82 | + |
| 83 | +## Project Style |
| 84 | + |
| 85 | +Keep changes minimal and focused. Read existing patterns before writing new code. The build system and diagnostics are always required. One issue per PR. Use Conventional Commits format. |
0 commit comments