Setup on a new machine
- Install: Go 1.25+ (
server/go.moddeclaresgo 1.25.0), Node 20+ (aws-cdk-librequires it), Docker (running), AWS CLI v2, git. For the SSM-based helpers (npm run db:tunnel,npm run logs:nats) also install the Session Manager plugin:brew install --cask session-manager-plugin. - Clone & build (
cse_tcp_beand this docs repo are expected to sit side by side as sibling checkouts):git clone <this-repo-url> && cd cse_tcp_benpm install # root: only `concurrently`, for `npm run dev`cd server && go build ./... && go vet ./... && cd ..cd cdk && npm install && cd .. - Local config:
npm run devcopies.env.exampleto.envon first run and sources it for you. Anything run outsidenpm run dev(a singlego run, CDK) does not load.env— neither the Go binaries nor CDK use a dotenv library — soset -a; source .env; set +afirst when you need it. Never put AWS credentials in.env, even though it's gitignored. - Run locally (no AWS needed), from the repo root:
npm run dev # NATS + TimescaleDB in Docker, then tcpserver, ws-gateway, persistence-workernpm run dev:stop # stop the Go services, leave the containers runningnpm run dev:down # stop the nats/timescaledb containers too
scripts/dev.shreuses existingnats/timescaledbcontainers (starting them if stopped) and only creates them when none exist, waits for Postgres, prints the LAN addresses to point devices and browsers at, and runs the three services withgo runin one terminal. The services compile once at start and never reload — after changingserver/, runnpm run dev:stop && npm run dev. Ports: devices onDEVICE_PORT(8443unless.envsets it — the shipped.env.examplesets9000), WebSocket onws://<lan-ip>:8090/ws, health check on/healthz. See Server behavior for details. - Docs-sync commit hook (optional, once per clone): warns — never
blocks — when a commit touches
server/cmd/,cdk/lib/or the messaging code while this docs repo has no pending or recent change:cp scripts/git-hooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit - AWS credentials (only needed to deploy):
aws configure # region: us-east-1 — or `aws configure sso`aws sts get-caller-identity # verify
- CDK bootstrap (once per AWS account/region):
cd cdk && npx cdk bootstrap aws://$(aws sts get-caller-identity --query Account --output text)/us-east-1
- Verify the CDK app type-checks and synthesizes:
cd cdk && npx tsc --noEmit && npx cdk synth --strict
- Deploy the dev-tier pipeline with
cd cdk && npm run deploy— never a barecdk deployfor these stacks; see Infrastructure for why, and for every othernpm runcommand.
Protocol files → JSON
Parsed from the vendor docs in protocols/source/ into
server/internal/modbus/specs/, one JSON per model, common schema (model,
protocol, connection, registers[], fault_codes[]).
server/internal/modbus/specs/ is the only copy, and it is the one
embedded into the Go binary (//go:embed specs/*.json in
server/internal/modbus/registry.go). Edit these files directly. After
changing them, regenerate this site's protocol reference pages and sandbox
register data from the cse-solar-docs checkout with
python3 scripts/gen_protocol_docs.py (it reads the specs from a sibling
../cse_tcp_be, or from CSE_TCP_BE_DIR).
| File | Model | Protocol |
|---|---|---|
aotai-hybrid.json | Nexus | Modbus RTU |
ip20-2kw-12kw.json | Yorker | Modbus RTU |
ip20-3k6-5k.json | IP20 3K6/5K | Not Modbus: a proprietary ASCII command protocol over the DTU ("transport": "ascii"). Generated by scripts/gen-ip20-3k6-5k-spec.py; do not hand-edit. See IP20 3K6/5K. |
None of the source docs state baud/parity/slave address except the ASCII
one — see each file's connection.notes, or the
protocol reference pages.