Ship the Next.js cycle editor with CAD chrome, technical HX symbols, Fixed/Free boundary guidance, and secondary water/air pressure drop support in the solver stack. Co-authored-by: Cursor <cursoragent@cursor.com>
76 lines
1.9 KiB
Markdown
76 lines
1.9 KiB
Markdown
# Entropyk Web UI
|
|
|
|
Visual canvas builder for Entropyk thermodynamic cycles.
|
|
|
|
The UI emits the same `ScenarioConfig` JSON as the CLI
|
|
(`crates/cli/src/config.rs`). Physics always runs through
|
|
`entropyk_cli::run::simulate_from_json` via the Axum `ui-server`.
|
|
|
|
## Prerequisites
|
|
|
|
- Node.js 18+ and npm
|
|
- The Rust API server running (see below)
|
|
|
|
## Setup
|
|
|
|
### 1. Start the Rust API server
|
|
|
|
From the project root:
|
|
|
|
```bash
|
|
cargo run -p entropyk-demo --bin ui-server
|
|
# → http://localhost:3030
|
|
```
|
|
|
|
Endpoints:
|
|
- `GET /api/health`
|
|
- `GET /api/components`
|
|
- `POST /api/simulate`
|
|
- `GET /api/mollier?fluid=R134a`
|
|
|
|
### 2. Start the Next.js dev server
|
|
|
|
```bash
|
|
cd apps/web
|
|
npm install
|
|
npm run dev
|
|
# → http://localhost:3000
|
|
```
|
|
|
|
By default the frontend proxies `/api/entropyk/*` to `http://localhost:3030/api/*`
|
|
(see `next.config.mjs`). To point at a different API, set:
|
|
|
|
```bash
|
|
ENTROPYK_API_URL=http://my-host:3030 npm run dev
|
|
```
|
|
|
|
## Usage
|
|
|
|
1. Drag components from the left palette onto the canvas.
|
|
2. Connect ports by dragging from one handle to another.
|
|
3. Select a node to edit its parameters in the right panel.
|
|
4. Pick the fluid and backend in the top bar.
|
|
5. Click **Solve cycle** — the result panel shows COP, edge states and a P-h diagram.
|
|
6. **Load** drops in a CLI example from the picker; **Import JSON** loads any CLI config.
|
|
7. **Multi-run** sweeps parameters (fluid, UA, …) and solves cases in parallel.
|
|
|
|
## Architecture
|
|
|
|
```
|
|
Browser (Next.js) Rust API (Axum ui-server :3030)
|
|
React Flow canvas → POST /api/simulate
|
|
Zustand store → simulate_from_json() (CLI engine)
|
|
Recharts P-h diagram ← SimulationResult JSON
|
|
```
|
|
|
|
Anything buildable in the UI can also be run with:
|
|
|
|
```bash
|
|
cargo run -p entropyk-cli -- run path/to/config.json
|
|
```
|
|
|
|
## Deprecated surfaces
|
|
|
|
- `ui/` at the repo root — legacy static HTML; calls removed `/api/calculate`. Do not use.
|
|
- `tools/circuit-builder-ui` — alternate HTML builder; prefer `apps/web`.
|