# groverankur/astra architecture

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

- Interactive diagram: https://gitdiagram.com/groverankur/astra
- Repository: https://github.com/groverankur/astra

## Overview

Astra is a Python authentication and authorization platform. Its principal runtime path accepts application requests through framework adapters, processes OAuth/OIDC grants, and issues tokens and sessions; authorization and MFA provide policy and authentication controls along that path. Operators also configure and inspect deployments through the CLI and browser admin UI. The graph includes documented federation, WebAuthn, plugins, persistence, tenancy, and policy capabilities; some are represented at directory level because their implementation was not sampled.

Main entry points: [`src/astraauth/core/oauth/services.py`](https://github.com/groverankur/astra/blob/main/src/astraauth/core/oauth/services.py) (OAuth/OIDC grants), [`src/astraauth/core/sessions/services.py`](https://github.com/groverankur/astra/blob/main/src/astraauth/core/sessions/services.py) (Session lifecycle), [`src/astraauth/core/adapters/oauth_http.py`](https://github.com/groverankur/astra/blob/main/src/astraauth/core/adapters/oauth_http.py) (OAuth HTTP endpoints), [`packages/astraauth-admin-ui/src/astraauth_admin_ui/app.py`](https://github.com/groverankur/astra/blob/main/packages/astraauth-admin-ui/src/astraauth_admin_ui/app.py) (Browser admin UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_adapters["Framework adapters"]
end

subgraph group_protocol["Auth protocols"]
  node_http["OAuth HTTP endpoints<br/>[oauth_http.py]"]
  node_oauth["OAuth/OIDC grants<br/>[services.py]"]
  node_clientauth["Client authentication<br/>[client_auth.py]"]
  node_tokens["Token management<br/>[token_manager.py]"]
  node_sessions["Session lifecycle<br/>[services.py]"]
  node_sessionstate["Session state<br/>[models.py]"]
  node_idp["OIDC federation<br/>[services.py]"]
end

subgraph group_controls["Security controls"]
  node_authorization["RBAC and ABAC<br/>[engine.py]"]
  node_mfa["MFA services<br/>[services.py]"]
  node_mfa_models["MFA contracts<br/>[models.py]"]
  node_policy_parser["Policy DSL parser<br/>[parser.py]"]
  node_policy_engine["Relationship checks<br/>[engine.py]"]
  node_webauthn["WebAuthn ceremonies<br/>[services.py]"]
end

subgraph group_runtime["Runtime services"]
  node_sessionstore["Session stores<br/>[store.py]"]
  node_persistence[("Relational persistence<br/>[relational.py]")]
  node_events["Event bus<br/>[base.py]"]
  node_plugins["Plugin runtime<br/>[runtime.py]"]
  node_tenancy["Tenant middleware<br/>[middleware.py]"]
  node_config["Runtime configuration<br/>[settings.py]"]
end

subgraph group_operator["Operator tools"]
  node_cli["Operator CLI<br/>[app.py]"]
  node_admin["Browser admin UI<br/>[app.py]"]
  node_admin_components["Dashboard views<br/>[components.py]"]
end

node_app(("Python application"))
node_client(("OAuth client"))

node_app -->|"uses"| node_adapters
node_adapters -.->|"wires endpoints"| node_http
node_client -->|"requests tokens"| node_http
node_http -->|"dispatches grants"| node_oauth
node_http -->|"checks access"| node_authorization
node_http -->|"handles sessions"| node_sessions
node_oauth -->|"authenticates client"| node_clientauth
node_oauth -->|"checks policy"| node_authorization
node_oauth -->|"creates sessions"| node_sessions
node_oauth -->|"issues tokens"| node_tokens
node_sessions -->|"creates and rotates"| node_sessionstate
node_sessions -->|"reads and writes"| node_sessionstore
node_sessions -->|"encrypts refresh tokens"| node_tokens
node_sessions -->|"publishes events"| node_events
node_mfa -->|"uses contracts"| node_mfa_models
node_mfa -->|"validates session"| node_sessions
node_webauthn -->|"upgrades MFA"| node_mfa
node_policy_engine -->|"uses schema"| node_policy_parser
node_admin -->|"renders views"| node_admin_components
node_cli -->|"launches UI"| node_admin
node_cli -->|"loads settings"| node_config
node_admin -->|"uses settings"| node_config
node_oauth -.->|"persists state"| node_persistence
node_idp -.->|"stores federation state"| node_persistence
node_plugins -.->|"uses relational storage"| node_persistence
node_tenancy -.->|"scopes requests"| node_oauth
node_client -.->|"federates identity"| node_idp

click node_adapters "https://github.com/groverankur/astra/tree/main/src/astraauth/adapters"
click node_http "https://github.com/groverankur/astra/blob/main/src/astraauth/core/adapters/oauth_http.py"
click node_oauth "https://github.com/groverankur/astra/blob/main/src/astraauth/core/oauth/services.py"
click node_clientauth "https://github.com/groverankur/astra/blob/main/src/astraauth/core/oauth/client_auth.py"
click node_tokens "https://github.com/groverankur/astra/blob/main/src/astraauth/core/token/token_manager.py"
click node_sessions "https://github.com/groverankur/astra/blob/main/src/astraauth/core/sessions/services.py"
click node_sessionstate "https://github.com/groverankur/astra/blob/main/src/astraauth/core/sessions/models.py"
click node_sessionstore "https://github.com/groverankur/astra/blob/main/src/astraauth/core/sessions/store.py"
click node_authorization "https://github.com/groverankur/astra/blob/main/src/astraauth/core/authorization/engine.py"
click node_mfa "https://github.com/groverankur/astra/blob/main/src/astraauth/core/mfa/services.py"
click node_mfa_models "https://github.com/groverankur/astra/blob/main/src/astraauth/core/mfa/models.py"
click node_policy_parser "https://github.com/groverankur/astra/blob/main/packages/astraauth-policy/src/astraauth_policy/parser.py"
click node_policy_engine "https://github.com/groverankur/astra/blob/main/packages/astraauth-policy/src/astraauth_policy/engine.py"
click node_persistence "https://github.com/groverankur/astra/blob/main/src/astraauth/core/persistence/relational.py"
click node_events "https://github.com/groverankur/astra/blob/main/src/astraauth/core/events/base.py"
click node_plugins "https://github.com/groverankur/astra/blob/main/src/astraauth/plugins/runtime.py"
click node_idp "https://github.com/groverankur/astra/blob/main/src/astraauth/idp/services.py"
click node_webauthn "https://github.com/groverankur/astra/blob/main/src/astraauth/webauthn/services.py"
click node_cli "https://github.com/groverankur/astra/blob/main/packages/astraauth-cli/src/astraauth_cli/app.py"
click node_admin "https://github.com/groverankur/astra/blob/main/packages/astraauth-admin-ui/src/astraauth_admin_ui/app.py"
click node_admin_components "https://github.com/groverankur/astra/blob/main/packages/astraauth-admin-ui/src/astraauth_admin_ui/components.py"
click node_tenancy "https://github.com/groverankur/astra/blob/main/packages/astraauth-tenancy/src/astraauth_tenancy/middleware.py"
click node_config "https://github.com/groverankur/astra/blob/main/src/astraauth/core/config/settings.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_adapters,node_client toneBlue
class node_http,node_oauth,node_clientauth,node_tokens,node_sessions,node_sessionstate,node_idp toneAmber
class node_authorization,node_mfa,node_mfa_models,node_policy_parser,node_policy_engine,node_webauthn toneMint
class node_sessionstore,node_persistence,node_events,node_plugins,node_tenancy,node_config toneRose
class node_cli,node_admin,node_admin_components,node_app toneIndigo
```

## Components

### Entry points

- [Framework adapters](https://github.com/groverankur/astra/tree/main/src/astraauth/adapters): `src/astraauth/adapters`

### Auth protocols

- [OAuth HTTP endpoints](https://github.com/groverankur/astra/blob/main/src/astraauth/core/adapters/oauth_http.py): `src/astraauth/core/adapters/oauth_http.py`
- [OAuth/OIDC grants](https://github.com/groverankur/astra/blob/main/src/astraauth/core/oauth/services.py): `src/astraauth/core/oauth/services.py`
- [Client authentication](https://github.com/groverankur/astra/blob/main/src/astraauth/core/oauth/client_auth.py): `src/astraauth/core/oauth/client_auth.py`
- [Token management](https://github.com/groverankur/astra/blob/main/src/astraauth/core/token/token_manager.py): `src/astraauth/core/token/token_manager.py`
- [Session lifecycle](https://github.com/groverankur/astra/blob/main/src/astraauth/core/sessions/services.py): `src/astraauth/core/sessions/services.py`
- [Session state](https://github.com/groverankur/astra/blob/main/src/astraauth/core/sessions/models.py): `src/astraauth/core/sessions/models.py`
- [OIDC federation](https://github.com/groverankur/astra/blob/main/src/astraauth/idp/services.py): `src/astraauth/idp/services.py`

### Security controls

- [RBAC and ABAC](https://github.com/groverankur/astra/blob/main/src/astraauth/core/authorization/engine.py): `src/astraauth/core/authorization/engine.py`
- [MFA services](https://github.com/groverankur/astra/blob/main/src/astraauth/core/mfa/services.py): `src/astraauth/core/mfa/services.py`
- [MFA contracts](https://github.com/groverankur/astra/blob/main/src/astraauth/core/mfa/models.py): `src/astraauth/core/mfa/models.py`
- [Policy DSL parser](https://github.com/groverankur/astra/blob/main/packages/astraauth-policy/src/astraauth_policy/parser.py): `packages/astraauth-policy/src/astraauth_policy/parser.py`
- [Relationship checks](https://github.com/groverankur/astra/blob/main/packages/astraauth-policy/src/astraauth_policy/engine.py): `packages/astraauth-policy/src/astraauth_policy/engine.py`
- [WebAuthn ceremonies](https://github.com/groverankur/astra/blob/main/src/astraauth/webauthn/services.py): `src/astraauth/webauthn/services.py`

### Runtime services

- [Session stores](https://github.com/groverankur/astra/blob/main/src/astraauth/core/sessions/store.py): `src/astraauth/core/sessions/store.py`
- [Relational persistence](https://github.com/groverankur/astra/blob/main/src/astraauth/core/persistence/relational.py): `src/astraauth/core/persistence/relational.py`
- [Event bus](https://github.com/groverankur/astra/blob/main/src/astraauth/core/events/base.py): `src/astraauth/core/events/base.py`
- [Plugin runtime](https://github.com/groverankur/astra/blob/main/src/astraauth/plugins/runtime.py): `src/astraauth/plugins/runtime.py`
- [Tenant middleware](https://github.com/groverankur/astra/blob/main/packages/astraauth-tenancy/src/astraauth_tenancy/middleware.py): `packages/astraauth-tenancy/src/astraauth_tenancy/middleware.py`
- [Runtime configuration](https://github.com/groverankur/astra/blob/main/src/astraauth/core/config/settings.py): `src/astraauth/core/config/settings.py`

### Operator tools

- [Operator CLI](https://github.com/groverankur/astra/blob/main/packages/astraauth-cli/src/astraauth_cli/app.py): `packages/astraauth-cli/src/astraauth_cli/app.py`
- [Browser admin UI](https://github.com/groverankur/astra/blob/main/packages/astraauth-admin-ui/src/astraauth_admin_ui/app.py): `packages/astraauth-admin-ui/src/astraauth_admin_ui/app.py`
- [Dashboard views](https://github.com/groverankur/astra/blob/main/packages/astraauth-admin-ui/src/astraauth_admin_ui/components.py): `packages/astraauth-admin-ui/src/astraauth_admin_ui/components.py`

### Other components

- **Python application**
- **OAuth client**

## Connections

- Python application → Framework adapters: uses (evidence: `README.md`)
- Framework adapters → OAuth HTTP endpoints: wires endpoints
- OAuth client → OAuth HTTP endpoints: requests tokens (evidence: `README.md`)
- OAuth HTTP endpoints → OAuth/OIDC grants: dispatches grants (evidence: `src/astraauth/core/adapters/oauth_http.py`)
- OAuth HTTP endpoints → RBAC and ABAC: checks access (evidence: `src/astraauth/core/adapters/oauth_http.py`)
- OAuth HTTP endpoints → Session lifecycle: handles sessions (evidence: `src/astraauth/core/adapters/oauth_http.py`)
- OAuth/OIDC grants → Client authentication: authenticates client (evidence: `src/astraauth/core/oauth/services.py`)
- OAuth/OIDC grants → RBAC and ABAC: checks policy (evidence: `src/astraauth/core/oauth/services.py`)
- OAuth/OIDC grants → Session lifecycle: creates sessions (evidence: `src/astraauth/core/oauth/services.py`)
- OAuth/OIDC grants → Token management: issues tokens (evidence: `src/astraauth/core/oauth/services.py`)
- Session lifecycle → Session state: creates and rotates (evidence: `src/astraauth/core/sessions/services.py`)
- Session lifecycle → Session stores: reads and writes (evidence: `src/astraauth/core/sessions/services.py`)
- Session lifecycle → Token management: encrypts refresh tokens (evidence: `src/astraauth/core/sessions/services.py`)
- Session lifecycle → Event bus: publishes events (evidence: `src/astraauth/core/sessions/services.py`)
- MFA services → MFA contracts: uses contracts (evidence: `src/astraauth/core/mfa/services.py`)
- MFA services → Session lifecycle: validates session (evidence: `src/astraauth/core/mfa/services.py`)
- WebAuthn ceremonies → MFA services: upgrades MFA (evidence: `src/astraauth/webauthn/services.py`)
- Relationship checks → Policy DSL parser: uses schema (evidence: `packages/astraauth-policy/src/astraauth_policy/engine.py`)
- Browser admin UI → Dashboard views: renders views (evidence: `packages/astraauth-admin-ui/src/astraauth_admin_ui/app.py`)
- Operator CLI → Browser admin UI: launches UI (evidence: `packages/astraauth-cli/src/astraauth_cli/app.py`)
- Operator CLI → Runtime configuration: loads settings (evidence: `packages/astraauth-cli/src/astraauth_cli/app.py`)
- Browser admin UI → Runtime configuration: uses settings (evidence: `packages/astraauth-admin-ui/src/astraauth_admin_ui/app.py`)
- OAuth/OIDC grants → Relational persistence: persists state
- OIDC federation → Relational persistence: stores federation state
- Plugin runtime → Relational persistence: uses relational storage
- Tenant middleware → OAuth/OIDC grants: scopes requests
- OAuth client → OIDC federation: federates identity
