# mrtracker-new/contact-manager architecture

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

- Interactive diagram: https://gitdiagram.com/mrtracker-new/contact-manager
- Repository: https://github.com/mrtracker-new/contact-manager

## Overview

##### Main Components
- Frontend Web Application – Built with React and Material UI. This is represented by the files under the “src” directory, including pages (e.g., ContactList.js, Dashboard.js) and shared components (e.g., Header.js, ImportExport.js).
- Mobile Application – Uses Capacitor to wrap the web app and run natively on Android. The “android” directory contains all native Android code and configurations.
- Document and Contact Management Logic – Implemented as utility functions (e.g., vCardFormatter.js, contactImportExport.js) and integrated with storage mechanisms (Capacitor Preferences, LocalStorage).
- Routing & State Management – The application uses React Router for navigation (visible in the “src” directory) and React Context API for state management.
- Configuration & Integration Layer – Provided by capacitor.config.json and capacitor.config.ts, which govern cross-platform behaviors like file system access, camera & sharing integrations.

##### Component Relationships & Interactions
- The Frontend Web Application serves as the primary user interface accessible via browsers. It interacts with local storage (e.g., Capacitor Preferences, LocalStorage) for holding contact information locally (supporting offline functionality).
- The Mobile Application layer (wrapped by Capacitor) uses the same web codebase (from “src”) but builds an Android package (see “android” directory). This native layer interfaces with OS-specific features (camera, file handling, etc.) configured in capacitor.config.json.
- The document processing utilities, invoked by both frontends, handle tasks such as formatting vCard files and managing document attachments.
- The import/export functionalities (also seen in the components and utils directories) ensure data can be exchanged in standard formats (vCard).

##### Architectural Patterns & Design Principles
- Cross-Platform Reusability: The design emphasizes code reuse by sharing the React codebase across web and native apps via Capacitor.
- Component-Based UI: The React components follow a modular pattern ensuring separation of concerns (header, dashboard, contact details, etc.).
- Offline-First and Local Data Storage: The application is designed to maintain full functionality without constant internet access.
- Separation of Concerns: Clear split between presentation (React UI), business logic (utility functions for contact and document management), and mobile integration (native Android code wrapped by Capacitor).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    USER("User Interaction"):::user

    %% Web Frontend Layer
    subgraph "Web Frontend"
        ReactUI("React UI"):::frontend
        AppRouting("App.js (Routing)"):::frontend
        Context("index.js (Context)"):::frontend
    end

    %% Core Business Logic Layer
    CoreLogic("Contact & Document Utilities"):::core

    %% Local Storage & Document Management
    LocalStorage["Local Storage & Document Management"]:::storage

    %% Mobile Layer
    MobileApp("Mobile App (Capacitor + Android)"):::mobile

    %% Configuration & Integration Layer
    subgraph "Configuration & Integration"
        CapConfigJSON("capacitor.config.json"):::config
        CapConfigTS("capacitor.config.ts"):::config
    end

    %% Connections
    USER -->|"Interact"| ReactUI
    ReactUI -->|"Route"| AppRouting
    ReactUI -->|"Context"| Context
    ReactUI -->|"Invoke"| CoreLogic
    ReactUI -->|"Persist"| LocalStorage
    CoreLogic -->|"Update"| LocalStorage
    MobileApp -->|"Wraps"| ReactUI
    MobileApp -->|"Uses"| CapConfigJSON
    MobileApp -->|"Uses"| CapConfigTS

    %% Click Events
    click ReactUI "https://github.com/mrtracker-new/contact-manager/tree/master/src/"
    click AppRouting "https://github.com/mrtracker-new/contact-manager/blob/master/src/App.js"
    click Context "https://github.com/mrtracker-new/contact-manager/blob/master/src/index.js"
    click CoreLogic "https://github.com/mrtracker-new/contact-manager/tree/master/src/utils/"
    click MobileApp "https://github.com/mrtracker-new/contact-manager/tree/master/android/"
    click CapConfigJSON "https://github.com/mrtracker-new/contact-manager/blob/master/capacitor.config.json"
    click CapConfigTS "https://github.com/mrtracker-new/contact-manager/blob/master/capacitor.config.ts"

    %% Styles
    classDef frontend fill:#85C1E9,stroke:#21618C,stroke-width:2px,color:#ffffff;
    classDef mobile fill:#82E0AA,stroke:#27AE60,stroke-width:2px,color:#ffffff;
    classDef core fill:#F5B041,stroke:#D35400,stroke-width:2px,color:#ffffff;
    classDef config fill:#BB8FCE,stroke:#8E44AD,stroke-width:2px,color:#ffffff;
    classDef storage fill:#F9E79F,stroke:#F1C40F,stroke-width:2px,color:#000000;
    classDef user fill:#D7DBDD,stroke:#A6ACAF,stroke-width:2px,color:#000000;
```
