Skip to content

Patryk404/sim_francisco

Repository files navigation

sim_francisco

FastAPI + TypeScript application with bundled frontend.

Project Structure

sim_francisco/
├── backend/              # Python FastAPI backend
│   ├── main.py          # FastAPI application
│   ├── requirements.txt # Python dependencies
│   └── public/          # Static HTML files
│       └── index.html   # Root page
├── frontend/            # TypeScript frontend
│   ├── src/
│   │   └── index.ts    # TypeScript entry point
│   ├── dist/           # Build output (bundled JS)
│   ├── package.json    # Node dependencies & scripts
│   └── tsconfig.json   # TypeScript configuration
└── .gitignore

Quick Start

1. Install Dependencies

Backend:

cd backend
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
cd ..

Frontend:

cd frontend
npm install
cd ..

2. Run the Application

Terminal 1 - Frontend watch mode:

cd frontend && npm run watch

Terminal 2 - Backend server:

cd backend && uvicorn main:app --reload

3. Open Your Browser

Visit http://localhost:8000 and open the browser console to see "hey" logged!

Running the Application

Development Mode (Recommended)

Run both the backend server and frontend build watcher simultaneously:

Terminal 1 - Frontend (auto-rebuild on changes):

cd frontend
npm run watch

Terminal 2 - Backend (auto-reload on changes):

cd backend
uvicorn main:app --reload

Then open your browser to: http://localhost:8000

Production Mode

  1. Build the frontend once:

    cd frontend
    npm run build
  2. Run the backend:

    cd backend
    uvicorn main:app

Available Endpoints

  • GET / - Main application page (serves index.html)
  • GET /health - Health check endpoint
  • /dist/* - Static files (bundled JavaScript)
  • GET /api/scenario - Get the current scenario
  • POST /api/scenario - Create a new scenario (grid, buildings, shelters, agents)
  • GET /api/riskmap - Risk grid for visualization
  • POST /api/step - Compute safest paths for agents

Development

  • Frontend TypeScript source: frontend/src/index.ts
  • Backend API routes: backend/main.py
  • HTML template: backend/public/index.html

The TypeScript code is bundled using esbuild and served by FastAPI as a static file.

Integration Notes

  • Leaflet: map grid cells to lat/lon and replace the canvas renderer with Leaflet layers.
  • Real SF data: ingest building footprints and seismic risk zones, then swap the random scenario generator in backend/sim/state.py.
  • Nemotron + Prime Intelligence: replace SimulationState.step() with policy calls and verifier hooks.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5