Skip to main content

Setup on a new machine

  1. Install: Go 1.25+ (server/go.mod declares go 1.25.0), Node 20+ (aws-cdk-lib requires 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.
  2. Clone & build (cse_tcp_be and this docs repo are expected to sit side by side as sibling checkouts):
    git clone <this-repo-url> && cd cse_tcp_be
    npm install # root: only `concurrently`, for `npm run dev`
    cd server && go build ./... && go vet ./... && cd ..
    cd cdk && npm install && cd ..
  3. Local config: npm run dev copies .env.example to .env on first run and sources it for you. Anything run outside npm run dev (a single go run, CDK) does not load .env — neither the Go binaries nor CDK use a dotenv library — so set -a; source .env; set +a first when you need it. Never put AWS credentials in .env, even though it's gitignored.
  4. Run locally (no AWS needed), from the repo root:
    npm run dev # NATS + TimescaleDB in Docker, then tcpserver, ws-gateway, persistence-worker
    npm run dev:stop # stop the Go services, leave the containers running
    npm run dev:down # stop the nats/timescaledb containers too
    scripts/dev.sh reuses existing nats/timescaledb containers (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 with go run in one terminal. The services compile once at start and never reload — after changing server/, run npm run dev:stop && npm run dev. Ports: devices on DEVICE_PORT (8443 unless .env sets it — the shipped .env.example sets 9000), WebSocket on ws://<lan-ip>:8090/ws, health check on /healthz. See Server behavior for details.
  5. 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
  6. AWS credentials (only needed to deploy):
    aws configure # region: us-east-1 — or `aws configure sso`
    aws sts get-caller-identity # verify
  7. 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
  8. Verify the CDK app type-checks and synthesizes:
    cd cdk && npx tsc --noEmit && npx cdk synth --strict
  9. Deploy the dev-tier pipeline with cd cdk && npm run deploy — never a bare cdk deploy for these stacks; see Infrastructure for why, and for every other npm run command.

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).

FileModelProtocol
aotai-hybrid.jsonNexusModbus RTU
ip20-2kw-12kw.jsonYorkerModbus RTU
ip20-3k6-5k.jsonIP20 3K6/5KNot 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.