# asguizar/maintenanceapp architecture

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

- Interactive diagram: https://gitdiagram.com/asguizar/maintenanceapp
- Repository: https://github.com/asguizar/maintenanceapp

## Overview

##### Project type and purpose
- From the README and file tree, this is a hybrid mobile application (Ionic Framework + Angular) wrapped via Capacitor.
- Purpose: a fully offline maintenance-tracking app for home, vehicles, health, pets, with reminders, reports, and local backups.

##### File structure
- Root: config files for Ionic (`ionic.config.json`), Angular (`angular.json`, `tsconfig.json`), Capacitor (`capacitor.config.ts`), plus package manifests.
- android/: the native Android project generated by Capacitor (Gradle scripts, Java entry point, resources, tests).
- src/app/: the Angular/Ionic frontend code, organized into:
- core/guards & services (authentication, maintenance logic, notifications)
- features/ (login, home, maintenance form, report, settings)
- home/ (Ionic page module)
- src/assets, src/environments, src/theme: static assets, environment configs, SCSS variables.
- Plugins and tooling: @capacitor/local-notifications, @capacitor/filesystem, RxJS, Ionicons.

##### Key architectural patterns
- Angular’s module-component-service structure (MVVM-ish):
- Components handle presentation & user events
- Services encapsulate business logic & data persistence
- Dependency injection for services (AuthService, MaintenanceService, NotificationService).
- Capacitor as a bridge between web code (WebView) and native mobile APIs (notifications, filesystem).
- LocalStorage for data persistence + Capacitor Filesystem for backup.

##### Main components and interactions
a. Presentation Layer (Ionic/Angular)
- Feature modules & components (Login, Home Page, Maintenance, Report, Settings)
- Routing (app-routing.module.ts)
b. Business Logic Layer (Angular services)
- AuthService: handles local auth checks
- MaintenanceService: CRUD tasks in localStorage
- NotificationService: schedules local notifications via Capacitor
c. Persistence Layer
- localStorage (primary data store)
- Capacitor Filesystem (backup / export)
d. Native Layer (Capacitor + Android/iOS)
- WebView host (Ionic run)
- Capacitor bridge/plugins for Notifications & Filesystem
- Android native project (Gradle, MainActivity.java, resources)
e. External & Tools

