# openedx/frontend-app-authn architecture

> Architecture diagram of the GitHub repository openedx/frontend-app-authn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openedx/frontend-app-authn
- Repository: https://github.com/openedx/frontend-app-authn

## Overview

##### Project Type and Purpose
- This is a React-based micro-frontend (MFE) whose sole responsibility is user authentication flows: login, registration, forgot/reset password, and progressive profiling.
- It is embedded into a host container (e.g., Tutor or Open edX LMS) via a micro-frontend loader.

##### File Structure
- **Public & Bootstrapping**
- public/index.html → React mount point
- src/index.jsx + MainApp.jsx → root component and router setup
- **Container & Layout**
- src/base-container → layout wrapper, image/text/video layouts
- **Feature Modules**
- src/login, src/register, src/forgot-password, src/reset-password, src/progressive-profiling → each has UI components, messages, and a data layer (actions/reducers/sagas/service)
- **Shared Components**
- src/common-components → reusable UI (FormGroup, PasswordField, SSO, Zendesk, routes, etc.)
- src/field-renderer → dynamic field rendering for configurable fields
- **State Management**
- src/data/configureStore.js → Redux store
- src/data/reducers.js + src/data/sagas.js → root reducer and saga composition
- **Utilities & Integrations**
- src/data/utils, algolia.js, optimizely.js, oneTrust.js → feature flags, analytics, cookie management
- **Build & Config**
- webpack.prod.config.js, .env*, package.json, catalog-info.yaml → build, environment variable injection, CI/CD

##### Relationships & Data Flows
- **User → UI Components**: user triggers an action (e.g., click “Login”)
- **UI → Redux Action**
- **Redux Saga → Service Layer**: invoke REST API
- **Service Layer → External API**: e.g., POST /login
- **API Response → Saga → Reducer → UI Update**
- **Config Flow**: on startup Saga fetches MFE_CONFIG_API_URL → populates feature flags & dynamic fields

##### Architectural Patterns & Technologies
- **Micro-frontend** (isolated deployable UI unit)
- **Feature-based code organization** (each route has its own slice)
- **Container/Presentational** layout in base-container
- **Redux + Redux-Saga** for state and side-effect management
- **Webpack** (potentially Module Federation for MFE)
- **Jest** for unit & snapshot tests
- **SCSS** for styling layouts

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Host Container"
        HC["MFE Loader"]:::external
    end

    subgraph "Micro-frontend Shell"
        HTML["index.html"]:::ui
        IDX["src/index.jsx"]:::ui
        MAIN["src/MainApp.jsx"]:::ui
    end

    HC --> HTML
    HTML --> IDX
    IDX --> MAIN

    subgraph "UI Layer"
        LC["Layout Container"]:::ui
        subgraph "Features"
            LOGIN["Login Module"]:::ui
            REGISTER["Registration Module"]:::ui
            FORGOT["Forgot Password Module"]:::ui
            RESET["Reset Password Module"]:::ui
            PROFILE["Progressive Profiling Module"]:::ui
        end
        SHARED["Shared Components"]:::ui
        FIELDR["Field Renderer"]:::ui
    end

    MAIN --> LC
    LC --> LOGIN
    LC --> REGISTER
    LC --> FORGOT
    LC --> RESET
    LC --> PROFILE
    LC --> SHARED
    LC --> FIELDR

    subgraph "State Management"
        STORE["Configure Store"]:::state
        REDUCERS["Root Reducers"]:::state
        SAGAS["Root Sagas"]:::state
    end

    LOGIN --> STORE
    REGISTER --> STORE
    FORGOT --> STORE
    RESET --> STORE
    PROFILE --> STORE
    SHARED --> STORE
    FIELDR --> STORE

    STORE --> REDUCERS
    STORE --> SAGAS

    subgraph "Service Layer"
        AUTH_CLIENT["Auth API Client"]:::service
        CONFIG_CLIENT["MFE Config Client"]:::service
        ALGOLIA["Algolia Integration"]:::service
        OPTIMIZELY["Optimizely Integration"]:::service
        ONETRUST["OneTrust Integration"]:::service
        GLOBALCONFIG["Global Config Loader"]:::service
    end

    SAGAS --> AUTH_CLIENT
    SAGAS --> CONFIG_CLIENT
    SAGAS --> ALGOLIA
    SAGAS --> OPTIMIZELY
    SAGAS --> ONETRUST

    MAIN --> GLOBALCONFIG
    GLOBALCONFIG --> STORE

    subgraph "External Services"
        AUTH_API["Authentication API"]:::external
        CONFIG_API["MFE Config API"]:::external
        SOCIAL["Social Auth Providers"]:::external
        ALG_API["Algolia Search"]:::external
        ONE_API["OneTrust/Optimizely/Zendesk"]:::external
    end

    AUTH_CLIENT --> AUTH_API
    CONFIG_CLIENT --> CONFIG_API
    AUTH_CLIENT --> SOCIAL
    ALGOLIA --> ALG_API
    OPTIMIZELY --> ONE_API
    ONETRUST --> ONE_API

    %% Click Events
    click HTML "https://github.com/openedx/frontend-app-authn/blob/master/public/index.html"
    click IDX "https://github.com/openedx/frontend-app-authn/blob/master/src/index.jsx"
    click MAIN "https://github.com/openedx/frontend-app-authn/blob/master/src/MainApp.jsx"
    click LC "https://github.com/openedx/frontend-app-authn/tree/master/src/base-container/"
    click LOGIN "https://github.com/openedx/frontend-app-authn/tree/master/src/login/"
    click REGISTER "https://github.com/openedx/frontend-app-authn/tree/master/src/register/"
    click FORGOT "https://github.com/openedx/frontend-app-authn/tree/master/src/forgot-password/"
    click RESET "https://github.com/openedx/frontend-app-authn/tree/master/src/reset-password/"
    click PROFILE "https://github.com/openedx/frontend-app-authn/tree/master/src/progressive-profiling/"
    click SHARED "https://github.com/openedx/frontend-app-authn/tree/master/src/common-components/"
    click FIELDR "https://github.com/openedx/frontend-app-authn/tree/master/src/field-renderer/"
    click STORE "https://github.com/openedx/frontend-app-authn/blob/master/src/data/configureStore.js"
    click REDUCERS "https://github.com/openedx/frontend-app-authn/blob/master/src/data/reducers.js"
    click SAGAS "https://github.com/openedx/frontend-app-authn/blob/master/src/data/sagas.js"
    click ALGOLIA "https://github.com/openedx/frontend-app-authn/blob/master/src/data/algolia.js"
    click OPTIMIZELY "https://github.com/openedx/frontend-app-authn/blob/master/src/data/optimizely.js"
    click ONETRUST "https://github.com/openedx/frontend-app-authn/blob/master/src/data/oneTrust.js"
    click GLOBALCONFIG "https://github.com/openedx/frontend-app-authn/blob/master/src/config/index.js"

    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef state fill:#90EE90,stroke:#000,stroke-width:1px
    classDef service fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#DDA0DD,stroke:#000,stroke-width:1px
```
