# shield-intelligence/shield-authenticator architecture

> Architecture diagram of the GitHub repository shield-intelligence/shield-authenticator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shield-intelligence/shield-authenticator
- Repository: https://github.com/shield-intelligence/shield-authenticator

## Overview

#### Purpose and entry points
SHIELD-Authenticator is a React-based TOTP authenticator with a client-side encrypted account vault, Firebase-backed identity/sync, offline behavior, and a Capacitor Android shell. Browser startup flows through `src/index.js` into `src/App.js`; native Android starts at `android/app/src/main/java/com/shieldintelligence/authenticator/MainActivity.java`.

#### Application composition and routing
`App.js` is the application orchestrator, combining lifecycle/security hooks, handler modules, and routes. `src/pages/AppRoutes.js` separates public authentication/legal pages from the authenticated vault experience. Primary user surfaces are the dashboard and settings:
- `src/App.js`
- `src/pages/AppRoutes.js`
- `src/pages/Dashboard.js`
- `src/pages/SettingsPage.js`

#### Identity, vault lifecycle, and recovery
Firebase authentication establishes the user identity; vault access is a separate passphrase-controlled lifecycle. The lifecycle hook and handlers coordinate setup, unlock, recovery, passphrase changes, and teardown. Recovery questions support resetting vault access, but encrypted data remains dependent on vault cryptographic material.
- `src/hooks/useAuthVaultLifecycle.js`
- `src/modules/appHandlers/authHandlers.js`
- `src/modules/appHandlers/vaultHandlers.js`
- `src/Utils/recoveryQuestions.js`

#### Encryption and local persistence boundary
2FA secrets are encrypted/decrypted on the client before cloud persistence. Vault cryptography uses Argon2id-derived passphrase keys; local state and secure storage retain device-side vault/session readiness needed for offline behavior. Firebase/Firestore is a ciphertext store rather than a trusted plaintext vault.
- `src/Utils/vaultCrypto.js`
- `src/Utils/vault.js`
- `src/Utils/vaultLocalState.js`
- `src/Utils/secureStorage.js`

#### Account and TOTP workflow
Authenticated, unlocked users manage account records through dashboard forms/list items. Account handlers mediate create/edit/delete and persistence; the ticker hook continuously derives and refreshes display codes. Filtering, provider presentation, and CSV import/export operate around this decrypted in-app account model.
- `src/modules/appHandlers/accountHandlers.js`
- `src/components/AddAccountForm.js`
- `src/components/AccountList.js`
- `src/hooks/useCodesTicker.js`
- `src/Utils/csvUtils.js`

#### Cloud sync and connectivity
Firebase initialization and service access are centralized in utilities, configured through public `REACT_APP_FIREBASE_*` build-time values. Connectivity/security state distinguishes online use, offline-ready devices after successful sync, and fresh offline installs without cached vault data.
- `src/Utils/firebase.js`
- `src/Utils/services.js`
- `src/hooks/useSecurityAndConnectivity.js`
- `src/Utils/networkUtils.js`

#### Native and deployment boundary
The frontend is a static React/PWA build, deployable to static hosting; `_redirects` and `_headers` indicate host-level SPA/routing and response policy support. Capacitor packages the same web app for Android and exposes native root-detection and screen-security plugins to JavaScript.
- `capacitor.config.ts`
- `android/app/src/main/java/com/shieldintelligence/authenticator/RootDetectionPlugin.java`
- `android/app/src/main/java/com/shieldintelligence/authenticator/ScreenSecurityPlugin.java`
- `public/_redirects`