- UI Component → Service → localStorage / Filesystem
- NotificationService → Capacitor LocalNotifications Plugin → Native OS Scheduler
- Capacitor Bridge ←→ Android/iOS runtime

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% WebView Layer
    subgraph "WebView (Ionic/Angular)"
        direction TB
        %% Presentation Layer
        subgraph "Presentation Layer"
            direction TB
            AppComponent["AppComponent"]:::web
            AppModule["AppModule"]:::web
            AppRoutingModule["AppRoutingModule"]:::web
            HomeModule["HomeModule"]:::web
            HomePage["HomePage"]:::web
            LoginComponent["LoginComponent"]:::web
            MaintenanceComponent["MaintenanceComponent"]:::web
            ReportComponent["ReportComponent"]:::web
            SettingsComponent["SettingsComponent"]:::web
            AuthGuard["AuthGuard"]:::service
        end

        %% Business Logic Layer
        subgraph "Business Logic Layer"
            direction TB
            AuthService["AuthService"]:::service
            MaintenanceService["MaintenanceService"]:::service
            NotificationService["NotificationService"]:::service
        end

        %% Persistence Layer
        subgraph "Persistence Layer"
            direction TB
            LocalStorage["localStorage"]:::persistence
            Environment["Environment Configs"]:::persistence
        end
    end

    %% Capacitor Bridge & Plugins
    subgraph "Capacitor Bridge & Plugins"
        direction TB
        CapacitorBridge["Capacitor Bridge"]:::plugin
        LocalNotificationsPlugin["LocalNotifications Plugin"]:::plugin
        FilesystemPlugin["Filesystem Plugin"]:::plugin
    end

    %% Native Layer
    subgraph "Native (Android/iOS)"
        direction TB
        AndroidProject["Android Project"]:::native
    end

    %% Connections: Presentation → Business Logic
    LoginComponent -->|calls| AuthService
    MaintenanceComponent -->|uses| MaintenanceService
    MaintenanceComponent -->|schedules| NotificationService
    ReportComponent -->|fetches| MaintenanceService
    SettingsComponent -->|triggers backup| MaintenanceService
    AuthGuard -->|validates| AuthService

    %% Business Logic → Persistence
    AuthService -->|reads/writes| LocalStorage
    MaintenanceService -->|CRUD| LocalStorage
    NotificationService -->|schedules| LocalStorage

    %% Business Logic → Plugins
    NotificationService -->|invoke| LocalNotificationsPlugin
    MaintenanceService -->|invoke| FilesystemPlugin

    %% Plugins ↔ Bridge ↔ Native
    LocalNotificationsPlugin ---|via Bridge| CapacitorBridge
    FilesystemPlugin ---|via Bridge| CapacitorBridge
    CapacitorBridge <--> AndroidProject

    %% Plugins dependencies
    CapacitorBridge -->|registers| LocalNotificationsPlugin
    CapacitorBridge -->|registers| FilesystemPlugin

    %% Styles
    classDef web fill:#D0E8FF,stroke:#0366d6,color:#000
    classDef service fill:#E8F1D0,stroke:#7AAE3D,color:#000
    classDef persistence fill:#FFF4D0,stroke:#D6A900,color:#000
    classDef plugin fill:#F0D0FF,stroke:#9B3CBC,color:#000
    classDef native fill:#FFD0D0,stroke:#D14545,color:#000

    %% Click Events
    click AppRoutingModule "https://github.com/asguizar/maintenanceapp/blob/master/src/app/app-routing.module.ts"
    click AppModule "https://github.com/asguizar/maintenanceapp/blob/master/src/app/app.module.ts"
    click AppComponent "https://github.com/asguizar/maintenanceapp/blob/master/src/app/app.component.ts"
    click AppComponent "https://github.com/asguizar/maintenanceapp/blob/master/src/app/app.component.html"
    click HomeModule "https://github.com/asguizar/maintenanceapp/blob/master/src/app/home/home.module.ts"
    click HomePage "https://github.com/asguizar/maintenanceapp/blob/master/src/app/home/home.page.ts"
    click HomePage "https://github.com/asguizar/maintenanceapp/blob/master/src/app/home/home.page.html"
    click HomePage "https://github.com/asguizar/maintenanceapp/blob/master/src/app/home/home-routing.module.ts"
    click LoginComponent "https://github.com/asguizar/maintenanceapp/blob/master/src/app/features/login/login.component.ts"
    click LoginComponent "https://github.com/asguizar/maintenanceapp/blob/master/src/app/features/login/login.component.html"
    click MaintenanceComponent "https://github.com/asguizar/maintenanceapp/blob/master/src/app/features/maintenance/maintenance.component.ts"
    click MaintenanceComponent "https://github.com/asguizar/maintenanceapp/blob/master/src/app/features/maintenance/maintenance.component.html"
    click ReportComponent "https://github.com/asguizar/maintenanceapp/blob/master/src/app/features/report/report.component.ts"
    click ReportComponent "https://github.com/asguizar/maintenanceapp/blob/master/src/app/features/report/report.component.html"
    click SettingsComponent "https://github.com/asguizar/maintenanceapp/blob/master/src/app/features/settings/settings.component.ts"
    click SettingsComponent "https://github.com/asguizar/maintenanceapp/blob/master/src/app/features/settings/settings.component.html"
    click AuthService "https://github.com/asguizar/maintenanceapp/blob/master/src/app/core/services/auth.service.ts"
    click MaintenanceService "https://github.com/asguizar/maintenanceapp/blob/master/src/app/core/services/maintenance.service.ts"
    click NotificationService "https://github.com/asguizar/maintenanceapp/blob/master/src/app/core/services/notification.service.ts"
    click AuthGuard "https://github.com/asguizar/maintenanceapp/blob/master/src/app/core/guards/auth.guard.ts"
    click Environment "https://github.com/asguizar/maintenanceapp/blob/master/src/environments/environment.ts"
    click Environment "https://github.com/asguizar/maintenanceapp/blob/master/src/environments/environment.prod.ts"
    click capacitor.config "https://github.com/asguizar/maintenanceapp/blob/master/capacitor.config.ts"
    click AndroidProject "https://github.com/asguizar/maintenanceapp/blob/master/android/app/src/main/java/com/example/maintenance/MainActivity.java"
    click AndroidProject "https://github.com/asguizar/maintenanceapp/blob/master/android/app/src/main/AndroidManifest.xml"
    click AndroidProject "https://github.com/asguizar/maintenanceapp/blob/master/android/app/src/main/res/xml/file_paths.xml"
    click AndroidProject "https://github.com/asguizar/maintenanceapp/blob/master/android/app/build.gradle"
    click AndroidProject "https://github.com/asguizar/maintenanceapp/blob/master/android/gradle.properties"
```
