Last Updated: 4/7/2026
Installation & Setup
This guide walks you through setting up a local development environment for Agricultural Microworlds using GitHub Codespaces. You’ll go from zero to a running application in about 10 minutes.
Prerequisites
- A GitHub account with access to the
ksu-cs/development-project-agopsimulationrepository - A web browser
No local installation of Node.js, .NET, or PostgreSQL is required—the devcontainer handles all dependencies.
Step 1: Create a GitHub Codespace
- Navigate to the Agricultural Microworlds repository on GitHub
- Click the bright green Code button above the repository file list
- Switch to the Codespaces tab
- Click the + button to create a new codespace on
main
The initial build will take 5-10 minutes as GitHub downloads a Linux universal image, installs the .NET SDK, Node.js, and PostgreSQL 17, and runs npm install in the agricultural-microworlds.client/ directory.
Step 2: Fix Recovery Mode (Expected Issue)
The codespace will most likely open in recovery mode. This happens because GitHub’s free tier storage quota fills up with temporary files. You’ll see a banner at the top of the terminal saying “Running in Recovery Mode.”
To fix this:
- Open the terminal (if not already open) with
Ctrl + Shift + J(Windows/Linux) orCmd + Shift + J(Mac) - Run the following command to clear the temporary cache:
sudo rm -rf /tmp/* - Press
Ctrl + Shift + P(Windows/Linux) orCmd + Shift + P(Mac) to open the command palette - Type
rebuildand select “Codespaces: Rebuild Container” - When prompted, choose Rebuild (not Full Rebuild—Full Rebuild takes much longer)
After the rebuild completes (1-2 minutes), verify the terminal header no longer says “Running in Recovery Mode.”
Step 3: Navigate to the Client Directory
All npm commands must be run from the agricultural-microworlds.client/ directory:
cd agricultural-microworlds.clientStep 4: Install Dependencies
If the postCreateCommand in the devcontainer didn’t complete successfully, manually install npm dependencies:
npm installThis installs React 19, Blockly 12.3.1, Vite 7, and all dev dependencies (ESLint, Prettier, Jest, Babel).
Step 5: Build the Application
Build the Vite frontend bundle:
npm run buildThis compiles the React application and outputs static assets to dist/. The build process:
- Bundles all JavaScript modules
- Processes CSS
- Optimizes assets for production
- Generates source maps
You should see output like:
vite v7.1.7 building for production...
✓ built in 3.45sStep 6: Start the Development Server
Run the application:
npm run devWhat this does: The dev script changes directory to ../Agricultural-Microworlds.Server and runs dotnet run, which starts the ASP.NET Core backend. The backend serves the Vite-built frontend and proxies API requests.
The terminal will display:
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:5000
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000A browser tab should automatically open. If not, click the link in the terminal or navigate to the forwarded port in the Ports panel (usually https://<codespace-name>-5000.app.github.dev).
Alternative: Static Vite Server
To run only the Vite dev server (without the ASP.NET backend):
npm run "dev --static"This is useful for frontend-only development when you don’t need backend API routes. The Vite server runs on port 5000 (configured via DEV_SERVER_PORT environment variable, defaulting to 5000) with hot module replacement (HMR) enabled.
Step 7: Verify the Application
You should see the Agricultural Microworlds interface:
- Left panel: Blockly workspace with a toolbox of programming blocks (Movement, Farm Operations, Time & Flow, Sensors/Logic)
- Right panel: Simulation canvas showing a top-down view of a tractor on a field
- Controls: Run, Stop, and Reset buttons
Test the simulation:
- Drag a
move_forwardblock from the toolbox into the workspace - Click the Run button
- Watch the tractor move forward one tile in the simulation canvas
If you see the tractor move, congratulations—your development environment is working!
Available npm Scripts
The package.json defines these scripts:
| Script | Command | Purpose |
|---|---|---|
dev | cd ../Agricultural-Microworlds.Server && dotnet run | Start ASP.NET backend (serves frontend) |
dev --static | vite | Start Vite dev server only (frontend HMR) |
dev:svg | OPEN_SVG=true vite | Start Vite with SVG debugging enabled |
build | vite build | Build production bundle to dist/ |
test | jest | Run Jest unit tests |
lint | eslint . | Lint JavaScript files with ESLint |
preview | vite preview | Preview production build locally |
format | prettier --write . | Format code with Prettier |
Devcontainer Services
The docker-compose.yml provisions two services:
- app: Linux universal image with .NET SDK, Node.js, and development tools
- db: PostgreSQL 17 Alpine (accessible on port 5432)
The database is currently unused—authentication and data persistence are not yet implemented.
Troubleshooting
”Cannot find module” errors
Run npm install again. The postCreateCommand may have failed during initial setup.
Port forwarding issues
Check the Ports panel in VS Code. Ensure ports 5000, 5001, and 5432 are forwarded and set to HTTPS protocol.
Codespace keeps entering recovery mode
This is a known issue with GitHub’s storage limits. Run sudo rm -rf /tmp/* and rebuild the container each time you open the codespace.
Vite build fails
Ensure you’re in the agricultural-microworlds.client/ directory. The build command must run from the client folder, not the repository root.
ASP.NET backend won’t start
Check that the .NET SDK is installed: dotnet --version. The devcontainer should provision .NET 9.0 or later.
What’s Next
Now that you have a running development environment:
- Simulation Engine Architecture: Understand how the game loop works and why student code runs in a Web Worker
- State Management System: See how SimManagers coordinate without stepping on each other’s state
- Blockly Blocks Reference: Learn what programming blocks are available to students