# 2005-atharva/perppdf_app architecture

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

- Interactive diagram: https://gitdiagram.com/2005-atharva/perppdf_app
- Repository: https://github.com/2005-atharva/perppdf_app

## Overview

##### Project Type and Purpose
- This is a cross-platform mobile (and web/desktop) application built using Flutter.
- Its primary feature set includes user registration/login, browsing of PDFs, theme toggling, push notifications, payment integration via Razorpay, and cloud-based storage of user data.
- Core functionalities are powered by Firebase services (Authentication, Firestore, Storage, Messaging, Analytics) and additional integrations like the Razorpay payment gateway.

##### File Structure
- The top-level directories (android, ios, macos, linux, windows, web) indicate that the app targets all major platforms.
- The “lib” directory holds the Flutter application’s core logic, separated into further subdirectories:
- "auth" (managing authentication pages and logic),
- "pages" (containing various UI pages including home, folder, profile, etc.),
- "services" (which is divided into functions, providers, and settings indicating the handling of business logic, Firebase notifications, data persistence, and theme management),
- "utils" and "widgets" (providing shared utilities and UI components).
- The presence of configuration files (pubspec.yaml, firebase_options.dart) and platform-specific build files further emphasize the clean separation between presentation and logic layers, along with integration readiness.

##### Components to be Represented
a. Frontend Client (Flutter App):
- UI Layer: Representing the pages (registration/login, home, PDF viewer, etc.) and widgets (global components like logout functionality, theme togglers, etc.).
- Navigation & State Management: Highlight the use of the provider package and page routing.
b. Firebase Backend Services:
- Firebase Authentication: For secure user login/registration.
- Cloud Firestore: For storing user data such as personal information and app settings.
- Firebase Storage: To host and serve PDF documents.
- Firebase Messaging (Push Notifications): To deliver notifications about new content or feature updates.
- Firebase Analytics: For tracking user interactions and app events.
c. Payment Gateway:
- Razorpay Integration: Illustrate the connection between the UI layer and the Razorpay APIs for handling in-app purchases.
d. External Assets & Utilities:
- Environment management with flutter_dotenv (for API keys and configurations).

##### Relationships and Interactions
- Authentication flow (user registration/login from UI to Firebase Auth).
- Data flow (UI retrieving and sending data to Cloud Firestore and Firebase Storage).
- Notification flow (Firebase Messaging pushing data to the client).
- Payment flow (UI initiating payment through Razorpay and receiving callbacks/updates).
- Communication between different service modules and emphasize the separation between presentation (UI components and pages) and business logic (services and providers).

##### Architectural Patterns and Design Principles
- The app is built with a modular structure that fits a Model-View-Controller (or MVVM) pattern:
- Model: Firebase services for data storage and user services.
- View: Individual pages and widgets in the “lib” directory.
- Controller/ViewModel: Service providers and functions handling business logic.
- State management via the provider package, which helps in managing application state across UI components.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Flutter Client (UI Layer)
    subgraph "Flutter Client (UI Layer)"
        Auth["Authentication Pages"]:::ui
        Pages["Pages"]:::ui
        Widgets["Widgets"]:::ui
    end

    %% State Management & Business Logic
    subgraph "State Management & Business Logic"
        Prov["Providers (State Management)"]:::state
        Theme["Theme Management"]:::state
        FNotifications["Firebase Notifications"]:::state
        DataStore["User Data Storage"]:::state
    end

    %% Firebase Services
    subgraph "Firebase Services"
        FA["Firebase Auth"]:::firebase
        FS["Cloud Firestore"]:::firebase
        FStorage["Firebase Storage"]:::firebase
        FM["Firebase Messaging"]:::firebase
        FAnalytics["Firebase Analytics"]:::firebase
        FConfig["Firebase Config"]:::firebase
    end

    %% Payment Gateway
    subgraph "Payment Gateway"
        Razor["Razorpay Payment Gateway"]:::payment
    end

    %% External Assets & Resources
    subgraph "External Assets"
        Assets["Assets (Icons/Images/PDFs)"]:::assets
    end

    %% Connections between UI Layer and Firebase Services
    Auth -->|"auth_flow"| FA
    Pages -->|"data_flow"| FS
    Pages -->|"pdf_access"| FStorage
    Pages -->|"payment_init"| Razor
    Pages -->|"notification_receiver"| FM

    %% Connections within UI and Business Logic
    Widgets -->|"state_updates"| Prov
    Prov -->|"sync_data"| FS
    Prov -->|"sync_assets"| FStorage
    Theme -->|"theme_update"| Pages

    %% Connections from Business Logic to Firebase Services
    DataStore -->|"store_user_data"| FS
    DataStore -->|"store_user_data"| FStorage
    FNotifications -->|"notify_user"| FM

    %% Connections from Firebase Config to Firebase Services
    FConfig --> FA
    FConfig --> FS
    FConfig --> FStorage
    FConfig --> FM
    FConfig --> FAnalytics

    %% Connections from External Assets to UI Layer
    Assets -->|"resource_usage"| Pages
    Assets -->|"resource_usage"| Widgets

    %% Click Events for Component Mapping
    click Pages "https://github.com/2005-atharva/perppdf_app/tree/main/lib/pages"
    click Widgets "https://github.com/2005-atharva/perppdf_app/tree/main/lib/widgets"
    click Auth "https://github.com/2005-atharva/perppdf_app/tree/main/lib/auth"
    click FConfig "https://github.com/2005-atharva/perppdf_app/blob/main/lib/firebase_options.dart"
    click FNotifications "https://github.com/2005-atharva/perppdf_app/blob/main/lib/services/functions/firebase_notification.dart"
    click DataStore "https://github.com/2005-atharva/perppdf_app/blob/main/lib/services/functions/user_data_store.dart"
    click Prov "https://github.com/2005-atharva/perppdf_app/tree/main/lib/services/providers"
    click Theme "https://github.com/2005-atharva/perppdf_app/tree/main/lib/services/settings"
    click Assets "https://github.com/2005-atharva/perppdf_app/tree/main/assets"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef state fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
    classDef firebase fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef payment fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef assets fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
```
