{"id":47742648,"url":"https://github.com/bowber/mottomesh","last_synced_at":"2026-04-03T00:01:57.363Z","repository":{"id":337421533,"uuid":"1043715986","full_name":"bowber/mottomesh","owner":"bowber","description":"A Simple Template for Effective Communication using NATS.io as  central Message Broker","archived":false,"fork":false,"pushed_at":"2026-02-09T12:35:18.000Z","size":239,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-09T17:41:22.446Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bowber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-24T13:21:05.000Z","updated_at":"2026-02-09T12:35:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bowber/mottomesh","commit_stats":null,"previous_names":["bowber/mottomesh"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/bowber/mottomesh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bowber%2Fmottomesh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bowber%2Fmottomesh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bowber%2Fmottomesh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bowber%2Fmottomesh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bowber","download_url":"https://codeload.github.com/bowber/mottomesh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bowber%2Fmottomesh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31319743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T23:57:25.032Z","status":"ssl_error","status_checked_at":"2026-04-02T23:57:06.281Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-03T00:01:56.315Z","updated_at":"2026-04-03T00:01:57.344Z","avatar_url":"https://github.com/bowber.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MottoMesh\n\n\u003e A modern real-time communication framework with WebTransport and WebSocket support.\n\n## Architecture\n\n```\n┌─────────────┐   WebTransport/WS   ┌─────────────┐      NATS       ┌────────┐\n│   Browser   │ ─────────────────── │   Gateway   │ ──────────────  │ Server │\n│  (TS Client)│  https://443        │   (Rust)    │   tcp://4222    │ (Rust) │\n└─────────────┘                     └─────────────┘                 └────────┘\n      │                                    │\n      │ JWT Auth                           │ JWT Validation\n      ▼                                    │ Permission Checks\n┌─────────────┐                            │ Message Routing\n│ Auth Server │ ◄──────────────────────────┘\n│  (separate) │\n└─────────────┘\n```\n\n## Key Features\n\n- **WebTransport** (HTTP/3 over QUIC) with automatic **WebSocket fallback**\n- **JWT-based authentication** with flexible permission system\n- **NATS-style subject patterns** with wildcard support (`*` and `\u003e`)\n- **Bi-directional real-time communication** via pub/sub\n- **Request-reply pattern** support\n- **Motto-generated protocol + payload SDKs** from a single Rust schema\n- **Automatic reconnection** with subscription restoration\n\n## Project Structure\n\n```\nmottomesh/\n├── schema/                 # Motto source schema + generated SDKs\n│   ├── src/schema.rs       # Single source of truth for protocol + payload types\n│   └── generated/          # Generated Rust + TypeScript SDKs\n├── crates/\n│   ├── gateway/            # Gateway server (WebTransport + WebSocket)\n│   └── server/             # Backend service example\n├── client-ts/              # TypeScript client library\n├── example_web/            # Example SolidJS web app\n└── nats.conf               # NATS server configuration\n```\n\n## Getting Started\n\n### Prerequisites\n\n- [Rust](https://rustup.rs/) (edition 2024)\n- [nats-server](https://docs.nats.io/running-a-nats-service/introduction/installation)\n- [motto](https://crates.io/crates/motto) CLI (`cargo install motto --version 0.3.2`)\n- Node.js 18+\n\n### 1. Start NATS Server\n\n```bash\nnats-server -c nats.conf\n```\n\n### 2. Generate SDKs from Motto Schema\n\n```bash\n# one-command helper (defaults to patch bump)\n./scripts/regen-sdk.sh\n\n# optional: choose bump level\n./scripts/regen-sdk.sh minor\n```\n\n### 3. Start the Gateway\n\n```bash\n# Set the JWT secret (required)\nexport JWT_SECRET=\"your-secret-key\"\n\n# Optional: configure ports\nexport GATEWAY_PORT=4433  # WebTransport port (WebSocket on 4434)\nexport NATS_URL=localhost:4222\n\n# Run the gateway\ncargo run -p mottomesh-gateway\n```\n\n### 4. Start the Backend Server\n\n```bash\ncargo run -p mottomesh-server\n```\n\n### 5. Run the Example Web App\n\n```bash\ncd example_web\npnpm install\npnpm dev\n```\n\n## TypeScript Client Usage\n\n```typescript\nimport { MottomeshClient } from '@mottomesh/client';\nimport { encodeTestData, decodeTestData } from '@motto/schema';\n\n// Create client\nconst client = new MottomeshClient({\n  url: 'https://localhost:4433',\n  token: 'your-jwt-token',\n  transport: 'auto',  // WebTransport with WebSocket fallback\n});\n\n// Connect\nawait client.connect();\n\n// Subscribe to messages\nconst sub = client.subscribe('messages', (msg) =\u003e {\n  const data = decodeTestData(msg.payload);\n  console.log('Received:', data.name);\n});\n\n// Publish a message\nconst data = {\n  id: 1,\n  name: 'hello',\n  inner_data: {\n    id: [1, 1, 1],\n    name: ['hello', 'hello', 'hello'],\n  },\n};\nawait client.publish('messages', encodeTestData(data));\n\n// Clean up\nawait sub.unsubscribe();\nawait client.disconnect();\n```\n\n## JWT Token Format\n\nThe gateway expects JWT tokens with these claims:\n\n```json\n{\n  \"sub\": \"user-id\",\n  \"exp\": 1234567890,\n  \"iat\": 1234567890,\n  \"permissions\": [\"publish\", \"subscribe\", \"request\"],\n  \"allowed_subjects\": [\"messages.*\", \"user.\u003e\"],\n  \"deny_subjects\": [\"admin.*\"]\n}\n```\n\n### Subject Patterns\n\n- `*` matches a single token: `messages.*` matches `messages.user1` but not `messages.user1.inbox`\n- `\u003e` matches one or more tokens: `messages.\u003e` matches `messages.user1` and `messages.user1.inbox`\n\n## Environment Variables\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `JWT_SECRET` | (required) | Secret key for JWT validation |\n| `GATEWAY_HOST` | `0.0.0.0` | Host to bind gateway |\n| `GATEWAY_PORT` | `4433` | WebTransport port (WebSocket on port+1) |\n| `NATS_URL` | `localhost:4222` | NATS server URL |\n| `TLS_CERT_PATH` | (none) | Path to TLS certificate (auto-generates if not set) |\n| `TLS_KEY_PATH` | (none) | Path to TLS private key |\n\n## Development\n\n### Build Rust Workspace\n\n```bash\ncargo build\n```\n\n### Run Tests\n\n```bash\n# Run all Rust tests\ncargo test\n\n# Run TypeScript client tests\ncd client-ts\npnpm exec vitest run\n```\n\n### Build TypeScript Client\n\n```bash\ncd client-ts\npnpm build\n```\n\n### Type Checking\n\n```bash\n# TypeScript type checking\ncd client-ts\npnpm lint\n```\n\n## Key Dependencies\n\n- **[wtransport](https://github.com/BiagioFesta/wtransport)**: WebTransport implementation\n- **[axum](https://github.com/tokio-rs/axum)**: WebSocket server framework\n- **[async-nats](https://github.com/nats-io/nats.rs)**: NATS client\n- **[motto](https://crates.io/crates/motto)**: Schema-first multi-platform SDK generation\n\n## Future Enhancements\n\n- [ ] Connection rate limiting (sub-crate)\n- [ ] Metrics and observability\n- [ ] TLS certificate auto-renewal (ACME)\n- [ ] UniFFI bindings for mobile\n- [ ] napi-rs bindings for Node.js\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbowber%2Fmottomesh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbowber%2Fmottomesh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbowber%2Fmottomesh/lists"}