# maliffadlan/password-guard architecture

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

- Interactive diagram: https://gitdiagram.com/maliffadlan/password-guard
- Repository: https://github.com/maliffadlan/password-guard

## Overview

Based on our analysis of the file tree and README, PasswordKeeper is a modern, frontend-only React application that securely stores user passwords in a Google Sheet—all without a traditional backend. The key design goal is to ensure that the user interface (UI) clearly interacts with the various modules that handle Google Drive API communications and encryption behind the scenes.

##### Main components
- API Handler Module: The “src/APIHandler” folder encapsulates functionality for authentication (Auth.js), database interactions (Database.js), Google Drive communications (Drive.js) and encryption tasks (EncryptionHandler.js). This is the intermediary layer between the UI and external services.
- Context/Provider Components: Indicate the role of the context provided in “src/MainApp/provider”, which likely helps to distribute API and authentication state across the application.

##### Out component relationships and interactions
- User Actions: Show that users interact via the UI components in HomePage and MainApp.
- UI to API Handler: Illustrate how UI components (via events like login, add category, or view password details) invoke methods in the APIHandler, which in turn performs tasks like authentication, encryption/decryption, and communications with Google Drive/Sheets.
- Encryption: Emphasize that before data is stored, the EncryptionHandler encrypts passwords using the master key set during the first login.

##### Architectural patterns and design principles
- No Backend Architecture: Make clear that all operations happen on the client side using Google APIs, reducing the need for a separate server.
- Separation of Concerns: Note that component separation is enforced by dividing UI (React components and layout in MainApp/HomePage) versus utility/business logic in APIHandler.
- Context API Usage: Highlight how the ApiHandlerProvider and context modules inject services (such as API access) into the React component tree.
- Use of Modular Components: Recognize that the directory breakdown (AccountDialog, AppBar, DrawerContent, etc.) mirrors a component-based design where each piece is responsible for specific functionality.

## Diagram (Mermaid)

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

    %% Presentation Layer
    subgraph "Presentation Layer"
        UI_HomePage["HomePage (React)"]:::ui
        UI_MainApp["MainApp (React)"]:::ui
        UI_AppBar["AppBar"]:::ui
        UI_Drawer["DrawerContent"]:::ui
        UI_Account["AccountDialog"]:::ui
        UI_Category["CategoryItems"]:::ui
        UI_MasterKey["MasterKeyScreen"]:::ui
    end

    %% Service Layer
    subgraph "Service Layer"
        API_Auth["Auth Module"]:::service
        API_DB["Database Module"]:::service
        API_Drive["Drive Module"]:::service
        API_Encryption["Encryption Module"]:::service
        Provider_Context["ApiHandlerContext"]:::service
        Provider_Provider["ApiHandlerProvider"]:::service
    end

    %% External Integration
    subgraph "External Integration"
        External_API["Google Drive API Endpoints"]:::external
        External_Data["Google Drive/Sheets DataStore"]:::external
        External_Config["Environment Config"]:::external
    end

    %% User interactions with Presentation Layer
    User -->|"triggers"| UI_HomePage
    User -->|"triggers"| UI_MainApp

    %% UI Component relationships
    UI_MainApp -->|"includes"| UI_AppBar
    UI_MainApp -->|"includes"| UI_Drawer
    UI_MainApp -->|"includes"| UI_Account
    UI_MainApp -->|"includes"| UI_Category
    UI_MainApp -->|"includes"| UI_MasterKey

    %% Context injection into UI
    Provider_Provider -->|"injects API context"| UI_MainApp

    %% UI invoking Service Layer actions
    UI_MainApp -->|"login/auth"| API_Auth
    UI_MainApp -->|"encrypt/decrypt"| API_Encryption
    UI_MainApp -->|"data operations"| API_DB
    UI_MainApp -->|"data operations"| API_Drive

    %% Provider wiring to Service modules
    Provider_Provider -->|"provides"| API_Auth
    Provider_Provider -->|"provides"| API_DB
    Provider_Provider -->|"provides"| API_Drive
    Provider_Provider -->|"provides"| API_Encryption

    %% Service Layer calling External Integration
    API_Auth -->|"OAuth"| External_API
    API_Drive -->|"REST call"| External_API
    API_DB -->|"REST call"| External_API
    API_DB -->|"store/fetch"| External_Data
    API_Encryption -->|"prepares data"| UI_MainApp

    %% External configuration reference
    External_Config ---|"configures"| API_Auth

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef service fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef external fill:#FFCCCB,stroke:#333,stroke-width:2px;
    classDef user fill:#FFFF99,stroke:#333,stroke-width:2px;

    %% Click Events for Presentation Layer
    click UI_HomePage "https://github.com/maliffadlan/password-guard/blob/main/src/HomePage/HomePage.jsx"
    click UI_MainApp "https://github.com/maliffadlan/password-guard/blob/main/src/MainApp/index.jsx"
    click UI_AppBar "https://github.com/maliffadlan/password-guard/blob/main/src/MainApp/AppBar/index.jsx"
    click UI_Drawer "https://github.com/maliffadlan/password-guard/blob/main/src/MainApp/DrawerContent/index.jsx"
    click UI_Account "https://github.com/maliffadlan/password-guard/blob/main/src/MainApp/AccountDialog/index.jsx"
    click UI_Category "https://github.com/maliffadlan/password-guard/blob/main/src/MainApp/CategoryItems/index.jsx"
    click UI_MasterKey "https://github.com/maliffadlan/password-guard/blob/main/src/MainApp/MasterKeyScreen/index.jsx"

    %% Click Events for Service Layer
    click API_Auth "https://github.com/maliffadlan/password-guard/blob/main/src/APIHandler/Auth.js"
    click API_DB "https://github.com/maliffadlan/password-guard/blob/main/src/APIHandler/Database.js"
    click API_Drive "https://github.com/maliffadlan/password-guard/blob/main/src/APIHandler/Drive.js"
    click API_Encryption "https://github.com/maliffadlan/password-guard/blob/main/src/APIHandler/EncryptionHandler.js"
    click Provider_Context "https://github.com/maliffadlan/password-guard/blob/main/src/MainApp/provider/ApiHandlerContext.jsx"
    click Provider_Provider "https://github.com/maliffadlan/password-guard/blob/main/src/MainApp/provider/ApiHandlerProvider.jsx"

    %% Click Event for External Config
    click External_Config "https://github.com/maliffadlan/password-guard/blob/main/.env.sample"
```
