# openstack/skyline-apiserver architecture

> Architecture diagram of the GitHub repository openstack/skyline-apiserver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openstack/skyline-apiserver
- Repository: https://github.com/openstack/skyline-apiserver

## Overview

Skyline API Server is the backend service for the Skyline OpenStack dashboard. It is an ASGI application started with `uvicorn` against `skyline_apiserver.main:app`, and the repo is organized around API handling, OpenStack integration, policy management, and persistent configuration/state.

1. **Request entry point and app bootstrap**
   - `skyline_apiserver/main.py` and `__main__.py` are the runtime entry points.
   - Startup likely wires together config loading, logging, database setup, security, and route registration before serving HTTP traffic.
   - The README shows it is normally run either directly with Uvicorn for development or inside a container in production.

2. **HTTP API layer**
   - All external functionality is exposed under `skyline_apiserver/api/v1/`.
   - Main resource groups are `login`, `policy`, `setting`, `extension`, `prometheus`, and `contrib`.
   - `api/deps.py` is the boundary for shared request dependencies such as auth context, service clients, and request-scoped state.

3. **Authentication and request security**
   - `core/security.py` and `context.py` define how identity, authorization, and per-request context are handled.
   - The login flow is OpenStack-centric: the service authenticates users through Keystone and then uses that identity for downstream OpenStack requests.
   - The FAQ in the README makes clear that Skyline performs some authorization checks itself via the `/policy` API rather than relying only on downstream services.

4. **OpenStack client boundary**
   - `skyline_apiserver/client/openstack/` contains service-specific clients for Keystone, Nova, Neutron, Cinder, Glance, and a generic system client.
   - These modules isolate direct OpenStack REST interactions from the API handlers.
   - `client/utils.py` likely holds shared client helpers such as endpoint selection, token handling, and HTTP plumbing.

5. **Policy subsystem**
   - `skyline_apiserver/policy/` is a major subsystem and contains a base layer plus per-service policy managers under `policy/manager/`.
   - Managers exist for many OpenStack services: Keystone, Nova, Neutron, Cinder, Glance, Heat, Ironic, Magnum, Manila, Masakari, Octavia, Placement, Trove, Zun, Barbican, and Designate.
   - This subsystem is responsible for loading, normalizing, and serving policy rules so the UI can decide whether a user may see or invoke an action.
   - `cmd/policy_manager.py` and the related schemas suggest policy bundles can also be generated or managed as an operational task.

6. **Persistent state and migrations**
   - `db/models.py`, `db/api.py`, and `db/base.py` define the persistence layer.
   - Alembic migrations live under `db/alembic/`, with `000_init.py` as the initial schema migration.
   - The README indicates both SQLite and MariaDB are supported, so the app is designed to run with either embedded or external relational storage.

7. **Configuration model**
   - `config/` contains the runtime configuration system, split into base/default/OpenStack/setting layers.
   - The primary config file is `etc/skyline.yaml.sample`, typically copied to `/etc/skyline/skyline.yaml`.
   - Configuration covers database URL, Keystone URL, default region, endpoint interface type, system user credentials, and Prometheus settings.
   - `cmd/generate_sample_config.py` exists to emit a usable starter config.

8. **Prometheus integration**
   - The API includes a dedicated `prometheus` resource, which means the service can proxy or surface Prometheus data to the dashboard.
   - The README shows optional basic-auth and endpoint settings, so Prometheus is an external integration with configurable credentials rather than a built-in metrics store.

9. **API schemas and contract**
   - `schemas/` defines request/response models for each API group.
   - This is the main contract boundary between HTTP handlers and business logic, and it supports the generated OpenAPI/Swagger docs.
   - `cmd/generate_swagger.py` and the checked-in `swagger.json` indicate the API schema is exported as part of the build/release workflow.

10. **Packaging, deployment, and operational tooling**
   - `container/`, `kolla/`, `devstack/`, and `playbooks/` show the project is deployed in multiple OpenStack-oriented ways: container image, Kolla Ansible, DevStack, and OpenStack-Ansible.
   - `etc/gunicorn.py` and the Jinja nginx template suggest the service can also be fronted by generated web server config in some deployment modes.
   - `cmd/generate_nginx.py` indicates deployment artifacts are produced from templates rather than hand-maintained.

11. **Cross-cutting utility layer**
   - `utils/httpclient.py` likely centralizes outbound HTTP behavior.
   - `utils/roles.py` suggests role mapping or implied-role logic used by authorization decisions.
   - `types/constants.py` contains shared constants used across the service.

12. **Test and release structure**
   - Unit tests are organized by subsystem under `tests/unit/`, mirroring the production package layout.
   - `releasenotes/` and the `spec/` directory show the repo is maintained with OpenStack-style release management and feature/spec tracking.

