Share
## https://sploitus.com/exploit?id=6D927478-5B13-5FE4-8D31-F64B35F79928
# ๐Ÿง  OntologyLab

[![Python 3.11+](https://img.shields.io/badge/Python-3.11+-3776ab?style=flat-square&logo=python&logoColor=white)](https://www.python.org/)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.109-009688?style=flat-square&logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com/)
[![React 19](https://img.shields.io/badge/React-19-61dafb?style=flat-square&logo=react&logoColor=white)](https://react.dev/)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.9-3178c6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)](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