Chapter 2: Run the demo app
Your agent clones mock-lab, starts the app and its database, and checks that the app answers all of the tutorial traffic.
Time: about 1 to 2 minutes.
Prompt
Pick your language. The prompt is the same except for the directory.
- Go
- Java
- Python
- Node.js
Clone https://github.com/speedscale/mock-lab and open tutorial/go. Start its database with tutorial-db as the README describes, run the app, and send it the tutorial traffic once to check it works. Then stop the app and leave the database running.
Clone https://github.com/speedscale/mock-lab and open tutorial/java. Start its database with tutorial-db as the README describes, run the app, and send it the tutorial traffic once to check it works. Then stop the app and leave the database running.
Clone https://github.com/speedscale/mock-lab and open tutorial/python. Start its database with tutorial-db as the README describes, run the app, and send it the tutorial traffic once to check it works. Then stop the app and leave the database running.
Clone https://github.com/speedscale/mock-lab and open tutorial/node. Start its database with tutorial-db as the README describes, run the app, and send it the tutorial traffic once to check it works. Then stop the app and leave the database running.
What the agent does
This chapter uses no skill. The agent reads the app's README and follows it:
- Clones mock-lab and reads
tutorial/README.mdandtutorial/<language>/README.md. - Starts
tutorial-dbin the background fromtutorial/:go -C db run .when Go is installed, otherwise the prebuilt binary for your OS, downloaded once from the mock-lab release. It runs a real Postgres 16 as an ordinary process, with no Docker, on port 54329 with the schema fromcontract/schema.sql. The first start downloads about 30 MB of Postgres intotutorial/.tutorial-db/. - Builds and starts the app on port 8080, then runs the language's traffic driver, which sends 135 requests: health checks, catalog lookups, 40 orders with their reads, order lists, and a few bad requests that expect 400, 404 and 422.
- Stops the app and leaves the database running for the next chapters.
What you should see
The agent's summary. Trimmed:
The Go tutorial app works: the traffic script sent 135 requests with 0 unexpected responses. The app is stopped and the database is still running.
- Database: I started it from `tutorial/` with `go -C db run .`, as the README says, but in the background instead of its own terminal. It's Postgres 16 listening on `localhost:54329`, with user, password and database all `tutorial`. Its data and the downloaded Postgres are in `mock-lab/tutorial/.tutorial-db/` ...
- App: `go run .` in `tutorial/go` started on `:8080` using the default `DATABASE_URL`. ...
- Traffic: `go run ./cmd/traffic` ran once.
- Stopped: I ended both the `go run` process and the app binary it started, and port 8080 is free again.
To stop the database later, run `go -C db run . -stop` from `mock-lab/tutorial/`.
The line that matters is sent 135 requests, 0 unexpected. The traffic driver prints one line for each response with an unexpected status. Afterwards the orders table holds 40 rows.
If it goes wrong
port 54329 is in use ... already running. Atutorial-dbfrom an earlier attempt is still running. Use it, or stop it withtutorial-db -stop.port 54329 is in usefor another reason. Starttutorial-db -port <free port>and pointDATABASE_URLat that port. In later chapters, use the same port wherever a command maps tolocalhost:54329.- The first start is slow or fails to download. It fetches about 30 MB of Postgres binaries from Maven Central once. Check your network or proxy, then start it again.
Manual equivalent
git clone https://github.com/speedscale/mock-lab
cd mock-lab/tutorial
go -C db run . # terminal 1: runs until ctrl-c
Without Go, download tutorial-db once instead, as tutorial/README.md shows for each OS, and run ./tutorial-db (or .\tutorial-db.exe on Windows).
Then run the app and, in a second terminal, the traffic driver:
- Go
- Java
- Python
- Node.js
cd go
go run . # terminal 1
go run ./cmd/traffic # terminal 2
cd java
./mvnw -q package
java -jar target/tutorial-orders.jar # terminal 1
./mvnw -q compile exec:java -Dexec.args="http://localhost:8080" # terminal 2
cd python
python3 -m venv .venv
.venv/bin/pip install -r requirements-dev.txt
source .venv/bin/activate
python app.py # terminal 1
python traffic.py # terminal 2
cd node
npm ci
node server.js # terminal 1
node traffic.mjs # terminal 2
Stop the app with ctrl-c and leave the database running.