Energy grid simulation with a Next.js frontend and a FastAPI backend.
- Python 3.10+ (with
pip) - Node.js 18+ (with
npm)
Run these from the repository root (GridLock/).
-
Create and activate a virtual environment (recommended):
python -m venv .venv .\.venv\Scripts\Activate.ps1On macOS/Linux:
python -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Start the API server (defaults to
http://127.0.0.1:8000):python -m uvicorn backend.api.server:app --reload --host 127.0.0.1 --port 8000
If
pythonis not available as a command on Windows, use:py -m uvicorn backend.api.server:app --reload --host 127.0.0.1 --port 8000
Check it is up: open or request
http://127.0.0.1:8000/health.
Run these from the frontend/ directory.
-
Install dependencies:
cd frontend npm install -
Start the dev server:
npm run dev
The app is usually at http://localhost:3000.
The UI expects the API at http://127.0.0.1:8000. To use a different URL, set:
set NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8000
npm run dev(PowerShell: $env:NEXT_PUBLIC_API_BASE_URL="http://127.0.0.1:8000". On Unix, use export.)
- Frontend:
npm run buildthennpm start(fromfrontend/). - Backend: same
python -m uvicorncommand without--reloadfor a stable process.
- Terminal 1: start the backend with
python -m uvicornfrom the repo root. - Terminal 2:
cd frontend,npm run dev. - Use the browser on the Next.js URL; it will call the local API.