diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-03 17:02:31 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-03 17:02:31 +0000 |
| commit | d428baf30feec295870fadda2d335d1e7f89507b (patch) | |
| tree | 4d23e3a3fabb2512f903b778fb77fed97b805832 /README.md | |
docs: one-prompt architecture plan
ok 2 prompts, the second one was about the test strategy so we could
reuse it. I was thinking of a tool like blossom audit. but i didnt
mention it specifically.
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 185 |
1 files changed, 185 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..4672d8c --- /dev/null +++ b/README.md | |||
| @@ -0,0 +1,185 @@ | |||
| 1 | # ngit-grasp | ||
| 2 | |||
| 3 | A [GRASP](https://gitworkshop.dev/danconwaydev.com/grasp) (Git Relays Authorized via Signed-Nostr Proofs) implementation in Rust. | ||
| 4 | |||
| 5 | ## Overview | ||
| 6 | |||
| 7 | `ngit-grasp` is a Rust-based implementation of the GRASP protocol, which enables decentralized Git repository hosting with Nostr-based authorization. This implementation combines: | ||
| 8 | |||
| 9 | - **Git Smart HTTP Backend**: Serves Git repositories over HTTP | ||
| 10 | - **Nostr Relay**: Stores and validates repository announcements and state events | ||
| 11 | - **Integrated Authorization**: Validates Git pushes against Nostr state events without requiring external hooks | ||
| 12 | |||
| 13 | Unlike the reference implementation ([ngit-relay](https://gitworkshop.dev/npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit-relay)) which uses nginx + git-http-backend + pre-receive hooks + Khatru (Go), `ngit-grasp` provides a unified Rust service that handles both Git and Nostr protocols natively. | ||
| 14 | |||
| 15 | ## Status | ||
| 16 | |||
| 17 | **ALPHA** - Under active development. API and architecture subject to change. | ||
| 18 | |||
| 19 | ## Key Features | ||
| 20 | |||
| 21 | - **Pure Rust Implementation**: Single binary, no external dependencies beyond Git itself | ||
| 22 | - **Integrated Authorization**: Push validation happens inline during the Git receive-pack operation | ||
| 23 | - **GRASP-01 Compliant**: Core service requirements for Git hosting with Nostr authorization | ||
| 24 | - **Extensible Architecture**: Designed to support GRASP-02 (Proactive Sync) and GRASP-05 (Archive) extensions | ||
| 25 | - **Developer-Friendly**: Built with modern Rust async patterns using tokio and actix-web | ||
| 26 | |||
| 27 | ## Architecture Highlights | ||
| 28 | |||
| 29 | The key architectural decision is **inline authorization** rather than Git hooks: | ||
| 30 | |||
| 31 | - The `git-http-backend` crate provides low-level access to the Git protocol | ||
| 32 | - We intercept the `git-receive-pack` operation before spawning the Git process | ||
| 33 | - Push validation happens by checking the Nostr relay for the latest state event | ||
| 34 | - Only matching pushes are forwarded to the actual Git repository | ||
| 35 | |||
| 36 | This approach provides: | ||
| 37 | - **Better error messages**: Direct HTTP responses vs. hook stderr | ||
| 38 | - **Simpler deployment**: No hook management or symlinks | ||
| 39 | - **Tighter integration**: Shared state between Git and Nostr components | ||
| 40 | - **Easier testing**: Pure Rust unit and integration tests | ||
| 41 | |||
| 42 | ## GRASP Compliance | ||
| 43 | |||
| 44 | ### GRASP-01 (Core Service Requirements) | ||
| 45 | - ✅ NIP-01 compliant Nostr relay at `/` | ||
| 46 | - ✅ Accepts NIP-34 repository announcements and state events | ||
| 47 | - ✅ Git Smart HTTP service at `/<npub>/<identifier>.git` | ||
| 48 | - ✅ Push validation against Nostr state events | ||
| 49 | - ✅ Multi-maintainer support via recursive maintainer sets | ||
| 50 | - ✅ Support for `refs/nostr/<event-id>` for PRs | ||
| 51 | - ✅ CORS support for web-based Git clients | ||
| 52 | - ✅ NIP-11 relay information document | ||
| 53 | |||
| 54 | ### GRASP-02 (Proactive Sync) - Planned | ||
| 55 | - 🔄 Proactive event sync from listed relays | ||
| 56 | - 🔄 Proactive Git data sync from listed clone URLs | ||
| 57 | - 🔄 PR data fetching and serving | ||
| 58 | |||
| 59 | ### GRASP-05 (Archive) - Planned | ||
| 60 | - 🔄 Accept repositories not listing this instance | ||
| 61 | - 🔄 Backup/mirror mode operation | ||
| 62 | |||
| 63 | ## Technology Stack | ||
| 64 | |||
| 65 | - **Rust**: Core language | ||
| 66 | - **actix-web**: HTTP server framework | ||
| 67 | - **git-http-backend**: Git protocol handling | ||
| 68 | - **nostr-relay-builder**: Nostr relay infrastructure from rust-nostr | ||
| 69 | - **nostr-sdk**: Nostr event handling and validation | ||
| 70 | - **tokio**: Async runtime | ||
| 71 | |||
| 72 | ## Quick Start | ||
| 73 | |||
| 74 | ```bash | ||
| 75 | # Clone the repository | ||
| 76 | git clone https://gitworkshop.dev/ngit-grasp | ||
| 77 | cd ngit-grasp | ||
| 78 | |||
| 79 | # Build | ||
| 80 | cargo build --release | ||
| 81 | |||
| 82 | # Configure | ||
| 83 | cp .env.example .env | ||
| 84 | # Edit .env with your settings | ||
| 85 | |||
| 86 | # Run | ||
| 87 | cargo run --release | ||
| 88 | ``` | ||
| 89 | |||
| 90 | ## Configuration | ||
| 91 | |||
| 92 | Environment variables (see `.env.example`): | ||
| 93 | |||
| 94 | - `NGIT_DOMAIN`: Your domain (e.g., `gitnostr.com`) | ||
| 95 | - `NGIT_OWNER_NPUB`: Relay owner's npub | ||
| 96 | - `NGIT_RELAY_NAME`: Relay name for NIP-11 | ||
| 97 | - `NGIT_RELAY_DESCRIPTION`: Relay description | ||
| 98 | - `NGIT_GIT_DATA_PATH`: Path to store Git repositories | ||
| 99 | - `NGIT_RELAY_DATA_PATH`: Path to store Nostr events | ||
| 100 | - `NGIT_BIND_ADDRESS`: Server bind address (default: `127.0.0.1:8080`) | ||
| 101 | |||
| 102 | ## Development | ||
| 103 | |||
| 104 | See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for detailed architecture documentation and [docs/TEST_STRATEGY.md](docs/TEST_STRATEGY.md) for comprehensive testing approach. | ||
| 105 | |||
| 106 | ```bash | ||
| 107 | # Run tests | ||
| 108 | cargo test | ||
| 109 | |||
| 110 | # Run compliance tests | ||
| 111 | cargo test --test compliance | ||
| 112 | |||
| 113 | # Run with logging | ||
| 114 | RUST_LOG=debug cargo run | ||
| 115 | |||
| 116 | # Check code | ||
| 117 | cargo clippy | ||
| 118 | cargo fmt --check | ||
| 119 | |||
| 120 | # Generate test coverage | ||
| 121 | cargo tarpaulin --out Html | ||
| 122 | ``` | ||
| 123 | |||
| 124 | ## Project Structure | ||
| 125 | |||
| 126 | ``` | ||
| 127 | ngit-grasp/ | ||
| 128 | ├── src/ | ||
| 129 | │ ├── main.rs # Entry point, server setup | ||
| 130 | │ ├── git/ | ||
| 131 | │ │ ├── mod.rs # Git module | ||
| 132 | │ │ ├── handler.rs # Git HTTP handlers | ||
| 133 | │ │ └── authorization.rs # Push validation logic | ||
| 134 | │ ├── nostr/ | ||
| 135 | │ │ ├── mod.rs # Nostr module | ||
| 136 | │ │ ├── relay.rs # Relay setup and policies | ||
| 137 | │ │ └── events.rs # Event handlers | ||
| 138 | │ ├── storage/ | ||
| 139 | │ │ ├── mod.rs # Storage abstraction | ||
| 140 | │ │ └── repository.rs # Repository management | ||
| 141 | │ └── config.rs # Configuration | ||
| 142 | ├── docs/ | ||
| 143 | │ └── ARCHITECTURE.md # Detailed architecture | ||
| 144 | ├── tests/ | ||
| 145 | │ ├── integration/ # Integration tests | ||
| 146 | │ └── fixtures/ # Test data | ||
| 147 | └── README.md | ||
| 148 | ``` | ||
| 149 | |||
| 150 | ## Comparison with ngit-relay | ||
| 151 | |||
| 152 | | Feature | ngit-relay (Go) | ngit-grasp (Rust) | | ||
| 153 | |---------|----------------|-------------------| | ||
| 154 | | Language | Go | Rust | | ||
| 155 | | Components | nginx + git-http-backend + hooks + Khatru | Single integrated binary | | ||
| 156 | | Authorization | Pre-receive Git hook | Inline during receive-pack | | ||
| 157 | | Deployment | Docker + supervisord | Single binary | | ||
| 158 | | Testing | Go tests + shell scripts | Rust unit + integration tests | | ||
| 159 | | Performance | Good | Excellent (zero-copy, async) | | ||
| 160 | |||
| 161 | ## Contributing | ||
| 162 | |||
| 163 | Contributions welcome! Please: | ||
| 164 | |||
| 165 | 1. Read [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) | ||
| 166 | 2. Open an issue to discuss major changes | ||
| 167 | 3. Follow Rust conventions and run `cargo fmt` + `cargo clippy` | ||
| 168 | 4. Add tests for new functionality | ||
| 169 | |||
| 170 | ## License | ||
| 171 | |||
| 172 | MIT License - see [LICENSE](LICENSE) for details | ||
| 173 | |||
| 174 | ## Related Projects | ||
| 175 | |||
| 176 | - [GRASP Protocol](https://gitworkshop.dev/danconwaydev.com/grasp) - Protocol specification | ||
| 177 | - [ngit-relay](https://gitworkshop.dev/npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit-relay) - Reference implementation in Go | ||
| 178 | - [ngit](https://gitworkshop.dev/ngit) - Nostr Git plugin for git CLI | ||
| 179 | - [NIP-34](https://nips.nostr.com/34) - Git Stuff (Nostr protocol) | ||
| 180 | |||
| 181 | ## Acknowledgments | ||
| 182 | |||
| 183 | - Reference implementation by [@DanConwayDev](https://gitworkshop.dev/danconwaydev.com) | ||
| 184 | - [rust-nostr](https://github.com/rust-nostr/nostr) team for excellent Nostr libraries | ||
| 185 | - Git community for the Smart HTTP protocol | ||