# theimperialone/setu_x architecture

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

- Interactive diagram: https://gitdiagram.com/theimperialone/setu_x
- Repository: https://github.com/theimperialone/setu_x

## Overview

##### Project type and purpose
- This is a mobile-client–server application: an Android app (“Setu_X”) for patients and hospital staff to securely store and retrieve medical history.
- The backend is Firebase (Authentication, Realtime Database or Firestore, Storage), accessed via REST/SDK calls (VolleyMultipartRequest).

##### File structure
- Top-level: one Gradle module (`app`) containing all Android code and resources.
- Package breakdown under `com.imperial.setux`:
- root activities (MainActivity, UserActivity, DummyActivity)
- `hospital` subpackage – hospital login, registration, dashboard, patient verification, add diagnosis, view history
- `patient` subpackage – patient login, registration, dashboard, view notifications, medical history
- `medicalRecord` subpackage – adapter and model for medical record list
- Network helper: `VolleyMultipartRequest`
- Configuration: `google-services.json` (Firebase), `network_security_config.xml`, ProGuard rules

##### README
- Confirms use of Android Studio and Firebase
- Unique patient identifier: Aadhaar Number
- Security: encryption, authentication
- Future integrations: Blockchain, Digilocker

##### Components
a. Main components
- Android App (Client)
– UI Layer (Activities & Fragments)
– Domain/Feature Modules (hospital, patient, medicalRecord)
– Network Layer (VolleyMultipartRequest, Firebase SDK)
– Local config & security (network_security_config.xml, encryption helpers)
- Backend Services (Firebase)
– Authentication Service (login/register hospital & patient)
– Database (Firestore or Realtime Database storing patient records keyed by Aadhaar)
– Storage (prescriptions, attachments)
– (Optionally) Cloud Functions for server-side logic/encryption
- External Services (future/facilitators)
– Aadhaar validation API
– Digilocker API
– Blockchain network (future)

b. Relationships & data flow
- User taps button → Activity calls domain controller → Network Layer issues request via Firebase SDK or Volley → Firebase Authentication verifies → DB read/write → Response returns → UI updates
- Secure channel layer (HTTPS/TLS) between App and Firebase

c. Architectural patterns & design principles
- Feature-based packaging: separate hospital & patient flows
- MVC/MVVM-ish: Activities as controllers, Adapters/ViewModels for lists, Models for data (Patient, MedicalRecord)
- Single‐responsibility: each Activity focuses on one screen
- Secure by design: network_security_config enforces TLS, ProGuard for obfuscation

d. Key technologies/frameworks
- Android SDK & AndroidX
- Firebase Auth, Firebase Database, Firebase Storage
- Volley (multipart requests)
- ProGuard/R8 (code shrinking)
- Gradle (build system)

## Diagram (Mermaid)

```mermaid
flowchart TD
    AndroidApp["Android App (Client)"]:::client
    UIActivities["UI Layer\n(Activities & Layouts)"]:::ui
    Hospital["Hospital Module"]:::business
    Patient["Patient Module"]:::business
    MedicalRecord["MedicalRecord Module"]:::business
    Volley["VolleyMultipartRequest"]:::network
    FirebaseSDK["Firebase SDK"]:::network
    Security["Config & Security\n(network_security_config.xml,\nProGuard)"]:::config
    GoogleServices["google-services.json"]:::config

    subgraph "Firebase Backend"
        Auth["Authentication Service"]:::backend
        Database["Firestore/Realtime DB"]:::backend
        Storage["Storage Service"]:::backend
        CloudFunctions["Cloud Functions"]:::backend
    end

    subgraph "External Services"
        Aadhaar["Aadhaar Validation API"]:::external
        DigiLocker["Digilocker API"]:::external
        Blockchain["Blockchain Network"]:::external
    end

    AndroidApp --> UIActivities
    AndroidApp --> Hospital
    AndroidApp --> Patient
    AndroidApp --> MedicalRecord
    AndroidApp --> Volley
    AndroidApp --> FirebaseSDK
    AndroidApp --> Security
    AndroidApp --> GoogleServices

    UIActivities -->|"invoke controllers"| Hospital
    UIActivities -->|"invoke controllers"| Patient
    UIActivities -->|"invoke controllers"| MedicalRecord

    Hospital -->|"Auth & Data Requests"| Volley
    Patient -->|"Auth & Data Requests"| Volley
    MedicalRecord -->|"CRUD Records"| Volley

    Volley -->|"Authenticate\nHTTPS/TLS"| Auth
    Volley -->|"Read/Write Data\nHTTPS/TLS"| Database
    Volley -->|"Upload/Download\nHTTPS/TLS"| Storage
    Volley -->|"Cloud Function Calls\nHTTPS/TLS"| CloudFunctions

    UIActivities -->|"Verify ID\nHTTPS/TLS"| Aadhaar
    UIActivities -->|"Future Integration"| DigiLocker
    UIActivities -->|"Future Integration"| Blockchain

    click AndroidApp "https://github.com/theimperialone/setu_x/tree/master/app/"
    click UIActivities "https://github.com/theimperialone/setu_x/tree/master/app/src/main/java/com/imperial/setux/"
    click Hospital "https://github.com/theimperialone/setu_x/tree/master/app/src/main/java/com/imperial/setux/hospital/"
    click Patient "https://github.com/theimperialone/setu_x/tree/master/app/src/main/java/com/imperial/setux/patient/"
    click MedicalRecord "https://github.com/theimperialone/setu_x/tree/master/app/src/main/java/com/imperial/setux/medicalRecord/"
    click Volley "https://github.com/theimperialone/setu_x/blob/master/app/src/main/java/com/imperial/setux/VolleyMultipartRequest.java"
    click GoogleServices "https://github.com/theimperialone/setu_x/blob/master/app/google-services.json"
    click Security "https://github.com/theimperialone/setu_x/blob/master/app/src/main/res/xml/network_security_config.xml"
    click Security "https://github.com/theimperialone/setu_x/blob/master/app/proguard-rules.pro"

    classDef client fill:#e0f7fa,stroke:#006064,color:#000
    classDef ui fill:#e3f2fd,stroke:#1e88e5,color:#000
    classDef business fill:#e8f5e9,stroke:#43a047,color:#000
    classDef network fill:#fff3e0,stroke:#fb8c00,color:#000
    classDef config fill:#f3e5f5,stroke:#8e24aa,color:#000
    classDef backend fill:#ffe0b2,stroke:#ef6c00,color:#000
    classDef external fill:#eceff1,stroke:#37474f,color:#000
```
