# yerass11/umitapp architecture

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

- Interactive diagram: https://gitdiagram.com/yerass11/umitapp
- Repository: https://github.com/yerass11/umitapp

## Overview

##### Project type and high-level purpose
- UMitApp is a full-stack iOS mobile application (SwiftUI + UIKit)
- Purpose: allow users to register, book doctor appointments, order medicines (with Stripe payments), and chat with medical professionals.
- Architecture: MVVM on the client; Django REST + Firebase + Stripe on the server side.

##### Main components
A. Mobile Client (iOS App)
1. UI Layer
– SwiftUI Views (ContentView, Feature Views in Features/…)
– UIKit integrations where needed
2. Presentation Layer (MVVM)
– ViewModels in each feature (e.g. DoctorsViewModel, ChatViewModel, PaymentViewModel)
3. Service/Network Layer
– Core services: UserService, AppointmentService, DoctorService, HospitalService, DocumentService
– Feature services: ChatService (WebSocketManager), MedicineOrderService, AuthService
4. Core Modules
– CustomTabBar, CustomTextField, other reusable components

B. Backend Services
1. Django REST Framework API
– Endpoints for users, appointments, doctors, hospitals, documents, reviews, pharmacy orders
– Business logic, authentication hooks (JWT if used alongside Firebase)
– PostgreSQL (or other) database
2. Firebase
– Authentication (Email/Apple ID/Social)
– Real-time Database or Firestore for chat messages & notifications
– Cloud Messaging for push notifications
– Storage (if any media is stored)
3. Stripe
– Stripe iOS SDK integration on client
– Stripe webhooks on backend for payment confirmation

##### Relationships and data flows
- UI → ViewModel: two-way binding (SwiftUI @StateObject/@Published)
- ViewModel → Service: method calls for network actions
- Service → Django API: REST over HTTPS (JSON)
- Service → Firebase SDK: Auth calls, Database/Firestore reads & writes, Messaging subscriptions
- Service → Stripe SDK: payment token generation → backend → webhook → update order status
- ChatService → WebSocketManager: persistent socket connection to chat endpoint (could be Django Channels or Firebase RT-DB)
- Push Notifications: Django or Firebase Cloud Functions → FCM → device

##### Architectural patterns & design principles
– MVVM: clear separation of Views, ViewModels, and Services
– Modular “Features” directory: each feature encapsulates its models, views, and services
– Core reusable modules in Core/ (TabBar, TextField)
– Dependency injection of services into view models (via initializers or environment objects)
– Single source of truth for network configuration (base URL, headers)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Mobile Client" 
        style MobileClient fill:#D0E8FF,stroke:#333,stroke-width:1px
        subgraph "UI Layer (SwiftUI + UIKit)"
            AppEntry["UMitApp.swift"]:::client
            ContentView["ContentView.swift"]:::client
            ChatView["ChatView.swift"]:::client
            HomeView["HomeView.swift"]:::client
        end
        subgraph "ViewModels (MVVM)"
            DoctorsVM["DoctorsViewModel.swift"]:::client
            AuthVM["AuthViewModel.swift"]:::client
        end
        subgraph "Services"
            UserService["UserService.swift"]:::client
            ChatService["ChatService.swift"]:::client
            WebSocket["WebSocketManager.swift"]:::client
        end
        subgraph "Core Modules"
            CustomTabBar["CustomTabBar.swift"]:::client
            CustomTextField["CustomTextField.swift"]:::client
        end
    end

    subgraph "Backend Services"
        style Backend fill:#D0FFD6,stroke:#333,stroke-width:1px
        DjangoAPI["Django REST Framework API"]:::backend
        Postgres[(PostgreSQL)]:::backend
    end

    Firebase["Firebase (Auth / Firestore / FCM)"]:::external
    Firestore[(Firestore)]:::external
    Stripe["Stripe"]:::external

    %% Connections
    AppEntry -->|"@Published/Binding"| DoctorsVM
    ContentView -->|"@Published/Binding"| AuthVM
    DoctorsVM -->|"calls"| UserService
    AuthVM -->|"calls"| UserService
    UserService -->|"HTTPS JSON REST"| DjangoAPI
    ChatService -->|"Firebase SDK calls"| Firebase
    ChatService -->|"WebSocket"| WebSocket
    DjangoAPI -->|"SQL queries"| Postgres
    DjangoAPI -->|"webhooks"| Stripe
    Firebase -->|"push notifications (FCM)"| AppEntry

    %% Click Events
    click AppEntry "https://github.com/yerass11/umitapp/blob/main/UMit/UMit/App/UMitApp.swift"
    click ContentView "https://github.com/yerass11/umitapp/blob/main/UMit/UMit/Features/ContentView.swift"
    click ChatView "https://github.com/yerass11/umitapp/blob/main/UMit/UMit/Features/Chat/Modules/View/ChatView.swift"
    click HomeView "https://github.com/yerass11/umitapp/blob/main/UMit/UMit/Features/Home/Modules/Home/HomeView.swift"
    click DoctorsVM "https://github.com/yerass11/umitapp/blob/main/UMit/UMit/Features/Home/Modules/Doctor/ViewModel/DoctorsViewModel.swift"
    click AuthVM "https://github.com/yerass11/umitapp/blob/main/UMit/UMit/Features/Profile/Modules/Auth/ViewModel/AuthViewModel.swift"
    click UserService "https://github.com/yerass11/umitapp/blob/main/UMit/UMit/Core/Service/UserService.swift"
    click ChatService "https://github.com/yerass11/umitapp/blob/main/UMit/UMit/Features/Chat/Modules/Service/ChatService.swift"
    click WebSocket "https://github.com/yerass11/umitapp/blob/main/UMit/UMit/Features/Chat/Modules/Service/WebSocketManager.swift"
    click CustomTabBar "https://github.com/yerass11/umitapp/blob/main/UMit/UMit/Core/TabBar/CustomTabBar.swift"
    click CustomTextField "https://github.com/yerass11/umitapp/blob/main/UMit/UMit/Core/TextField/CustomTextField.swift"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#036,stroke-width:1px
    classDef backend fill:#D0FFD6,stroke:#093,stroke-width:1px
    classDef external fill:#FFEFD5,stroke:#F60,stroke-width:1px
```