Overall, the architecture is a thin HTTP API layer backed by a config-driven persistence layer and a substantial OpenStack integration layer. The most important diagram boundaries are: client requests into the ASGI app, policy/login checks against Keystone and service-specific policy data, outbound calls to OpenStack services, and DB-backed state/configuration on the server side.

Main entry points: [`skyline_apiserver/main.py`](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/main.py) (App startup), [`skyline_apiserver/api/v1`](https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/api/v1) (API v1), [`skyline_apiserver/core/security.py`](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/core/security.py) (Security), [`skyline_apiserver/policy/manager`](https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/policy/manager) (Policy managers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main["App startup<br/>ASGI entrypoint<br/>[main.py]"]
  node_app_main["Module entry<br/>Python module<br/>[__main__.py]"]
  node_api_v1["API v1<br/>HTTP routes"]
  node_api_deps["API deps<br/>request boundary<br/>[deps.py]"]
end

subgraph group_core["Core Services"]
  node_security["Security<br/>authz/authn<br/>[security.py]"]
  node_context["Context<br/>[context.py]"]
  node_openstack_clients["OpenStack clients<br/>service adapters"]
  node_client_utils["Client utils<br/>http plumbing<br/>[utils.py]"]
  node_policy_base["Policy core<br/>policy engine<br/>[base.py]"]
  node_policy_mgr["Policy managers<br/>service policies"]
  node_http_utils["HTTP utils<br/>shared helpers<br/>[httpclient.py]"]
end

subgraph group_state["State & Config"]
  node_db_api["DB API<br/>persistence layer<br/>[api.py]"]
  node_db_models["DB models<br/>ORM models<br/>[models.py]"]
  node_config["Config"]
  node_schemas["Schemas<br/>API contract"]
end

subgraph group_ops["Ops & Tooling"]
  node_policy_cmd["Policy cmd<br/>ops command<br/>[policy_manager.py]"]
  node_swagger_cmd["Swagger cmd<br/>ops command"]
  node_config_cmd["Config cmd<br/>ops command"]
  node_nginx_tpl["Nginx template<br/>deploy artifact<br/>[nginx.conf.j2]"]
end

node_app_main -->|"launches"| node_main
node_main -->|"loads"| node_config
node_main -->|"wires"| node_security
node_main -->|"initializes"| node_db_api
node_main -->|"serves"| node_api_v1
node_api_v1 -->|"depends on"| node_api_deps
node_api_v1 -->|"validates with"| node_schemas
node_api_v1 -->|"checks"| node_security
node_api_v1 -->|"calls"| node_openstack_clients
node_api_deps -->|"builds"| node_context
node_api_deps -->|"injects"| node_openstack_clients
node_security -->|"stores"| node_context
node_security -->|"consults"| node_policy_base
node_openstack_clients -->|"uses"| node_client_utils
node_client_utils -->|"builds on"| node_http_utils
node_policy_base -->|"extends"| node_policy_mgr
node_policy_mgr -->|"reads"| node_config
node_policy_mgr -->|"persists"| node_db_api
node_db_api -->|"operates on"| node_db_models
node_config_cmd -->|"generates"| node_config
node_policy_cmd -->|"operates on"| node_policy_mgr
node_swagger_cmd -->|"exports"| node_schemas
node_swagger_cmd -->|"documents"| node_api_v1
node_nginx_tpl -->|"fronts"| node_main

click node_main "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/main.py"
click node_app_main "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/__main__.py"
click node_api_v1 "https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/api/v1"
click node_api_deps "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/api/deps.py"
click node_security "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/core/security.py"
click node_context "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/context.py"
click node_openstack_clients "https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/client/openstack"
click node_client_utils "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/client/utils.py"
click node_policy_base "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/policy/base.py"
click node_policy_mgr "https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/policy/manager"
click node_db_api "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/db/api.py"
click node_db_models "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/db/models.py"
click node_config "https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/config"
click node_schemas "https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/schemas"
click node_policy_cmd "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/cmd/policy_manager.py"
click node_swagger_cmd "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/cmd/generate_swagger.py"
click node_config_cmd "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/cmd/generate_sample_config.py"
click node_nginx_tpl "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/templates/nginx.conf.j2"
click node_http_utils "https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/utils/httpclient.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_app_main,node_api_v1,node_api_deps toneBlue
class node_security,node_context,node_openstack_clients,node_client_utils,node_policy_base,node_policy_mgr,node_http_utils toneAmber
class node_db_api,node_db_models,node_config,node_schemas toneMint
class node_policy_cmd,node_swagger_cmd,node_config_cmd,node_nginx_tpl toneRose
```

## Components

### Runtime

ASGI entrypoint and HTTP API surface

- [App startup](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/main.py): ASGI entrypoint · Bootstraps the service and serves the FastAPI app · `skyline_apiserver/main.py`
- [Module entry](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/__main__.py): Python module · Module entry for running the server package · `skyline_apiserver/__main__.py`
- [API v1](https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/api/v1): HTTP routes · Versioned API handlers for login, policy, settings, extensions, contrib, and Prometheus · `skyline_apiserver/api/v1`
- [API deps](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/api/deps.py): request boundary · Shared request-scoped dependencies and injected services · `skyline_apiserver/api/deps.py`

### Core Services

Security, policy, context, and OpenStack integration

- [Security](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/core/security.py): authz/authn · Identity, authorization, and request security helpers · `skyline_apiserver/core/security.py`
- [Context](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/context.py): request context · Per-request user and service context · `skyline_apiserver/context.py`
- [OpenStack clients](https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/client/openstack): service adapters · REST clients for Keystone, Nova, Neutron, Cinder, Glance, and system operations · `skyline_apiserver/client/openstack`
- [Client utils](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/client/utils.py): http plumbing · Shared outbound HTTP and token/endpoint helpers · `skyline_apiserver/client/utils.py`
- [Policy core](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/policy/base.py): policy engine · Base policy loading and normalization logic · `skyline_apiserver/policy/base.py`
- [Policy managers](https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/policy/manager): service policies · Per-service policy loaders and rule managers · `skyline_apiserver/policy/manager`
- [HTTP utils](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/utils/httpclient.py): shared helpers · Reusable HTTP client helpers for outbound calls · `skyline_apiserver/utils/httpclient.py`

### State & Config

Persistence, runtime settings, and shared contracts

- [DB API](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/db/api.py): persistence layer · Database access helpers and session-facing API · `skyline_apiserver/db/api.py`
- [DB models](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/db/models.py): ORM models · Persistent entities and schema-backed models · `skyline_apiserver/db/models.py`
- [Config](https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/config): runtime config · Base, default, OpenStack, and setting configuration layers · `skyline_apiserver/config`
- [Schemas](https://github.com/openstack/skyline-apiserver/tree/master/skyline_apiserver/schemas): API contract · Request and response models for the public API · `skyline_apiserver/schemas`

### Ops & Tooling

Operational commands and generated artifacts

- [Policy cmd](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/cmd/policy_manager.py): ops command · Operational policy bundle generation and management · `skyline_apiserver/cmd/policy_manager.py`
- [Swagger cmd](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/cmd/generate_swagger.py): ops command · Exports the OpenAPI/Swagger document · `skyline_apiserver/cmd/generate_swagger.py`
- [Config cmd](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/cmd/generate_sample_config.py): ops command · Generates starter configuration files · `skyline_apiserver/cmd/generate_sample_config.py`
- [Nginx template](https://github.com/openstack/skyline-apiserver/blob/master/skyline_apiserver/templates/nginx.conf.j2): deploy artifact · Generated web server configuration template · `skyline_apiserver/templates/nginx.conf.j2`

## Connections

- Module entry → App startup: launches · Package entry delegates to the ASGI application bootstrap
- App startup → Config: loads · Startup reads runtime configuration
- App startup → Security: wires · Bootstrapping connects auth and request security
- App startup → DB API: initializes · Startup prepares persistence access
- App startup → API v1: serves · The ASGI app exposes versioned routes
- API v1 → API deps: depends on · Handlers use shared request dependencies
- API v1 → Schemas: validates with · Route inputs and outputs use typed schemas
- API v1 → Security: checks · Login and policy endpoints use authn/authz helpers
- API v1 → OpenStack clients: calls · Handlers delegate OpenStack operations to service clients
- API deps → Context: builds · Dependencies assemble request context
- API deps → OpenStack clients: injects · Request-scoped client access is provided here
- Security → Context: stores · Security decisions are reflected in request context
- Security → Policy core: consults · Authorization may consult loaded policy rules
- OpenStack clients → Client utils: uses · Service clients share transport and endpoint helpers
- Client utils → HTTP utils: builds on · Outbound HTTP behavior is centralized
- Policy core → Policy managers: extends · Service-specific managers specialize the policy core
- Policy managers → Config: reads · Policy sources and service settings come from config
- Policy managers → DB API: persists · Policy state can be stored or refreshed via the DB layer
- DB API → DB models: operates on · Database access uses ORM models
- Config cmd → Config: generates · Produces a starter configuration sample
- Policy cmd → Policy managers: operates on · Operational command drives policy bundle management
- Swagger cmd → Schemas: exports · Swagger generation is based on API schemas
- Swagger cmd → API v1: documents · Generated OpenAPI covers the public routes
- Nginx template → App startup: fronts · Deployment template fronts the running service
