# sang-19/elderlycareremindersystem-carenest architecture

> Architecture diagram of the GitHub repository sang-19/elderlycareremindersystem-carenest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sang-19/elderlycareremindersystem-carenest
- Repository: https://github.com/sang-19/elderlycareremindersystem-carenest

## Overview

##### Project Type and Purpose
- This is a **mobile full-stack client** (Expo/React Native) focused on elderly care: user authentication, medicine & appointment reminders, relative management, notifications, and local data persistence.
- No server code is included, so we’ll model any backend or external services as “External API” or “Push Notification Service.”

##### File Structure
- **app/**: Expo Router-based navigation folders
- `(auth)` branch: login/register flows
- `(tabs)` branch: main tab screens (Appointments, Reminders, Connections, Profile)
- **components/**: reusable UI widgets (EmergencyButton, ReminderForm, ScrollableTabBar)
- **context/**: React Context APIs for global state (Auth, Alert, Reminder, Connection, Notification)
- **utils/**: business-logic helpers (notifications.ts)
- **hooks/**: custom hooks (useFrameworkReady)
- **assets/**: images and static resources
- **types/** & **expo-env.d.ts**: TypeScript definitions

##### README
- Frontend tech: Expo, React Native, TypeScript, React Navigation/Expo Router
- State mgmt: Context API + AsyncStorage
- Features list clarifies core domain objects: Users, Medications, Appointments, Relatives, Reminders

##### Main Components & Their Roles
A. Mobile App (front end)
- Navigation Layer (Expo Router)
- UI Layer (Screens under `app/(auth)` & `app/(tabs)`)
- Presentation Components (`components/…`)
B. State Management
- `AuthContext`: handles login, registration, token storage
- `ReminderContext`: manages medication/activity reminders
- `AppointmentContext` (implicitly in Reminders or build new)
- `ConnectionContext`: relatives/contacts CRUD
- `NotificationContext`: schedules & reacts to push/local notifications
C. Data Layer
- AsyncStorage (via Contexts) for persisting user/profile/reminder data locally
D. External Services
- **Expo Push Notification Service** (via `utils/notifications.ts`)
- **Backend API** (assumed): user auth, data sync (optional, model as external REST/GraphQL)
E. Device APIs
- Local Notifications, Storage, Platform-specific features

##### Relationships & Data Flows
- UI Screens ←→ Contexts: Screens dispatch actions (e.g., addReminder) to Context providers
- Contexts → AsyncStorage: read/write domain data
- Contexts → External API: sync data if online (login, fetch appointments)
- Contexts → Notification Service: schedule/cancel push or local notifications
- Notification Service → App: delivers push events into NotificationContext

##### Architectural Patterns & Principles
- **Component-Based UI**: small reusable components under `components/`
- **Context API for State**: isolates domain logic from presentation
- **Router-First Navigation**: file-system based routing in `app/`
- **Separation of Concerns**: UI, state, data/storage, external integration

##### Final Checklist
- [ ] UI components & screens clearly labeled
- [ ] AsyncStorage block showing persistence interactions
- [ ] Annotations of key frameworks (React Native, Expo, TypeScript, React Navigation)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI / Navigation Layer"
        direction TB
        Nav["Navigation Layer\n(Expo Router)"]:::ui
        click Nav "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/_layout.tsx"
        subgraph "Auth Flow Screens"
            direction TB
            AuthIndex["Auth Home\nindex.tsx"]:::ui
            click AuthIndex "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/(auth)/index.tsx"
            AuthLogin["Login Screen\nlogin.tsx"]:::ui
            click AuthLogin "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/(auth)/login.tsx"
            AuthRegister["Register Screen\nregister.tsx"]:::ui
            click AuthRegister "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/(auth)/register.tsx"
            AuthLayout["Auth Layout\n_layout.tsx"]:::ui
            click AuthLayout "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/(auth)/_layout.tsx"
        end
        subgraph "Main Tabs Screens"
            direction TB
            TabsHome["Tabs Home\nindex.tsx"]:::ui
            click TabsHome "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/(tabs)/index.tsx"
            TabsLayout["Tabs Layout\n_layout.tsx"]:::ui
            click TabsLayout "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/(tabs)/_layout.tsx"
            Appointments["Appointments Screen\nappointments.tsx"]:::ui
            click Appointments "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/(tabs)/appointments.tsx"
            Reminders["Reminders Screen\nreminders.tsx"]:::ui
            click Reminders "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/(tabs)/reminders.tsx"
            Connections["Connections Screen\nconnections.tsx"]:::ui
            click Connections "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/(tabs)/connections.tsx"
            Profile["Profile Screen\nprofile.tsx"]:::ui
            click Profile "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/(tabs)/profile.tsx"
        end
        NotFound["Not Found Screen\n+not-found.tsx"]:::ui
        click NotFound "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/app/+not-found.tsx"
    end

    %% Presentation Components
    subgraph "Presentation Components"
        direction TB
        EmergencyButton["EmergencyButton.tsx"]:::ui
        click EmergencyButton "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/components/EmergencyButton.tsx"
        ReminderForm["ReminderForm.tsx"]:::ui
        click ReminderForm "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/components/ReminderForm.tsx"
        ScrollableTabBar["ScrollableTabBar.tsx"]:::ui
        click ScrollableTabBar "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/components/ScrollableTabBar.tsx"
    end

    %% State Management Layer
    subgraph "Context Providers (State Management)"
        direction TB
        AuthCtx["AuthContext"]:::state
        click AuthCtx "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/context/AuthContext.tsx"
        ReminderCtx["ReminderContext"]:::state
        click ReminderCtx "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/context/ReminderContext.tsx"
        ConnectionCtx["ConnectionContext"]:::state
        click ConnectionCtx "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/context/ConnectionContext.tsx"
        NotificationCtx["NotificationContext"]:::state
        click NotificationCtx "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/context/NotificationContext.tsx"
        AlertCtx["AlertContext"]:::state
        click AlertCtx "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/context/AlertContext.tsx"
        FrameworkReady["useFrameworkReady"]:::state
        click FrameworkReady "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/hooks/useFrameworkReady.ts"
    end

    %% Data Layer
    AsyncStorage["AsyncStorage\n(Local Persistence)"]:::datastore

    %% Utilities
    NotificationsUtil["notifications.ts\n(Expo Push + Local)"]:::external
    click NotificationsUtil "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/utils/notifications.ts"

    %% External Services
    PushService["Expo Push Notification Service"]:::external
    BackendAPI["Care App API\n/auth, /reminders, /appointments, /connections"]:::external

    %% Assets & Types
    Assets["Static Assets\nassets/images"]:::datastore
    click Assets "https://github.com/sang-19/elderlycareremindersystem-carenest/tree/main/assets/images"
    TypesIndex["types/index.ts"]:::datastore
    click TypesIndex "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/types/index.ts"
    TypesEnv["types/env.d.ts"]:::datastore
    click TypesEnv "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/types/env.d.ts"
    ExpoEnv["expo-env.d.ts"]:::datastore
    click ExpoEnv "https://github.com/sang-19/elderlycareremindersystem-carenest/blob/main/expo-env.d.ts"

    %% Relationships
    Nav --> AuthLayout
    Nav --> TabsLayout

    %% UI to Context
    AuthIndex -->|login/register actions| AuthCtx
    AuthLogin -->|login actions| AuthCtx
    AuthRegister -->|register actions| AuthCtx

    AppscreensReminders(Reminders) -->|manage reminders| ReminderCtx
    Reminders --> ReminderCtx
    Appointments -->|view appointments| ReminderCtx
    Connections -->|manage connections| ConnectionCtx
    Profile -->|fetch profile| AuthCtx
    Profile -->|fetch relatives| ConnectionCtx

    %% Context to Data & External
    AuthCtx -->|persist token/data| AsyncStorage
    ReminderCtx -->|persist reminders| AsyncStorage
    ConnectionCtx -->|persist connections| AsyncStorage
    NotificationCtx -->|persist settings| AsyncStorage
    AlertCtx -->|persist alerts| AsyncStorage

    AuthCtx -->|sync data| BackendAPI
    ReminderCtx -->|sync reminders| BackendAPI
    ConnectionCtx -->|sync connections| BackendAPI
    NotificationCtx -->|register device| BackendAPI

    %% Notification flow
    NotificationCtx -->|use util| NotificationsUtil
    NotificationsUtil -->|send push| PushService
    PushService -->|receive push events| NotificationCtx

    %% Framework init
    FrameworkReady --> AuthCtx
    FrameworkReady --> ReminderCtx
    FrameworkReady --> ConnectionCtx
    FrameworkReady --> NotificationCtx
    FrameworkReady --> AlertCtx

    %% Component usage
    AuthLogin --> EmergencyButton
    Reminders --> ReminderForm
    TabsLayout --> ScrollableTabBar

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,stroke-width:2px
    classDef state fill:#DFF7D8,stroke:#2D8A24,stroke-width:2px
    classDef datastore fill:#FFE5B4,stroke:#D2691E,stroke-width:2px
    classDef external fill:#E3D4FC,stroke:#6A0DAD,stroke-width:2px
```
