# bad-microservices/py_auth_micro architecture

> Architecture diagram of the GitHub repository bad-microservices/py_auth_micro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bad-microservices/py_auth_micro
- Repository: https://github.com/bad-microservices/py_auth_micro

## Overview

##### Main Components Identification

a) Authentication Flow Components:
- LDAP/AD Integration Layer
- Local Authentication System
- Token Management System (JWT with HMAC/RSA)
- Session Management

b) Core Structural Components:
- Configuration Management
- Models Layer
- Workflows Layer
- Exception Handling

##### Component Relationships

Use the following conventions:
- Blue: Authentication flows
- Green: Configuration flows
- Orange: Data access flows

##### Specific Elements

a) Authentication Flow:
- Dual-path authentication (LDAP vs Local)
- Token generation and validation processes
- Synchronization flow

b) Data Models:
- User Model
- Model
- Token Model
- Their relationships

c) Configuration Components:
- App Config
- DB Config
- LDAP Config

##### Technical Details to Highlight

- JWT Token Generation points
- HMAC/RSA signing options
- LDAP/AD integration points
- Database interaction layers
- Workflow orchestration

- Authentication flow
- Token issuance flow
- Synchronization
- Session management
- User management

Remember to:
- Clear boundaries between components
- Integration points with other microservices
- Security aspects of the system
- Document both synchronous and asynchronous flows

This will provide a comprehensive view of the authentication microservice while maintaining the appropriate level of detail for a principal software engineer to understand the system's architecture and interactions.

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Systems
    subgraph External
        LDAP[("LDAP/AD")]
        ClientApps["Client Applications"]
    end

    %% Authentication Layer
    subgraph AuthLayer["Authentication Layer"]
        LDAPHandler["LDAP Login Handler"]:::auth
        LocalHandler["Local Login Handler"]:::auth
        TokenMgmt["Token Management"]:::auth
    end

    %% Core Services Layer
    subgraph CoreServices["Core Services"]
        ConfigMgmt["Configuration Management"]:::core
        DBInteractions["Database Interactions"]:::core
        LDAPInt["LDAP Integration"]:::core
    end

    %% Models Layer
    subgraph DataModels["Data Models"]
        UserModel["User Model"]:::model
        GroupModel["Group Model"]:::model
        TokenModel["Token Model"]:::model
    end

    %% Workflows Layer
    subgraph Workflows["Workflows"]
        UserWF["User Workflow"]:::workflow
        GroupWF["Group Workflow"]:::workflow
        SessionWF["Session Management"]:::workflow
    end

    %% Configuration Components
    subgraph Config["Configuration"]
        AppConfig["App Config"]:::config
        DBConfig["DB Config"]:::config
        LDAPConfig["LDAP Config"]:::config
    end

    %% Relationships
    ClientApps --> LDAPHandler & LocalHandler
    LDAPHandler --> TokenMgmt
    LocalHandler --> TokenMgmt
    LDAPHandler --> LDAPInt
    LDAPInt --> LDAP
    
    TokenMgmt --> TokenModel
    TokenMgmt --> SessionWF
    
    UserWF --> UserModel
    GroupWF --> GroupModel
    
    ConfigMgmt --> AppConfig & DBConfig & LDAPConfig
    
    LDAPInt --> ConfigMgmt
    DBInteractions --> UserModel & GroupModel & TokenModel
    
    SessionWF --> TokenMgmt
    UserWF --> DBInteractions
    GroupWF --> DBInteractions

    %% Styles
    classDef auth fill:#f9f,stroke:#333,stroke-width:2px
    classDef core fill:#bbf,stroke:#333,stroke-width:2px
    classDef model fill:#bfb,stroke:#333,stroke-width:2px
    classDef workflow fill:#fbf,stroke:#333,stroke-width:2px
    classDef config fill:#ffb,stroke:#333,stroke-width:2px

    %% Click Events
    click LDAPHandler "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/LoginHandler/_loginldap.py"
    click LocalHandler "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/LoginHandler/_loginlocal.py"
    click TokenMgmt "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/Models/_token.py"
    click LDAPInt "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/Core/_ldap_interactions.py"
    click ConfigMgmt "https://github.com/bad-microservices/py_auth_micro/tree/main/py_auth_micro/Config/"
    click UserModel "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/Models/_user.py"
    click GroupModel "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/Models/_group.py"
    click TokenModel "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/Models/_token.py"
    click UserWF "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/WorkFlows/_userworkflow.py"
    click GroupWF "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/WorkFlows/_groupworkflow.py"
    click SessionWF "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/WorkFlows/_sessionworkflow.py"
    click AppConfig "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/Config/_appconfig.py"
    click DBConfig "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/Config/_dbconfig.py"
    click LDAPConfig "https://github.com/bad-microservices/py_auth_micro/blob/main/py_auth_micro/Config/_ldapconfig.py"
```
