# foxriver-2005/caregiver-careseeker-connect architecture

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

- Interactive diagram: https://gitdiagram.com/foxriver-2005/caregiver-careseeker-connect
- Repository: https://github.com/foxriver-2005/caregiver-careseeker-connect

## Overview

##### Main Components
- User Interfaces (UI): Since this is an Android app, the UI is built using various Layouts, Activities, and Fragments. The file structure in the “app/src/main/res/layout” directory shows numerous screens – for login, caregiver and care seeker dashboards, chat, booking appointments, payment, etc.
- Modules by Role:
- Care Seeker: Includes screens and processes for OTP login, caregiver search, appointment booking, payment initiation, and subsequent chat functionality.
- Care Giver: Consists of UI for profile setup (including uploading credentials), setting time slots, viewing appointments, and chat interactions.
- Admin: Has its own set of screens for user registration, approval of appointments (i.e., marking payments as complete), viewing feedback, and overall management.
- Business Logic & Helpers: The “Helpers” package contains adapters and session management classes that handle data presentation and interaction logic.
- Data Models: The “Models” package defines the various data entities (for appointments, payments, chat messages, prescriptions, etc.).
- Payment Integration Module (MPesa): There is a dedicated package for MPesa, containing classes like STKPush, AuthInterceptor, and DarajaApiClient. This module manages the payment processes via MPesa.
- Chat and Communication: Classes across Admin and user roles suggest two-way messaging functionalities.
- External Assets: In “app/src/main/assets” you see several JSON files (for calendar, admin data, contact, etc.) which likely support configuration or test data for UI or feature setups.

##### Relationships and Interactions
- The UI components interact with the underlying data models and business logic via Activities and Fragments.
- Role-specific flows:
- Care Seeker login initiates through OTP verification, then moves to appointment booking, which involves selecting a Care Giver. This booking process then triggers the MPesa payment module.
- Once payment is processed and confirmed by the Admin (through the Admin module), the chat functionality becomes enabled.
- Care Giver and Admin modules interact by syncing appointments and feedback.
- The MPesa module encapsulates all external payment calls. Its classes (like STKPushService) may serve as intermediaries to the MPesa APIs.
- Data flow: User inputs (e.g., booking details, chat messages) are routed from UI layers to underlying adapters and models, then passed to specific service modules (such as the MPesa service for payment or a chat/message service for communication).

##### Architectural Patterns and Design Principles
- Modularization: The project is divided based on the roles (Admin, Care Giver, and Care Seeker) and functionality (e.g., MPesa integration, Helpers, Models) which aids in separation of concerns.
- MVC/MVP: Although Android projects often adopt the Model-View-Controller (or Model-View-Presenter) pattern, the presence of distinct Models, Views (layouts and activities), and controller/logic classes in Helpers indicates a similar separation.
- API Integration: The MPesa package demonstrates how external payment APIs are integrated.
- Use of Adapters: Multiple adapter classes in the Helpers folder indicate a pattern for seamlessly binding data and UI – especially for list-based elements like appointments and chat messages.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["User Interfaces (UI)"]:::presentation
        CS["Care Seeker Module"]:::presentation
        CG["Care Giver Module"]:::presentation
        AD["Admin Module"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        HL["Business Logic & Helpers"]:::business
    end

    %% Data Model Layer
    subgraph "Data Model Layer"
        DM["Data Models"]:::data
    end

    %% External Services Integration
    subgraph "External Services"
        MP["MPesa Payment Module"]:::external
        EA["External Assets/Configuration Files"]:::external
    end

    %% Connections from Presentation Layer to Business Logic
    UI -->|"routes_to"| CS
    UI -->|"routes_to"| CG
    UI -->|"routes_to"| AD

    CS -->|"OTP_Verification_&_Appointment_Booking"| HL
    CG -->|"ProfileSetup_&_Availability"| HL
    AD -->|"ManageRegistrations_Appointments"| HL

    %% Business Logic interactions
    HL -->|"Data_Operations"| DM
    HL -->|"Initiate_Payment"| MP
    MP -->|"Payment_Confirmation"| HL

    EA -->|"Config_Data"| HL
    EA -->|"Supports_UI"| UI

    HL -->|"Chat_Message_Delegate"| CS
    HL -->|"Chat_Message_Delegate"| CG
    HL -->|"Feedback_Sync"| AD
    HL -->|"Appointment_Sync"| CG
    HL -->|"Appointment_Sync"| AD

    %% Click Events
    click UI "https://github.com/foxriver-2005/caregiver-careseeker-connect/tree/main/app/src/main/res/layout"
    click CS "https://github.com/foxriver-2005/caregiver-careseeker-connect/tree/main/app/src/main/java/com/care/careme/CareSeeker"
    click CG "https://github.com/foxriver-2005/caregiver-careseeker-connect/tree/main/app/src/main/java/com/care/careme/CareGiver"
    click AD "https://github.com/foxriver-2005/caregiver-careseeker-connect/tree/main/app/src/main/java/com/care/careme/Admin"
    click HL "https://github.com/foxriver-2005/caregiver-careseeker-connect/tree/main/app/src/main/java/com/care/careme/Helpers"
    click DM "https://github.com/foxriver-2005/caregiver-careseeker-connect/tree/main/app/src/main/java/com/care/careme/Models"
    click MP "https://github.com/foxriver-2005/caregiver-careseeker-connect/tree/main/app/src/main/java/com/care/careme/Mpesa"
    click EA "https://github.com/foxriver-2005/caregiver-careseeker-connect/tree/main/app/src/main/assets"

    %% Styles
    classDef presentation fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef business fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef data fill:#ffe082,stroke:#ff6f00,stroke-width:2px;
    classDef external fill:#ffab91,stroke:#bf360c,stroke-width:2px;
```
