This project is an interactive simulation and analytics dashboard that demonstrates how game theory can be applied to industrial safety scenarios, specifically in a shipyard environment. It uses MongoDB for flexible, real-time data storage, FastAPI for backend simulation logic, and a modern React (Next.js) frontend with LeafyGreen UI and Recharts for visualization.
Key Features:
- Simulate worker behavior under different supervisor policies and incentive levels.
- Generate synthetic worker profiles and environmental sensor data.
- Visualize worker decisions and risk profiles with interactive charts and tables.
- Inspect MongoDB data models directly from the UI.
- Reset and rerun simulations to explore different scenarios.
- Frontend: React (Next.js), LeafyGreen UI, Recharts
- Backend: FastAPI (Python)
- Database: MongoDB
- Node.js (v18+ recommended)
- Python 3.8+
- MongoDB (local or Atlas)
git clone <your-repo-url>
cd shipyard_simulation_demo
Create a .env
file in the backend/
directory and set your MongoDB connection string:
echo "MONGO_URI=mongodb://localhost:27017/shipyard_demo" > backend/.env
Note: Replace the connection string with your MongoDB Atlas URI if using a cloud database.
You can set up the project using either Docker Compose (quick setup) or manual installation.
This is the fastest way to get everything running:
docker-compose up --build -d
That's it! The application will be available at http://localhost:3008.
If you prefer to run components individually:
Set Up the Backend:
-
Navigate to the backend directory
-
Install dependencies:
pip install -r requirements.txt
-
Start the FastAPI server (default port:
8008
):uvicorn main:app --reload --port 8008
Set Up the Frontend:
-
Navigate to the frontend directory:
cd frontend
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open http://localhost:3008 in your browser.
-
Configure Simulation:
Select supervisor policy, incentive level, number of workers, and timesteps. -
Generate Workers:
Click "Generate Worker Profiles" to create synthetic workers. -
Run Simulation:
Click "Run Simulation" to simulate worker decisions and safety events. -
View Results:
- Worker behavior and sensor data are shown in tables.
- Charts visualize worker decisions and risk profiles.
- Click "Data Model" to inspect sample MongoDB documents.
-
Reset Database:
Click "Reset Database" to clear all data and start fresh.
- Flexible Data Model: Store varied data (workers, behaviors, sensors) using the flexible document model.
- Real-Time Analytics: Aggregation pipelines and change streams enable real time analytics and responsive dashboards.
- Scalability: Easily handles large volumes of simulation and sensor data.
Humza Akhtar, MongoDB humza.akhtar@mongodb.com