How ai4os/ai4-papi works
Main Components
• API Server (FastAPI): At the heart is the FastAPI application (see ai4papi/main.py) that routes incoming HTTP requests.
• Routers / Endpoints: The project organizes its endpoints in a versioned manner under ai4papi/routers/v1. These include:
• Catalog – for metadata access to modules/tools
• Deployments – for launching and managing module deployments (secured endpoints)
• Inference – for inference-related endpoints
• Try_me – for demo deployments
• Stats and others (e.g., secrets, storage)
• Authentication Module: A dedicated auth.py in the package handles OIDC token validation and related authentication flows.
• Integration with External Services:
• Nomad – used for scheduling and deploying jobs (see ai4papi/nomad and configuration files in etc/nomad-related hcl)
• OSCAR – hinted at in the README, representing decoupled underlying tooling.
• Configuration Management:
• The etc folder holds YAML and HCL configuration files (main_conf.yaml, module and tool configurations) that drive the application's behavior.
• Deployment & DevOps Infrastructure:
• Docker-related files, docker-compose, and GitHub workflows (in .github/workflows) indicate containerization and CI/CD practices.
• Testing & Quality Assurance:
• A dedicated tests directory with test suites for individual endpoints.
• Pre-commit and formatting tools (Ruff) integrated in development.
Relationships and Interactions
• Clients (e.g., Swagger UI accessed through a browser, or Python scripts using the API) send HTTP requests, which get routed to the FastAPI server.
• FastAPI then directs requests to the relevant router modules (catalog, deployments, etc.).
• The Deployments endpoints interface with Nomad (via the Nomad integration modules) to schedule containerized jobs.
• Configuration data is loaded from the etc folder to control dynamic settings for deployments, quotas, and custom configurations.
• External systems (like OSCAR for additional services) and the Docker container registry/infrastructure form part of the broader ecosystem.
Architectural Patterns and Design Principles
• Modular Design: Separation of API endpoints into clear versioned modules allows scalability and independent evolution of service areas.
• Decoupling: The API abstracts away the complexities of directly interacting with underlying systems (Nomad, OSCAR) by acting as an intermediary.
• Configuration-Driven Behavior: Extensive use of external YAML/HCL configurations supports flexibility in deploying and operating the application.
• Containerization & CI/CD: Docker, GitHub actions, and pre-commit hooks enforce quality and streamline deployment.
Relevant Technologies and Frameworks
• FastAPI (API layer)
• Nomad (job scheduling and orchestration)
• OAuth/OIDC for authentication (integration with EGI Check-In)
• Docker (containerization)
• Python testing frameworks (pytest or standard unittest in tests/)
• YAML/HCL configuration for module/tool settings