# ontology-sim **Repository Path**: kazzz/ontology-sim ## Basic Information - **Project Name**: ontology-sim - **Description**: 本体驱动的仿真系统 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2026-03-18 - **Last Updated**: 2026-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Ontology-Driven Simulation Graph A Memgraph + FastAPI + Vue 3 demo for ontology-driven simulation. The UI presents entities, actions, functions, events, and rules of engagement in a graph workspace with real-time updates. ## What It Shows - Graph entities for units and zones, plus command, tracking, and location relationships. - Entity properties, derived properties, action commands, event subscriptions, and event logs in one workspace. - Function-driven derived properties such as ETA, threat level, and tracking target. - Configurable rules of engagement and a start/stop simulation control. - Realtime synchronization through WebSocket snapshots and incremental updates. - Built-in Chinese and English UI switching. ## Stack - Backend: FastAPI - Graph database: Memgraph - Frontend: Vue 3 + Vite - Graph rendering: Cytoscape + cytoscape-cola - Realtime transport: WebSocket - Local orchestration: Docker Compose ## Project Layout ```text ontology-sim/ |- backend/ | |- app/ | | |- db/ | | |- ontology/ | | |- realtime/ | | |- services/ | | |- config.py | | |- main.py | | |- seed.py | |- requirements.txt | |- Dockerfile |- frontend/ | |- public/ | |- src/ | |- package.json | |- Dockerfile |- docker-compose.yml |- README.md ``` ## Quick Start With Docker ```bash docker compose build docker compose up -d ``` Useful endpoints after startup: - Frontend: `http://localhost:8080` - Backend docs: `http://localhost:8000/docs` - Health check: `http://localhost:8000/health` - WebSocket: `ws://localhost:8000/ws` Stop services: ```bash docker compose down ``` Remove the Memgraph volume as well: ```bash docker compose down -v ``` ## Local Development Start Memgraph first: ```bash docker compose up -d memgraph ``` Run the backend: ```bash cd backend pip install -r requirements.txt uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload ``` Run the frontend: ```bash cd frontend npm install npm run dev ``` ## Key API Endpoints - `GET /health` - `GET /api/ontology` - `GET /api/graph` - `GET /api/events` - `GET /api/simulation/status` - `POST /api/simulation/start` - `POST /api/simulation/stop` - `POST /api/reset` - `POST /api/actions/move-to-point` - `POST /api/actions/move-to-zone` - `POST /api/actions/attack` - `POST /api/actions/assign-tracking` - `GET /api/functions/eta` - `GET /api/functions/threat` - `GET /api/functions/tracked` - `GET /api/functions/derived-properties` - `GET /api/functions/rules-of-engagement` - `POST /api/functions/rules-of-engagement` - `GET /ws` ## Encoding And i18n Notes - Frontend UI copy is centralized in `frontend/src/i18n/messages.js`. - That file intentionally stores Chinese text with Unicode escapes to reduce mojibake risk on Windows shells. - If you add new translatable UI copy, prefer adding it through the i18n layer instead of hardcoding text in Vue components. ## Verification Build the frontend bundle: ```bash cd frontend npm run build ``` Optional backend syntax check: ```bash python -m compileall backend/app ```