# satyajit1910/mediclock architecture

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

- Interactive diagram: https://gitdiagram.com/satyajit1910/mediclock
- Repository: https://github.com/satyajit1910/mediclock

## Overview

##### Main Components
- User Interface (UI) Layer: Represent the various Activities (MainActivity, HomeActivity, DoctorActivity, DoctorAddActivity, labActivity, labAddActivity, DisplayMedicineActivity, RingActivity, TimeChangeActivity, UpdateActivity) and their corresponding layout XML files. They are the entry points for user interactions.
- Service and Alarm Handling Layer: Include components like MyAlarmService, AlarmManagerHandler, CommonAlarmRefreshService, AlarmRefreshService, and background services. These handle scheduling and notifications.
- Broadcast Receiver Layer: Show components such as CommonBroadCastReceiver and MyBroadcastReceiver which listen for system or alarm events.
- Data/Model Layer: Identify the model classes (DoctorDataModel, LabTestDataModel, TIME, etc.) handling the business data related to medicines, doctors, and labs.
- External and Integration Layers: Highlight the Google Services integration (indicated by google-services.json) which may handle notifications, analytics, or even synchronicity across devices.

##### Relationships and Interactions
- UI components (activities) interact with the service layer to trigger alarms and notifications when a reminder is due.
- The Service Layer communicates with the Broadcast Receivers to handle alarm-trigger events.
- Model/Data components provide and store the application’s data and are used by both UI components and services.
- External services (like Firebase or Play Store integrations) interact with the application, indicated by configuration files and external notifications.

##### Architectural Patterns and Design Principles
- The project naturally aligns with a layered (or even MVC/MVP) architecture segregation:
- The “View” is the UI layer (activities and layouts).
- The “Controller/Presenter” could be represented by the activities and other coordinating classes.
- The “Model” is composed of the data model classes.
- The “Service” layer for alarm management and background task handling.
- Separation of concerns: note how reminder logic, UI functions, and data management are separated into distinct packages.
- Design patterns like the use of Broadcast Receivers (Observer pattern) for handling asynchronous events.

##### Relevant Technologies, Frameworks, or Libraries
- Android SDK components (Activities, Services, Broadcast Receivers).
- Gradle for build automation.
- Google Services integration as indicated by the google-services.json.
- The Android resource system (layouts, drawable resources, fonts, etc.) that supports UI definitions.
- Firebase (potentially, based on configuration) or local database (SQLite) for data management if applicable.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        MA["MainActivity"]:::ui
        HA["HomeActivity"]:::ui
        DA["DoctorActivity"]:::ui
        DAA["DoctorAddActivity"]:::ui
        LA["labActivity"]:::ui
        LAA["labAddActivity"]:::ui
        DMA["DisplayMedicineActivity"]:::ui
        RA["RingActivity"]:::ui
        TCA["TimeChangeActivity"]:::ui
        UA["UpdateActivity"]:::ui
    end

    %% Service and Alarm Handling Layer
    subgraph "Service and Alarm Handling Layer"
        MAS["MyAlarmService"]:::service
        AMH["AlarmManagerHandler"]:::service
        ARS["AlarmRefreshService"]:::service
        CARS["CommonAlarmRefreshService"]:::service
    end

    %% Broadcast Receiver Layer
    subgraph "Broadcast Receiver Layer"
        CBR["CommonBroadCastReceiver"]:::broadcast
        MBR["MyBroadcastReceiver"]:::broadcast
    end

    %% Data/Model Layer
    subgraph "Data/Model Layer"
        DDM["DoctorDataModel"]:::model
        LTM["LabTestDataModel"]:::model
        TIME["TIME"]:::model
    end

    %% External and Integration Layer
    subgraph "External and Integration Layer"
        GSI["GoogleServices Integration"]:::external
    end

    %% Database Component
    subgraph "Database Component"
        DB["SQLite/Firebase Database"]:::database
    end

    %% Connections between UI components
    MA -->|"launches"| HA
    HA -->|"setReminder"| AMH
    HA -->|"configureTime"| TIME
    DA -->|"handles data"| DDM
    DAA -->|"updates data"| DDM
    LA -->|"handles data"| LTM
    LAA -->|"updates data"| LTM
    DMA -->|"displays reminder"| TIME
    TCA -->|"adjusts time"| TIME
    TCA -->|"updates"| UA

    %% Connections between Service Layer and UI/Data
    AMH -->|"schedules alarms"| ARS
    AMH -->|"schedules alarms"| CARS
    ARS -->|"triggers event"| MBR
    CARS -->|"triggers event"| CBR
    MBR -->|"notifies user"| RA

    %% Connections with External Integration
    MAS -->|"logs/updates"| GSI
    HA -->|"reports event"| GSI

    %% Connections with Data/Database
    DDM -->|"persists"| DB
    LTM -->|"persists"| DB
    TIME -->|"persists"| DB

    %% Click Events for UI Layer
    click MA "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/MainActivity.java"
    click HA "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/medicine/HomeActivity.java"
    click DA "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/doctor/DoctorActivity.java"
    click DAA "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/doctor/DoctorAddActivity.java"
    click LA "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/lab/labActivity.java"
    click LAA "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/lab/labAddActivity.java"
    click DMA "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/medicine/DisplayMedicineActivity.java"
    click RA "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/medicine/RingActivity.java"
    click TCA "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/medicine/TimeChangeActivity.java"
    click UA "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/medicine/UpdateActivity.java"

    %% Click Events for Service and Alarm Handling Layer
    click MAS "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/medicine/MyAlarmService.java"
    click AMH "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/medicine/AlarmManagerHandler.java"
    click ARS "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/medicine/AlarmRefreshService.java"
    click CARS "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/CommonAlarmRefreshService.java"

    %% Click Events for Broadcast Receiver Layer
    click CBR "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/CommonBroadCastReceiver.java"
    click MBR "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/medicine/MyBroadcastReceiver.java"

    %% Click Events for Data/Model Layer
    click DDM "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/doctor/DoctorDataModel.java"
    click LTM "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/lab/LabTestDataModel.java"
    click TIME "https://github.com/satyajit1910/mediclock/blob/main/app/src/main/java/com/satyajitghosh/mediclock/medicine/TIME.java"

    %% Click Event for External Integration
    click GSI "https://github.com/satyajit1910/mediclock/blob/main/app/google-services.json"

    %% Styles
    classDef ui fill:#ffe6e6,stroke:#cc0000,stroke-width:2px;
    classDef service fill:#e6f7ff,stroke:#0066cc,stroke-width:2px;
    classDef broadcast fill:#e6ffe6,stroke:#009900,stroke-width:2px;
    classDef model fill:#f9e6ff,stroke:#9933cc,stroke-width:2px;
    classDef external fill:#fff4cc,stroke:#cc9900,stroke-width:2px;
    classDef database fill:#e6ffff,stroke:#009999,stroke-width:2px;
```
