Share
## https://sploitus.com/exploit?id=6D927478-5B13-5FE4-8D31-F64B35F79928
# ๐ง OntologyLab
[](https://www.python.org/)
[](https://fastapi.tiangolo.com/)
[](https://react.dev/)
[](https://www.typescriptlang.org/)
[](https://opensource.org/licenses/MIT)
A modern, web-based ontology editor with visual graph editing and semantic reasoning capabilities. Built as a modern alternative to [Protรฉgรฉ](https://protege.stanford.edu/).
## โจ Features
| Feature | Description |
|---------|-------------|
| ๐จ **Visual Graph Editor** | Interactive visualization using Cytoscape.js with hierarchical, force-directed, and radial layouts |
| ๐ฆ **Full OWL 2 Support** | Create and edit classes, object/data properties, individuals, and complex axioms |
| ๐งฎ **Semantic Reasoning** | Integrated HermiT reasoner for consistency checking and inference |
| ๐ **SPARQL Queries** | Execute SPARQL queries with Monaco-based syntax highlighting and result tables |
| ๐พ **JSON Persistence** | Fast, version-control friendly file format |
| ๐ค **Import/Export** | Support for OWL/XML, RDF/XML, Turtle, and JSON-LD formats |
| ๐ **Dark Theme** | Beautiful dark UI designed for extended use |
## ๐๏ธ Architecture
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ React Frontend โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Graph View โ โ Class Tree โ โ Property Editor โ โ
โ โ (Cytoscape) โ โ (Sidebar) โ โ (Detail Panel) โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ SPARQL Editor (Monaco) โโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ REST API
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FastAPI Backend โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ OWLReady2 โ โ RDFLib โ โ HermiT Reasoner โ โ
โ โ (Ontology) โ โ (SPARQL) โ โ (Inference) โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโดโโโโโโโโโ
โ JSON/OWL Files โ
โโโโโโโโโโโโโโโโโโโ
```
## ๐ Quick Start
### Prerequisites
| Requirement | Version | Notes |
|-------------|---------|-------|
| Python | 3.11+ | Required |
| Node.js | 18+ | Required |
| Java | 11+ | Required for reasoning/consistency checks |
| npm | 9+ | Or yarn |
### 1. Clone the Repository
```bash
git clone https://github.com/yourusername/BDO-Ontology.git
cd BDO-Ontology
```
### 2. Backend Setup
```bash
cd backend
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Start the server
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
```
The API will be available at **http://localhost:8000**
### 3. Frontend Setup
```bash
cd frontend
# Install dependencies
npm install
# Start the development server
npm run dev
```
The application will be available at **http://localhost:5173**
### 4. Java Setup (Required for Reasoning)
The HermiT reasoner requires Java. Install it based on your OS:
**macOS (Homebrew):**
```bash
brew install openjdk
# Make it available system-wide
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
# Or add to ~/.zshrc
export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
export JAVA_HOME="/opt/homebrew/opt/openjdk"
```
**Ubuntu/Debian:**
```bash
sudo apt update && sudo apt install openjdk-17-jre
```
**Windows:**
Download from [Adoptium](https://adoptium.net/) or use `winget install Microsoft.OpenJDK.17`
## ๐ API Documentation
Once the backend is running, interactive API docs are available at:
| Documentation | URL |
|---------------|-----|
| Swagger UI | http://localhost:8000/api/docs |
| ReDoc | http://localhost:8000/api/redoc |
### Key Endpoints
| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/ontologies` | List all ontologies |
| `POST` | `/api/ontologies` | Create new ontology |
| `POST` | `/api/ontologies/import` | Import OWL/RDF file |
| `GET` | `/api/ontologies/{id}` | Get ontology details |
| `GET` | `/api/ontologies/{id}/export/{format}` | Export ontology |
| `POST` | `/api/ontologies/{id}/classes` | Create a class |
| `POST` | `/api/ontologies/{id}/properties` | Create a property |
| `POST` | `/api/ontologies/{id}/sparql` | Execute SPARQL query |
| `GET` | `/api/ontologies/{id}/consistency` | Check consistency |
| `POST` | `/api/ontologies/{id}/reason` | Run reasoner |
## ๐ ๏ธ Technology Stack
### Frontend
| Technology | Purpose |
|------------|---------|
| React 19 | UI Framework |
| TypeScript 5.9 | Type Safety |
| Vite 7 | Build Tool |
| TailwindCSS 4 | Styling |
| Cytoscape.js | Graph Visualization |
| Monaco Editor | SPARQL Editor |
| Zustand | State Management |
| Lucide React | Icons |
### Backend
| Technology | Purpose |
|------------|---------|
| FastAPI | REST API Framework |
| OWLReady2 | Ontology Manipulation |
| RDFLib | RDF/SPARQL Processing |
| HermiT | OWL Reasoning (via Java) |
| Pydantic | Data Validation |
| Uvicorn | ASGI Server |
## ๐ Project Structure
```
BDO-Ontology/
โโโ frontend/ # React application
โ โโโ src/
โ โ โโโ components/ # UI components
โ โ โ โโโ GraphView/ # Cytoscape graph visualization
โ โ โ โโโ Layout/ # App layout components
โ โ โ โโโ PropertyEditor/
โ โ โ โโโ SPARQLEditor/
โ โ โโโ services/ # API client
โ โ โโโ store/ # Zustand state management
โ โ โโโ types/ # TypeScript types
โ โโโ package.json
โโโ backend/ # FastAPI application
โ โโโ app/
โ โ โโโ api/ # Route handlers
โ โ โ โโโ routes/ # Individual route modules
โ โ โโโ core/ # Business logic
โ โ โ โโโ ontology_manager.py
โ โ โ โโโ reasoner.py
โ โ โ โโโ sparql_engine.py
โ โ โ โโโ serialization.py
โ โ โโโ models/ # Pydantic schemas
โ โโโ data/
โ โ โโโ ontologies/ # Stored ontology files
โ โโโ requirements.txt
โโโ Testing/ # Test ontologies and IRS schemas
โ โโโ 2024/ # IRS Tax Form XSD schemas
โ โโโ irs-tax-forms-2024.owl
โโโ README.md
```
## ๐ JSON Ontology Format
OntologyLab uses a JSON format optimized for version control:
```json
{
"id": "example-ontology",
"iri": "http://example.org/ontology#",
"metadata": {
"title": "Example Ontology",
"version": "1.0.0",
"description": "An example ontology"
},
"classes": [
{
"iri": "http://example.org/ontology#Person",
"label": "Person",
"subClassOf": ["owl:Thing"],
"comment": "Represents a person"
}
],
"objectProperties": [
{
"iri": "http://example.org/ontology#knows",
"label": "knows",
"domain": ["Person"],
"range": ["Person"]
}
],
"dataProperties": [],
"individuals": []
}
```
## โจ๏ธ Keyboard Shortcuts
| Shortcut | Action |
|----------|--------|
| `Ctrl/Cmd + S` | Save ontology |
| `Delete` | Delete selected entity |
| `Ctrl/Cmd + Z` | Undo |
| `Ctrl/Cmd + Y` | Redo |
| `Ctrl/Cmd + F` | Focus search |
| `Escape` | Close dialogs/panels |
## ๐ฏ Sample Ontologies
### IRS Tax Forms 2024
The repository includes an OWL ontology generated from IRS e-file schemas:
- **156 classes** covering tax forms (1041, 1065, 1120, 990, etc.)
- **19 properties** for relationships and data
- **Full class hierarchy** from Income Tax Categories to specific schedules
Located at: `Testing/irs-tax-forms-2024.owl`
## ๐ง Troubleshooting
### "Unable to locate a Java Runtime" when checking consistency
Install Java (see [Java Setup](#4-java-setup-required-for-reasoning) above) and restart the backend server.
### Backend can't find Java even after installation
Make sure Java is in the PATH when starting the backend:
```bash
export PATH="/opt/homebrew/opt/openjdk/bin:$PATH" # macOS with Homebrew
uvicorn app.main:app --host 0.0.0.0 --port 8000
```
### CORS errors in browser console
The backend includes CORS middleware. Ensure you're accessing the frontend at `http://localhost:5173` (not 127.0.0.1).
### Import fails silently
Check the browser console for errors. The backend logs detailed error messages.
## ๐ค Contributing
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
- [Protรฉgรฉ](https://protege.stanford.edu/) - Inspiration for ontology editing features
- [OWLReady2](https://owlready2.readthedocs.io/) - Python ontology library
- [Cytoscape.js](https://js.cytoscape.org/) - Graph visualization library
- [FastAPI](https://fastapi.tiangolo.com/) - Modern Python web framework
- [HermiT](http://www.hermit-reasoner.com/) - OWL 2 reasoner
---
Made with โค๏ธ for the semantic web community