Main entry points: [`src/App.js`](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/App.js) (Application orchestrator), [`src/pages/AppRoutes.js`](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/pages/AppRoutes.js) (Application routes), [`src/pages/Dashboard.js`](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/pages/Dashboard.js) (Dashboard), [`src/modules/appHandlers/accountHandlers.js`](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/modules/appHandlers/accountHandlers.js) (Account handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["React application"]
  node_index(("Browser entry<br/>React bootstrap<br/>[index.js]"))
  node_app["Application orchestrator<br/>React app<br/>[App.js]"]
  node_routes["Application routes<br/>route boundary<br/>[AppRoutes.js]"]
  node_dashboard["Dashboard<br/>authenticated page<br/>[Dashboard.js]"]
  node_settings["Settings<br/>authenticated page<br/>[SettingsPage.js]"]
  node_accounts["Account handlers<br/>handler module<br/>[accountHandlers.js]"]
  node_account_ui["Account management UI<br/>React components<br/>[AddAccountForm.js]"]
  node_ticker["TOTP code ticker<br/>React hook<br/>[useCodesTicker.js]"]
  node_csv["CSV import/export<br/>data utility<br/>[csvUtils.js]"]
end

subgraph group_vault["Vault security"]
  node_auth_lifecycle["Auth-vault lifecycle<br/>React hook"]
  node_auth_handlers["Authentication handlers<br/>handler module<br/>[authHandlers.js]"]
  node_vault_handlers["Vault handlers<br/>handler module<br/>[vaultHandlers.js]"]
  node_recovery["Recovery questions<br/>recovery utility"]
  node_vault_crypto{{"Vault cryptography<br/>crypto utility<br/>[vaultCrypto.js]"}}
  node_vault_state[("Local vault state<br/>local persistence<br/>[vaultLocalState.js]")]
  node_secure_storage[("Secure storage<br/>device storage<br/>[secureStorage.js]")]
end

subgraph group_cloud["Sync and platform"]
  node_firebase_services["Firebase services<br/>cloud integration<br/>[firebase.js]"]
  node_firestore[("Firestore ciphertext store<br/>cloud database")]
  node_connectivity["Security and connectivity<br/>React hook"]
  node_android["Android Capacitor shell<br/>native runtime<br/>[MainActivity.java]"]
  node_native_security{{"Native security plugins<br/>Capacitor plugins"}}
end

node_index -->|"mounts"| node_app
node_app -->|"renders"| node_routes
node_routes -->|"authenticated route"| node_dashboard
node_routes -->|"authenticated route"| node_settings
node_app -->|"uses"| node_auth_lifecycle
node_app -->|"uses"| node_auth_handlers
node_app -->|"uses"| node_vault_handlers
node_auth_lifecycle -->|"establishes identity"| node_firebase_services
node_auth_lifecycle -->|"restores readiness"| node_vault_state
node_vault_handlers -->|"unlocks and rekeys"| node_vault_crypto
node_vault_handlers -->|"supports recovery"| node_recovery
node_vault_state -->|"persists device state"| node_secure_storage
node_dashboard -->|"hosts"| node_account_ui
node_account_ui -->|"manages records"| node_accounts
node_accounts -->|"encrypts/decrypts secrets"| node_vault_crypto
node_accounts -->|"syncs ciphertext"| node_firestore
node_dashboard -->|"displays codes"| node_ticker
node_account_ui -->|"imports/exports"| node_csv
node_firebase_services -->|"accesses"| node_firestore
node_connectivity -->|"evaluates sync availability"| node_firebase_services
node_connectivity -->|"checks offline readiness"| node_vault_state
node_android -->|"hosts web app"| node_app
node_android -->|"registers"| node_native_security

click node_index "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/index.js"
click node_app "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/App.js"
click node_routes "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/pages/AppRoutes.js"
click node_dashboard "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/pages/Dashboard.js"
click node_settings "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/pages/SettingsPage.js"
click node_auth_lifecycle "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/hooks/useAuthVaultLifecycle.js"
click node_auth_handlers "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/modules/appHandlers/authHandlers.js"
click node_vault_handlers "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/modules/appHandlers/vaultHandlers.js"
click node_recovery "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/recoveryQuestions.js"
click node_vault_crypto "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/vaultCrypto.js"
click node_vault_state "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/vaultLocalState.js"
click node_secure_storage "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/secureStorage.js"
click node_accounts "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/modules/appHandlers/accountHandlers.js"
click node_account_ui "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/components/AddAccountForm.js"
click node_ticker "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/hooks/useCodesTicker.js"
click node_csv "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/csvUtils.js"
click node_firebase_services "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/firebase.js"
click node_connectivity "https://github.com/shield-intelligence/shield-authenticator/blob/main/src/hooks/useSecurityAndConnectivity.js"
click node_android "https://github.com/shield-intelligence/shield-authenticator/blob/main/android/app/src/main/java/com/shieldintelligence/authenticator/MainActivity.java"
click node_native_security "https://github.com/shield-intelligence/shield-authenticator/blob/main/android/app/src/main/java/com/shieldintelligence/authenticator/RootDetectionPlugin.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_index,node_app,node_routes,node_dashboard,node_settings,node_accounts,node_account_ui,node_ticker,node_csv toneBlue
class node_auth_lifecycle,node_auth_handlers,node_vault_handlers,node_recovery,node_vault_crypto,node_vault_state,node_secure_storage toneAmber
class node_firebase_services,node_firestore,node_connectivity,node_android,node_native_security toneMint
```

## Components

### React application

- [Browser entry](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/index.js): React bootstrap · `src/index.js`
- [Application orchestrator](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/App.js): React app · Combines lifecycle hooks, handlers, and routes. · `src/App.js`
- [Application routes](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/pages/AppRoutes.js): route boundary · Separates public pages from the authenticated vault. · `src/pages/AppRoutes.js`
- [Dashboard](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/pages/Dashboard.js): authenticated page · `src/pages/Dashboard.js`
- [Settings](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/pages/SettingsPage.js): authenticated page · `src/pages/SettingsPage.js`
- [Account handlers](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/modules/appHandlers/accountHandlers.js): handler module · Mediates account create, edit, delete, and persistence. · `src/modules/appHandlers/accountHandlers.js`
- [Account management UI](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/components/AddAccountForm.js): React components · Forms and list for decrypted in-app account records. · `src/components/AddAccountForm.js`
- [TOTP code ticker](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/hooks/useCodesTicker.js): React hook · Continuously derives and refreshes display codes. · `src/hooks/useCodesTicker.js`
- [CSV import/export](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/csvUtils.js): data utility · `src/Utils/csvUtils.js`

### Vault security

Passphrase-gated encrypted account lifecycle.

- [Auth-vault lifecycle](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/hooks/useAuthVaultLifecycle.js): React hook · Coordinates identity, vault readiness, recovery, and teardown. · `src/hooks/useAuthVaultLifecycle.js`
- [Authentication handlers](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/modules/appHandlers/authHandlers.js): handler module · `src/modules/appHandlers/authHandlers.js`
- [Vault handlers](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/modules/appHandlers/vaultHandlers.js): handler module · `src/modules/appHandlers/vaultHandlers.js`
- [Recovery questions](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/recoveryQuestions.js): recovery utility · `src/Utils/recoveryQuestions.js`
- [Vault cryptography](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/vaultCrypto.js): crypto utility · Derives Argon2id passphrase keys and encrypts account secrets. · `src/Utils/vaultCrypto.js`
- [Local vault state](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/vaultLocalState.js): local persistence · Retains device vault and session readiness for offline use. · `src/Utils/vaultLocalState.js`
- [Secure storage](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/secureStorage.js): device storage · `src/Utils/secureStorage.js`

### Sync and platform

- [Firebase services](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/Utils/firebase.js): cloud integration · Centralized Firebase initialization and service access. · `src/Utils/firebase.js`
- **Firestore ciphertext store**: cloud database · Stores encrypted vault data, not plaintext secrets.
- [Security and connectivity](https://github.com/shield-intelligence/shield-authenticator/blob/main/src/hooks/useSecurityAndConnectivity.js): React hook · Distinguishes online, offline-ready, and fresh offline states. · `src/hooks/useSecurityAndConnectivity.js`
- [Android Capacitor shell](https://github.com/shield-intelligence/shield-authenticator/blob/main/android/app/src/main/java/com/shieldintelligence/authenticator/MainActivity.java): native runtime · Hosts the same web application and native security plugins. · `android/app/src/main/java/com/shieldintelligence/authenticator/MainActivity.java`
- [Native security plugins](https://github.com/shield-intelligence/shield-authenticator/blob/main/android/app/src/main/java/com/shieldintelligence/authenticator/RootDetectionPlugin.java): Capacitor plugins · Provides root detection and screen-security controls. · `android/app/src/main/java/com/shieldintelligence/authenticator/RootDetectionPlugin.java`

## Connections

- Browser entry → Application orchestrator: mounts
- Application orchestrator → Application routes: renders
- Application routes → Dashboard: authenticated route
- Application routes → Settings: authenticated route
- Application orchestrator → Auth-vault lifecycle: uses
- Application orchestrator → Authentication handlers: uses
- Application orchestrator → Vault handlers: uses
- Auth-vault lifecycle → Firebase services: establishes identity
- Auth-vault lifecycle → Local vault state: restores readiness
- Vault handlers → Vault cryptography: unlocks and rekeys
- Vault handlers → Recovery questions: supports recovery
- Local vault state → Secure storage: persists device state
- Dashboard → Account management UI: hosts
- Account management UI → Account handlers: manages records
- Account handlers → Vault cryptography: encrypts/decrypts secrets
- Account handlers → Firestore ciphertext store: syncs ciphertext
- Dashboard → TOTP code ticker: displays codes
- Account management UI → CSV import/export: imports/exports
- Firebase services → Firestore ciphertext store: accesses
- Security and connectivity → Firebase services: evaluates sync availability
- Security and connectivity → Local vault state: checks offline readiness
- Android Capacitor shell → Application orchestrator: hosts web app
- Android Capacitor shell → Native security plugins: registers
