|
| 1 | +--- |
| 2 | +name: coremq-guide |
| 3 | +description: Reference for navigating the CoreMQ project — directory layout, build commands, default ports, where things live across the Rust broker and React dashboard. TRIGGER when user asks about project structure, where to put files, or how the server and client connect. |
| 4 | +--- |
| 5 | + |
| 6 | +# CoreMQ Project Guide |
| 7 | + |
| 8 | +Cargo workspace + Vite-React app. One Rust crate (the broker), one TS app (the dashboard). |
| 9 | + |
| 10 | +For deep conventions (TypeScript types, Zustand store shape, API routes, theme tokens, AdminCommand pattern), see `.claude/skills.md` — it's the canonical project doc. |
| 11 | + |
| 12 | +## Structure |
| 13 | + |
| 14 | +``` |
| 15 | +coremq-rust/ |
| 16 | +├── server/coremq-server/ — Rust MQTT broker (Tokio, Axum, ReDB, Casbin) |
| 17 | +│ └── src/ |
| 18 | +│ ├── api/ — Axum REST API (controllers, router, auth) |
| 19 | +│ ├── engine/ — Core event loop + command enums + workers |
| 20 | +│ ├── services/ — session, topic, jwt |
| 21 | +│ ├── protocol/ — MQTT 3.1.1 / 5 wire protocol |
| 22 | +│ ├── transport/ — TCP / TLS / WebSocket listeners |
| 23 | +│ ├── storage/ — ReDB persistence |
| 24 | +│ ├── models/ — Serde structs (api/, engine/) |
| 25 | +│ └── main.rs |
| 26 | +├── client/ — React 19 + TS + MUI 7 + Zustand admin dashboard |
| 27 | +│ └── src/ |
| 28 | +│ ├── pages/ — thin route wrappers |
| 29 | +│ ├── sections/ — feature views (UI + logic) |
| 30 | +│ ├── stores/ — Zustand state |
| 31 | +│ ├── services/ — axios API calls |
| 32 | +│ ├── types/ — TypeScript types |
| 33 | +│ ├── theme/ — MUI dark theme |
| 34 | +│ └── 118n/ — en.json, ko.json, uz.json |
| 35 | +├── docs/ — ARCHITECTURE.md, COREMQ_AI_NATIVE_PLATFORM.md, drawio diagrams |
| 36 | +├── tests/ — integration / stress / qos tests |
| 37 | +├── Cargo.toml — workspace root |
| 38 | +├── Makefile — `make dev` / `server` / `client` / `fmt` / `lint` / `fix` |
| 39 | +└── .claude/skills.md — full project conventions |
| 40 | +``` |
| 41 | + |
| 42 | +## Common Commands |
| 43 | + |
| 44 | +| What | Command | |
| 45 | +| --------------------- | ------------------------------------------------ | |
| 46 | +| Run both | `make dev` | |
| 47 | +| Run broker only | `make server` (= `cargo run -p coremq-server`) | |
| 48 | +| Run frontend only | `make client` (= `cd client && yarn dev`) | |
| 49 | +| Install everything | `make setup` | |
| 50 | +| Build broker | `cargo build -p coremq-server` | |
| 51 | +| Test broker | `cargo test -p coremq-server` | |
| 52 | +| Format Rust | `cargo fmt -p coremq-server` | |
| 53 | +| Lint Rust | `cargo clippy -p coremq-server --all-targets` | |
| 54 | +| Format frontend | `make fmt` | |
| 55 | +| Lint frontend | `make lint` | |
| 56 | +| Lint + format fix | `make fix` | |
| 57 | + |
| 58 | +## Default Ports |
| 59 | + |
| 60 | +| Service | Port | |
| 61 | +| ------------- | ------- | |
| 62 | +| MQTT TCP | `1883` | |
| 63 | +| MQTT TLS | `8883` | |
| 64 | +| MQTT WebSocket| `8083` | |
| 65 | +| REST API | `18083` | |
| 66 | +| Frontend dev | `3039` | |
| 67 | + |
| 68 | +## Default Credentials |
| 69 | + |
| 70 | +Username: `admin` / Password: `public` |
| 71 | + |
| 72 | +## Cross-cutting Wiring |
| 73 | + |
| 74 | +The broker and dashboard talk over two channels: |
| 75 | + |
| 76 | +- **REST API** (`http://localhost:18083/api/v1/...`) — admin operations: list sessions/topics/listeners/users, publish, login. See `server/coremq-server/src/api/router.rs` for the full route table. |
| 77 | +- **MQTT WebSocket** (`ws://localhost:8083`) — the dashboard speaks MQTT directly to subscribe to live topic updates. See `client/src/sections/websocket/`. |
| 78 | + |
| 79 | +## Gotchas |
| 80 | + |
| 81 | +- `Cargo.lock` IS committed (binary crate — needs reproducible builds). |
| 82 | +- Frontend uses **`yarn`**, not `npm install` (Makefile uses yarn, lockfile is `yarn.lock`). |
| 83 | +- `target/` and `client/node_modules/` are gitignored — don't commit either. |
| 84 | +- See `.claude/skills/debug-coremq/skill.md` for runtime issue diagnosis. |
0 commit comments