FastAPI for processing IFC (Industry Foundation Classes) using IfcOpenShell.
📚 Read the full documentation at louistrue.github.io/openBIM-service
- 🔍 IFC file processing with IfcOpenShell
- 📊 Extract building element properties and quantities
- 🏢 Split IFC files by storey
- 📏 Automatic unit conversion
- 🏗️ Building element information including:
- Geometry (volume, area, dimensions)
- Materials and their volumes
- Properties (loadBearing, isExternal)
- Building storey assignment
- Process geometry
- Async processing with callback support
We take data privacy seriously:
- 🗑️ All uploaded files are automatically deleted after processing is complete
- 🧹 Temporary files are completely wiped from container storage every hour
- 🔒 Files are processed with minimal disk persistence
- 📝 Processing logs are kept only for debugging and are regularly purged
- 🔐 All API requests require authentication via API key
- Python 3.10+
- pip
- Clone the repository:
git clone <repository-url>
cd <repository-name>
- Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
.\venv\Scripts\activate # Windows
- Install dependencies:
pip install -r requirements.txt
pip install -r requirements-dev.txt # For development
- Set up your API key:
Create a .env
file in the project root:
API_KEY=your-api-key-here
This API key is required for all API requests and tests.
Start the development server:
python run.py
The API will be available at http://localhost:8000
Run tests using pytest:
# Run all tests
pytest
# Run with coverage report
pytest --cov=app tests/
# Run specific test file
pytest tests/test_endpoints.py
Test outputs are saved in tests/output/
directory, including:
- Process results in JSONL format
- Error responses in JSON format
app/
├── main.py # FastAPI application entry point
├── api/
│ ├── routes/
│ │ └── ifc_routes.py # API endpoints
├─ core/
│ ├── config.py # Application settings
│ ├── security.py # API key authentication & rate limiting
│ └── models/ # Pydantic data models
│ └── ifc.py # IFC-related data models
└── services/
├── ifc/ # IFC processing services
│ ├── properties.py # Element property extraction
│ ├── quantities.py # Geometric quantities
│ ├── splitter.py # IFC model splitting
│ └── units.py # Unit conversion utilities
└─ lca/ # Life Cycle Assessment
└── materials.py # Material processing
tests/
├── conftest.py # Pytest configuration
├── test_endpoints.py # API tests
└── output/ # Test results and logs
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details.
We welcome contributions! Please see CONTRIBUTING.md for details on how to:
- Set up your development environment
- Follow our code style guidelines
- Submit pull requests
- Report issues
By contributing, you agree that your contributions will be licensed under the AGPL-3.0 License.
This project is built on top of several excellent open-source projects:
- IfcOpenShell - The core IFC processing library (LGPL-3.0)
- FastAPI - Modern web framework for building APIs (MIT)
- Pydantic - Data validation using Python type annotations (MIT)
- pytest - Testing framework (MIT)
- uvicorn - Lightning-fast ASGI server (BSD-3-Clause)
Special thanks to:
- The IfcOpenShell community for their excellent IFC processing tools and documentation
- All contributors to the dependencies that make this project possible
The /api/ifc/extract-building-elements
endpoint supports asynchronous processing with callbacks. When using callbacks:
- The endpoint returns immediately with a task ID
- Progress updates (10%) are sent to the callback URL
- Final results are sent to the callback URL
- All callback requests include the provided token in Authorization header
Progress updates:
{
"status": "processing",
"progress": 10,
"total_elements": 100,
"processed_elements": 10
}
Final result:
{
"status": "completed",
"progress": 100,
"result": {
"metadata": { ... },
"elements": [ ... ]
}
}
Error case:
{
"status": "error",
"error": "Error message"
}
- Start the callback test server:
python tests/callback_server.py
- In another terminal, run the test script:
python tests/test_callback.py
The callback server will log all received callbacks, including progress updates and the final result.