# drkno/plexsso architecture

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

- Interactive diagram: https://gitdiagram.com/drkno/plexsso
- Repository: https://github.com/drkno/plexsso

## Overview

##### Main Components

a. Core Components:
- Nginx Reverse Proxy (External)
- PlexSSO Backend (ASP.NET Core)
- React Frontend (UI)
- Plex Authentication Service (External)
- Plugin System
- Target Services (External)

b. Key Architectural Elements:
- Authentication Flow
- Plugin Architecture
- Configuration Management
- Access Control System

**[User Browser] → [Nginx Reverse Proxy]**

**[Frontend (React)]**
- ↕
**[Backend (ASP.NET Core)]**
- ↙     ↓     ↘
**[Auth] [Config] [Plugins]**

**[Plex Auth] [Target Services (Ombi, Deluge, etc.)]**

##### Component Details

Frontend (UI):
- Main components: Login Page, Admin Page, Access Denied Page
- Plex OAuth integration

Backend:
- Controllers: Login, Logout, SSO, Redirect
- Services: Authentication, Configuration, Plugin Management
- Models: API models, Internal models, Type definitions

Plugin System:
- Plugin interface
- Available plugins (Deluge, Ombi, Overseerr, Tautulli)
- Plugin communication paths

##### Data Flow Indicators

- Authentication flow from user → Nginx → PlexSSO → Plex
- Token management between PlexSSO and target services
- Configuration data flow
- Plugin communication paths

##### Important Details

Authentication Flow:
**Browser → Nginx auth_request → PlexSSO → Plex Authentication**
- ↙
**Success/Denial Response**

Plugin Architecture:
**[Core Service Registry]**
- ↓
**[Plugin Interface (IPlugin)]**
- ↙   ↓    ↘
**[Deluge] [Ombi] [Other Plugins]**

Configuration System:
**[Config Service]**
- ↓
**[Access Controls] → [Rule Evaluation]**

##### Technical Details to Highlight

- ASP.NET Core backend architecture
- React frontend component structure
- Plugin system extensibility
- Configuration management
- Authentication token flow

Remember to include notes about:
- Docker deployment context
- Nginx integration requirements
- Plugin extensibility points
- Configuration options
- Security boundaries

This will provide a complete picture of how PlexSSO operates as a single sign-on solution for Plex-based services.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External["External Layer"]
        Browser["Web Browser"]
        Nginx["Nginx Reverse Proxy"]:::proxy
        Plex["Plex Authentication"]
        TargetServices["Target Services"]:::external
    end

    subgraph Core["PlexSSO Core"]
        subgraph Frontend["Frontend Layer"]
            LoginPage["Login Page"]:::ui
            AdminPage["Admin Page"]:::ui
            DeniedPage["Access Denied Page"]:::ui
            PlexOAuth["Plex OAuth"]:::ui
        end

        subgraph Backend["Backend Layer"]
            Controllers["Controllers"]:::backend
            AuthService["Authentication Service"]:::backend
            ConfigService["Configuration Service"]:::backend
            PlexClient["Plex Client"]:::backend
            TokenService["Token Service"]:::backend
            HealthCheck["Health Checker"]:::backend
        end

        subgraph Plugins["Plugin System"]
            PluginInterface["Plugin Interface"]:::plugin
            PluginLoader["Plugin Loader"]:::plugin
            ServiceRegistry["Service Registry"]:::plugin
            
            subgraph AvailablePlugins["Available Plugins"]
                DelugePlugin["Deluge Plugin"]:::plugin
                OmbiPlugin["Ombi Plugin"]:::plugin
                OverseerrPlugin["Overseerr Plugin"]:::plugin
                TautulliPlugin["Tautulli Plugin"]:::plugin
            end
        end
    end

    %% Relationships
    Browser --> Nginx
    Nginx --> Controllers
    Controllers --> AuthService
    AuthService --> PlexClient
    PlexClient --> Plex
    ConfigService --> AuthService
    Controllers --> ConfigService
    
    LoginPage --> PlexOAuth
    PlexOAuth --> Controllers
    AdminPage --> Controllers
    
    ServiceRegistry --> PluginInterface
    PluginLoader --> ServiceRegistry
    PluginInterface --> DelugePlugin
    PluginInterface --> OmbiPlugin
    PluginInterface --> OverseerrPlugin
    PluginInterface --> TautulliPlugin
    
    DelugePlugin --> TargetServices
    OmbiPlugin --> TargetServices
    OverseerrPlugin --> TargetServices
    TautulliPlugin --> TargetServices

    %% Styles
    classDef external fill:#gray
    classDef proxy fill:#lightblue
    classDef ui fill:#green
    classDef backend fill:#blue
    classDef plugin fill:#yellow

    %% Click Events
    click Nginx "https://github.com/drkno/plexsso/blob/main/examples/nginx/sso_common.conf"
    click Controllers "https://github.com/drkno/plexsso/tree/main/backend/PlexSSO/Controllers/"
    click AuthService "https://github.com/drkno/plexsso/tree/main/backend/PlexSSO/Service/Auth/"
    click ConfigService "https://github.com/drkno/plexsso/tree/main/backend/PlexSSO/Service/Config/"
    click PlexClient "https://github.com/drkno/plexsso/tree/main/backend/PlexSSO/Service/PlexClient/"
    click LoginPage "https://github.com/drkno/plexsso/tree/main/ui/src/pages/login-page/"
    click AdminPage "https://github.com/drkno/plexsso/tree/main/ui/src/pages/sso-admin-page/"
    click DeniedPage "https://github.com/drkno/plexsso/tree/main/ui/src/pages/access-denied-page/"
    click PlexOAuth "https://github.com/drkno/plexsso/blob/main/ui/src/common/PlexOAuth.jsx"
    click PluginInterface "https://github.com/drkno/plexsso/blob/main/backend/PlexSSO/Plugin/IPlugin.cs"
    click PluginLoader "https://github.com/drkno/plexsso/blob/main/backend/PlexSSO/Service/Plugin/PluginLoader.cs"
    click DelugePlugin "https://github.com/drkno/plexsso/tree/main/backend/Plugins/PlexSSO.Deluge.Plugin/"
    click OmbiPlugin "https://github.com/drkno/plexsso/tree/main/backend/Plugins/PlexSSO.Ombi.Plugin/"
    click OverseerrPlugin "https://github.com/drkno/plexsso/tree/main/backend/Plugins/PlexSSO.Overseerr.Plugin/"
    click TautulliPlugin "https://github.com/drkno/plexsso/tree/main/backend/Plugins/PlexSSO.Tautulli.Plugin/"
    click ServiceRegistry "https://github.com/drkno/plexsso/blob/main/backend/PlexSSO/Service/ServiceRegistry.cs"
    click TokenService "https://github.com/drkno/plexsso/blob/main/backend/PlexSSO/Service/ITokenService.cs"
    click HealthCheck "https://github.com/drkno/plexsso/blob/main/backend/PlexSSO/Service/HealthCheck/HealthChecker.cs"
    click ConfigService "https://github.com/drkno/plexsso/blob/main/backend/PlexSSO/Service/Config/ConfigurationService.cs"
```
