# skyost/openauthenticator architecture

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

- Interactive diagram: https://gitdiagram.com/skyost/openauthenticator
- Repository: https://github.com/skyost/openauthenticator

## Overview

##### Project Type & Purpose
- This is a cross-platform OTP (one-time password) application, built with Flutter, that runs on mobile (Android/iOS) and desktops (Linux, macOS, Windows). It provides user authentication and secure TOTP generation.
- The app integrates with external services such as Firebase (Auth, Firestore, Dynamic Links), RevenueCat, and Stripe for sign-in, synchronization, and payments.
- There is also a separate website (built with Nuxt 3) contained in the “docs” directory, which serves as the landing/marketing site and translation portal.

##### Main Components
- Client Applications:
- Mobile Clients & Desktop Clients: Built with Flutter (directories: android, ios, macos, linux, windows) with the core code in the “lib” directory.
- Website: Located in the “docs” folder, built with Nuxt 3.
- Core Application Logic:
- UI & Widgets: Managed in “lib/pages”, “lib/widgets” and related subdirectories.
- Business Logic & Models: Found in “lib/model” (authentication, totp, settings, storage, etc.).
- Utilities: “lib/utils” and helper scripts in “bin” for tasks like SVG compilation and version generation.
- Internationalization:
- Localization files in “lib/i18n” and “docs/locales” for multi-language support.
- Third-Party Integrations:
- Firebase services (Auth, Firestore, Dynamic Links).
- RevenueCat integration for in-app purchases.
- Stripe for payment links.

##### Mapping the Relationships & Data Flow
- Client Layer:
- Mobile/Desktop Frontend (Flutter) communicates with UI components, widget events, and calls into business logic.
- The website interacts with users for documentation, translations, and outreach.
- Business Logic & State Management:
- Located in the “lib/model”, “lib/pages”, “lib/widgets”, and “lib/utils”, which together manage OTP generation, user authentication, and settings.
- Back-End / External Services:
- Firebase Authentication: Handles user sign-in and validation.
- Firebase Firestore: Used for OTP synchronization.
- Firebase Dynamic Links: For deep linking support.
- RevenueCat and Stripe: Manage subscription/payment integrations.
- Utility Scripts:
- Scripts in “bin” such as compile_svg.dart and generate.dart are run during build-time to prepare assets and configuration for the app.

##### Architectural Patterns and Design Principles
- Separation of concerns: UI, business logic, and external service integrations are clearly separated. The “lib” directory reflects an organized modular design (models, pages, widgets, utils).
- Cross-platform design: The project uses Flutter as a unified framework, targeting multiple platforms through platform-specific directories (android, ios, macos, etc.).
- Internationalization and extensibility: Language resources are centralized for easy scalability.
- Using cloud-backend services (Firebase) minimizes the need for a dedicated server at this stage.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Node
    User["User"]:::user

    %% Flutter Client Subgraph
    subgraph "Flutter Client (Mobile & Desktop)"
        F_platform["Platform-Specific Code (android, ios, macos, linux, windows)"]:::client
        F_core["Core Code (lib)"]:::client
        F_pages["Pages (lib/pages)"]:::client
        F_widgets["Widgets (lib/widgets)"]:::client
        F_model["Business Logic & Models (lib/model)"]:::client
        F_i18n["Internationalization (lib/i18n)"]:::client
    end

    %% Website Client Subgraph
    subgraph "Website Client (Nuxt 3)"
        W_site["Website (Nuxt 3)"]:::website
        W_locales["Locales (docs/locales)"]:::website
    end

    %% External Services Subgraph
    subgraph "External Services"
        FirebaseAuth["Firebase Auth"]:::service
        FirebaseFirestore["Firebase Firestore"]:::service
        FirebaseDynamic["Firebase Dynamic Links"]:::service
        Payment["RevenueCat/Stripe"]:::service
    end

    %% Utilities & Build Tools Subgraph
    subgraph "Utilities & Build Tools"
        U_util["Utilities (lib/utils)"]:::utility
        U_bin["Build Scripts (bin)"]:::utility
    end

    %% Data Flow & Relationships
    User -->|"interacts"| F_pages
    User -->|"interacts"| F_widgets
    User -->|"interacts"| W_site

    F_core --> F_pages
    F_core --> F_widgets
    F_pages -->|"triggers"| F_model
    F_widgets -->|"triggers"| F_model
    F_i18n -->|"supplies"| F_pages
    F_i18n -->|"supplies"| F_widgets

    F_model -->|"authenticates"| FirebaseAuth
    F_model -->|"syncs"| FirebaseFirestore
    F_model -->|"links"| FirebaseDynamic
    F_model -->|"handlesPayment"| Payment

    U_bin -->|"preBuild"| F_core
    U_util -->|"supports"| F_model

    W_site -->|"uses"| W_locales

    %% Click Events
    click F_core "https://github.com/skyost/openauthenticator/tree/main/lib"
    click F_pages "https://github.com/skyost/openauthenticator/tree/main/lib/pages"
    click F_widgets "https://github.com/skyost/openauthenticator/tree/main/lib/widgets"
    click F_model "https://github.com/skyost/openauthenticator/tree/main/lib/model"
    click F_i18n "https://github.com/skyost/openauthenticator/tree/main/lib/i18n"
    click W_site "https://github.com/skyost/openauthenticator/tree/main/docs"
    click W_locales "https://github.com/skyost/openauthenticator/tree/main/docs/locales"
    click U_util "https://github.com/skyost/openauthenticator/tree/main/lib/utils"
    click U_bin "https://github.com/skyost/openauthenticator/tree/main/bin"
    click FirebaseAuth "https://github.com/skyost/openauthenticator/blob/main/lib/model/authentication/firebase_authentication.dart"
    click Payment "https://github.com/skyost/openauthenticator/tree/main/lib/model/purchases"

    %% Styling Classes
    classDef client fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef website fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
    classDef service fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef utility fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef user fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
