# riteshdev99/medimate architecture

> Architecture diagram of the GitHub repository riteshdev99/medimate, 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/riteshdev99/medimate
- Repository: https://github.com/riteshdev99/medimate

## Overview

##### Project type and purpose
- This is a React Native–based mobile application (“MediMate”) for iOS and Android.
- Purpose: allow users to scan medicine labels, consult an AI doctor, locate hospitals, manage emergency contacts, read health news, and book doctor appointments.
- All business logic lives in the mobile client; it integrates with external services (Gemini API, Google Maps, News API, etc.).

##### File structure
- Top‐level mobile folders:
– android/ / ios/ — native project files and Gradle/Xcode configuration
– src/ — all React Native code:
· components/ — reusable UI pieces (navBar, newsCard, serviceCard, topBar)
· layout/ — “screens” or feature bundles (scanner, doctorConsult, homeLayout, hospitalLayout, userProfile, setting)
· Utils/ — cameraUtils.ts, prompt generators for AI doctor or scanner
· dto/ — data‐transfer object definitions for appointments, news, services
· mockData/ — static data for local testing
– index.js & App.tsx — entry point and root component
- Config files: babel.config.js, metro.config.js, tsconfig.json, package.json
- Native‐module integrations: react-native-image-crop-picker, Geolocation API, Google Maps API
- No custom backend code—app forwards requests to third‐party REST/GraphQL services.

##### README for additional insights
- Lists four main user‐facing services: AI Doctor (Gemini API), Nearby Hospitals (Google Maps + Geolocation), Emergency Contacts, Consult a Doctor (appointment & chat/video).
- News feed powered by News API.
- Key mobile tech: React Native, Image Crop Picker, Google Maps, Geolocation.

##### Main components
a. Mobile Device (iOS / Android)
– React Native JS Layer
– Native modules bridged via the React Native bridge:
- Camera & Image Cropper
- Geolocation
- Maps SDK
b. Application Modules (JS)
– Scanner module (Utils.cameraUtils → image picker → processing)
– AI Doctor module (Utils.doctorPrompt → Gemini API)
– Nearby Hospitals module (Utils.scannerPrompt → Geolocation + Google Maps API)
– News module (newsDto → News API)
– Services module (appointmentDto → “Consult a Doctor” API)
– UI layer (components/ + layout/)
c. External Services
– Gemini API (AI Doctor)
– Google Maps API (hospital locator)
– Geolocation Service (device GPS)
– News API (health news)
– Appointment / Chat / Video‐call API (third‐party medical service)
d. Optional local storage or mock server (for __tests__ and mockData)

##### Relationships and data flows
- User taps “Scan” → React Native UI → Camera native module → image returned to JS → send image to Gemini API for medicine ID
- User views “Nearby Hospitals” → JS requests device geolocation → calls Google Maps API → map tiles + hospital data returned → rendered in UI
- User reads news → JS issues REST call to News API → JSON feed → mapped into newsDto → newsCard components render articles
- User books appointment/chat → prepare appointmentDto → send to Health Services backend → confirmation → UI update

##### Architectural patterns and design principles
- Layered architecture:
– Presentation (components/layout)
– Business logic (Utils, DTO transformation)
– Data/Service layer (external API calls via fetch/Axios)
– Native‐bridge (React Native bridge to camera, geolocation, maps)
- Separation of concerns: UI vs. service integration vs. data modeling
- Asynchronous, event‐driven flows for API calls and native events

