Welcome to the AI on Demand (AIoD) Metadata Catalogue! This repository hosts the REST API for the metadata catalogue, which serves as a central hub for indexing, managing, and searching metadata related to artificial intelligence resources (datasets, models, tools, and more).
This project acts as the backend layer that enables rich cataloging features, relying on MySQL for relational data persistence, Elasticsearch for high-performance full-text search and filtering, and Keycloak for robust authentication and authorization.
- Features
- Architecture Overview
- Prerequisites
- Installation & Setup
- Using the API
- Development and Testing
- Monitoring
- Contributing
- License
- FastAPI-powered REST API: High-performance asynchronous API for managing and querying metadata.
- Advanced Search Capabilities: Integrated with Elasticsearch for complex querying across vast metadata sets.
- Secure Authentication: Built-in Keycloak integration ensures role-based access control (RBAC).
- Data Connectors: Ships with profiles and connectors to external platforms like HuggingFace Datasets, OpenML, Zenodo, and AIBuilder.
- Containerized Ecosystem: fully automated deployment setup using Docker Compose, including a pre-configured ELK/Elasticsearch stack and MySQL database.
- Monitoring Ready: Includes Prometheus metrics and Grafana dashboards for health and performance monitoring.
The application is composed of several interdependent services orchestrated through Docker Compose:
- App (apiserver): The main FastAPI web service running the Python REST backend.
- Database (sqlserver): MySQL 8.3 container to persist transactional metadata.
- Search (elasticsearch): Elasticsearch 8.8 container used as the primary search engine for the catalog.
- Auth (keycloak): Keycloak 24.0.4 for OAuth2 / OpenID Connect user authentication.
- Connectors: Various worker containers (HuggingFace, OpenML, Zenodo) to ingest and sync external datasets into the catalogue.
- Monitoring (optional): Prometheus and Grafana for metrics visualization.
- Nginx (optional): Reverse proxy for managing external routing.
To run this application, ensure you have the following installed on your local machine:
- Docker: For running containerized services.
- Docker Compose (or Docker Desktop which includes Compose).
- Bash: To execute the setup scripts.
- (Optional) Python 3.11+: If you intend to run the FastAPI service locally without Docker.
We recommend running the catalogue using the provided Docker setup, as it abstracts away the complex multi-service dependencies (Database, Search, Auth).
git clone https://github.com/aiondemand/AIOD-rest-api.git
cd AIOD-rest-apiEnvironment variables configure ports, credentials, and settings.
- Review the
.envfile at the root of the project. - If you need to customize settings for your local development, create a file named
override.env. The launch scripts will automatically source it. - Optional: If you want your local code changes to be live-reloaded inside the container, set
USE_LOCAL_DEV=truein your.envoroverride.env. This will mount yoursrc/directory to the container automatically.
To build and start all core services, use the included Bash script:
./scripts/up.shWhat happens here?
The script will load your environment variables and launch the docker compose command in detached mode. It starts the backend API, MySQL, Elasticsearch, and Keycloak.
To stop the application, use:
./scripts/down.shAccessing the Application: Once the containers are up and healthy, you can access the API and its documentation:
- Swagger UI (Interactive API Docs): http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- Keycloak Console: http://localhost:8080 (Default credentials are in the
.envfile)
If you prefer to run the FastAPI server natively on your machine while keeping the dependencies (MySQL, Elasticsearch) in Docker:
- Start only the background services:
docker compose up -d sqlserver elasticsearch keycloak
- Create and activate a virtual environment:
python3 -m venv .venv source .venv/bin/activate - Install dependencies:
pip install -e .[dev]
- Run the Uvicorn server:
cd src uvicorn main:app --reload --port 8000
The easiest way to interact with the API locally is through the Swagger UI (http://localhost:8000/docs).
- Authentication: Before making requests that require authorization, you must obtain a token via Keycloak. In the Swagger UI, click the Authorize button and log in.
- Endpoints: The catalogue uses versioned APIs (e.g.,
/v1/...). You will find endpoints to managedatasets,models,publications,experiments, andnodes.
The project uses pytest for testing and ruff / pre-commit for code quality checks.
Running Tests:
Ensure your virtual environment is active and dependencies are installed. To run the test suite:
pytest src/tests/Pre-commit Hooks:
We enforce code style and formatting using pre-commit. To install the hooks:
pre-commit installThe repository provides profiles to spin up Prometheus and Grafana alongside the API.
To launch the stack with monitoring enabled, pass the monitoring profile to the launch script:
./scripts/up.sh monitoring- Grafana Dashboard: Accessible at http://localhost:3000 (Configured via
AIOD_GRAFANA_PORT).
We welcome contributions! Please follow the standard pull request workflow:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/my-new-feature). - Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/my-new-feature). - Open a Pull Request.
This project is licensed under the MIT License - Copyright (c) 2023 AI On Demand.