# authed-dev/authed architecture

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

- Interactive diagram: https://gitdiagram.com/authed-dev/authed
- Repository: https://github.com/authed-dev/authed

## Overview

##### Project Type and Purpose
- Authed 2.0 is an identity/authentication platform designed for AI-native systems.
- It handles secure identity assignments, token-based authentication, role-based access control, and scoped credential management for autonomous agents.
- The project’s purpose is to serve as a layer in the AI ecosystem that manages agent authentication and authorization, with clear separation into distinct modules like identity, credentials, permissions, and audit.

##### Analyzing the File Structure
- Key top-level directories include:
- audit: Contains modules for logging, compliance, or tracking events.
- core: Provides the central lifecycle management, context, exceptions, and orchestration logic. The subdirectory lifecycle (with events and manager components) suggests a well-defined state/event management pattern.
- credentials: Manages credential operations, including base definitions and models.
- identity: Focused on identity management, including basic interfaces and default implementations.
- permissions: Contains similar structure to identity and credentials, indicating role-based access control enforcement.
- runtime: Likely handles request processing or the execution environment for the modules.
- The project also includes testing (with mocks for each module) and GitHub configuration for continuous integration and community guidelines.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% API Layer
    subgraph "API Layer"
        A["Agent Interface/API Layer"]
    end

    %% Core Orchestration Layer
    subgraph "Core Orchestration"
        CM["Core Manager"]
        subgraph "Lifecycle"
            LM["Lifecycle Manager"]
            LE["Lifecycle Events"]
        end
    end

    %% Modules Layer
    subgraph "Modules"
        ID["Identity Module"]
        CR["Credentials Module"]
        PM["Permissions Module"]
        AD["Audit Module"]
    end

    %% External Testing Mocks
    TM["External Testing Mocks"]

    %% Connections
    A -->|"Request"| CM
    CM -->|"Authenticate"| ID
    CM -->|"IssueToken"| CR
    CM -->|"CheckAccess"| PM
    CM -->|"TriggerEvent"| LM
    LM -->|"EmitEvent"| LE
    ID -->|"LogAuth"| AD
    CR -->|"LogCredential"| AD
    PM -->|"LogPermission"| AD
    A -->|"LogRequest"| AD
    TM -.->|"Simulate"| CM
    TM -.->|"Simulate"| ID
    TM -.->|"Simulate"| CR
    TM -.->|"Simulate"| PM
    TM -.->|"Simulate"| AD

    %% Click Events
    click A "https://github.com/authed-dev/authed/blob/main/runtime/handler.py"
    click CM "https://github.com/authed-dev/authed/blob/main/core/manager.py"
    click LM "https://github.com/authed-dev/authed/blob/main/core/lifecycle/manager.py"
    click LE "https://github.com/authed-dev/authed/blob/main/core/lifecycle/events.py"
    click ID "https://github.com/authed-dev/authed/tree/main/identity/"
    click CR "https://github.com/authed-dev/authed/tree/main/credentials/"
    click PM "https://github.com/authed-dev/authed/tree/main/permissions/"
    click AD "https://github.com/authed-dev/authed/tree/main/audit/"
    click TM "https://github.com/authed-dev/authed/tree/main/tests/mocks/"

    %% Styles
    classDef api fill:#aqua,stroke:#333,stroke-width:2px;
    classDef core fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef identity fill:#ffe699,stroke:#333,stroke-width:2px;
    classDef credentials fill:#cceeff,stroke:#333,stroke-width:2px;
    classDef permissions fill:#ffcc99,stroke:#333,stroke-width:2px;
    classDef audit fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef mock fill:#f5b7b1,stroke:#333,stroke-width:2px;

    class A api;
    class CM,LM,LE core;
    class ID identity;
    class CR credentials;
    class PM permissions;
    class AD audit;
    class TM mock;
```