##### Essential architectural elements to capture
- React Native entrypoint (index.js → App.tsx)
- Core directories (components vs. layout vs. Utils vs. dto)
- Native SDK integrations (camera, geolocation, maps)
- External API endpoints (Gemini, News, Maps, Appointment service)
- Data flow paths and transformation via DTOs

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile Device"
        direction TB
        subgraph "React Native JS Layer"
            direction TB
            RNEntry["index.js"]:::logic
            RootComp["App.tsx"]:::logic
            subgraph "Presentation Layer"
                direction TB
                NavBar["Navigation Bar"]:::presentation
                TopBar["Top Bar"]:::presentation
                subgraph "News Components"
                    direction TB
                    NewsList["News List"]:::presentation
                    NewsCard["News Card"]:::presentation
                end
                subgraph "Services Components"
                    direction TB
                    ServicesList["Services List"]:::presentation
                    ServiceCard["Service Card"]:::presentation
                end
                subgraph "Layouts (Screens)"
                    direction TB
                    Home["Home Screen"]:::presentation
                    AIDoc["AI Doctor Screen"]:::presentation
                    Details["Scanner / Details Screen"]:::presentation
                    Hospital["Hospital Locator Screen"]:::presentation
                    MapTest["Map Test Screen"]:::presentation
                    subgraph "Doctor Consult Flow"
                        direction TB
                        DocList["Doctor List"]:::presentation
                        DocCard["Doctor Card"]:::presentation
                        DocDetailCard["Doctor Detail Card"]:::presentation
                        DocDetailScreen["Doctor Detail Screen"]:::presentation
                    end
                    Profile["User Profile"]:::presentation
                    Settings["Settings"]:::presentation
                end
            end
            subgraph "Business Logic (Utils)" 
                direction TB
                CamUtil["Camera & Image Picker"]:::logic
                DocPrompt["AI Doctor Prompt Generator"]:::logic
                ScanPrompt["Scanner Prompt / Processing"]:::logic
            end
            subgraph "Data Transfer Objects (DTOs)"
                direction TB
                ApptDTO["Appointment DTO"]:::logic
                NewsDTO["News DTO"]:::logic
                ServiceDTO["Service DTO"]:::logic
            end
            subgraph "Mock Data"
                direction TB
                MockDoc["Mock Doctor Details"]:::logic
            end
        end
        subgraph "Native Modules" 
            direction TB
            CamNative["Camera & Image Cropper"]:::native
            GeoNative["Geolocation"]:::native
            MapNative["Maps SDK"]:::native
        end
    end

    subgraph "External Services"
        direction TB
        Gemini["Gemini API"]:::external
        GoogleMaps["Google Maps API"]:::external
        GeoService["Geolocation Service"]:::external
        NewsAPI["News API"]:::external
        HealthService["Appointment/Chat/Video API"]:::external
    end

    %% Data Flows
    RNEntry -->|loads| RootComp
    RootComp -->|renders| NavBar
    RootComp -->|renders| TopBar
    RootComp -->|renders| Home
    RootComp -->|navigates to| AIDoc
    RootComp -->|navigates to| Details
    RootComp -->|navigates to| Hospital
    RootComp -->|navigates to| MapTest
    RootComp -->|navigates to| DocList
    RootComp -->|navigates to| Profile
    RootComp -->|navigates to| Settings

    NavBar -->|uses| TopBar
    Home -->|calls| CamUtil
    Details -->|calls| CamUtil
    AIDoc -->|calls| DocPrompt
    Hospital -->|calls| ScanPrompt
    DocList -->|uses| ServiceDTO
    DocDetailScreen -->|uses| ServiceDTO
    ServicesList -->|uses| ServiceDTO
    NewsList -->|uses| NewsDTO

    CamUtil -->|via bridge| CamNative
    ScanPrompt -->|via bridge| GeoNative
    ScanPrompt -->|via bridge| MapNative
    DocPrompt -->|HTTP/REST| Gemini
    ScanPrompt -->|HTTP/REST| GoogleMaps
    GeoNative -->|device GPS| GeoService
    NewsList -->|HTTP/REST| NewsAPI
    DocList -->|HTTP/REST| HealthService
    ServiceDTO -->|HTTP/REST| HealthService

    %% Click Events
    click RNEntry "https://github.com/riteshdev99/medimate/blob/main/index.js"
    click RootComp "https://github.com/riteshdev99/medimate/blob/main/src/App.tsx"
    click NavBar "https://github.com/riteshdev99/medimate/blob/main/src/components/navBar/navBar.tsx"
    click TopBar "https://github.com/riteshdev99/medimate/blob/main/src/components/topBar/topBar.tsx"
    click NewsCard "https://github.com/riteshdev99/medimate/blob/main/src/components/news/newsCard.tsx"
    click NewsList "https://github.com/riteshdev99/medimate/blob/main/src/components/news/news.tsx"
    click ServiceCard "https://github.com/riteshdev99/medimate/blob/main/src/components/services/serviceCard.tsx"
    click ServicesList "https://github.com/riteshdev99/medimate/blob/main/src/components/services/services.tsx"
    click Home "https://github.com/riteshdev99/medimate/blob/main/src/layout/homeLayout.tsx"
    click AIDoc "https://github.com/riteshdev99/medimate/blob/main/src/layout/aiDoctor.tsx"
    click Details "https://github.com/riteshdev99/medimate/blob/main/src/layout/detailsLayout.tsx"
    click Hospital "https://github.com/riteshdev99/medimate/blob/main/src/layout/hospitalLayout.tsx"
    click MapTest "https://github.com/riteshdev99/medimate/blob/main/src/layout/mapTest.tsx"
    click DocList "https://github.com/riteshdev99/medimate/blob/main/src/layout/doctorConsult/doctorConsult.tsx"
    click DocCard "https://github.com/riteshdev99/medimate/blob/main/src/layout/doctorConsult/doctorCard.tsx"
    click DocDetailCard "https://github.com/riteshdev99/medimate/blob/main/src/layout/doctorConsult/doctorDetailCard.tsx"
    click DocDetailScreen "https://github.com/riteshdev99/medimate/blob/main/src/layout/doctorConsult/doctorDetailScreen.tsx"
    click Profile "https://github.com/riteshdev99/medimate/blob/main/src/layout/userProfile.tsx"
    click Settings "https://github.com/riteshdev99/medimate/blob/main/src/layout/setting.tsx"
    click CamUtil "https://github.com/riteshdev99/medimate/blob/main/src/Utils/cameraUtils.ts"
    click DocPrompt "https://github.com/riteshdev99/medimate/blob/main/src/Utils/doctorPrompt.ts"
    click ScanPrompt "https://github.com/riteshdev99/medimate/blob/main/src/Utils/scannerPrompt.ts"
    click ApptDTO "https://github.com/riteshdev99/medimate/blob/main/src/dto/appointmentDto.ts"
    click NewsDTO "https://github.com/riteshdev99/medimate/blob/main/src/dto/newsDto.ts"
    click ServiceDTO "https://github.com/riteshdev99/medimate/blob/main/src/dto/serviceDto.ts"
    click MockDoc "https://github.com/riteshdev99/medimate/blob/main/src/mockData/doctorDetails.ts"

    classDef presentation fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef logic fill:#DBFFD0,stroke:#333,stroke-width:1px
    classDef native fill:#FFD8A8,stroke:#333,stroke-width:1px
    classDef external fill:#E4D0FF,stroke:#333,stroke-width:1px
```
