# lucasomac/shesafe architecture

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

- Interactive diagram: https://gitdiagram.com/lucasomac/shesafe
- Repository: https://github.com/lucasomac/shesafe

## Overview

##### Project Type and Purpose
- SheSafe is a Kotlin Multiplatform mobile application.
- Targets: Android (Jetpack Compose + MVVM) and iOS (SwiftUI).
- Purpose: Personal safety toolkit (emergency contacts, location sharing, fake call, alerts) with Firebase backend and Google Sign-In.

##### File Structure
- Modules:
– androidApp/ : Android front end, structured by Clean Architecture (presentation, domain, data, framework).
– iosApp/ : iOS front end (SwiftUI).
– shared/ : Kotlin Multiplatform shared code (common business logic, routes, resources).
- Layers in androidApp:
– presentation/ (ViewModels, UI Composables)
– domain/ (Entities, Repositories interfaces, UseCases)
– data/ (Models, RepositoryImpl)
– framework/ (DataSourceImpl, Services for Firebase, DI)
- Configuration & build scripts: Gradle, Kotlin DSL.

##### README
- Mentions tech stack: Kotlin, Compose, Multiplatform, Firebase, Google Sign-In, Material3.
- Highlights Clean Architecture and key features.

##### Main Components
A. Mobile Frontends
1. Android App
– Jetpack Compose UI
– ViewModels (MVVM)
2. iOS App
– SwiftUI Views
– Calls shared use-cases directly
B. Shared KMP Module
– Business logic, route definitions, enums
C. Domain Layer (Android-specific, mirrored in shared if applicable)
– UseCases
– Repository interfaces
– Entities
D. Data Layer
– RepositoryImpl (adapts DataSources to Domain)
– Models (HelpRequestModel, SecureContactModel, etc.)
E. Framework Layer
– DataSources Impl (FirebaseDataSourceImpl)
– Services (AuthFirebaseService, HelpRequestFirebaseService…)
– DI container (SheSafeDependenciesInjection)
F. External Services
– Firebase (Auth, Firestore, Realtime DB)
– Google Sign-In
G. Platform SDKs
– Android SDK
– iOS SDK

##### Relationships & Interactions
- UI → ViewModel → UseCase → Repository interface → DataSource → Firebase Service → Firebase backend.
- Shared KMP code is invoked by both Android and iOS layers for common logic.
- Google Sign-In via FirebaseAuth.
- DI module wires up RepositoryImpl to UseCases and DataSources.

##### Architectural Patterns & Design Principles
- Clean Architecture: Separation into presentation / domain / data / framework.
- MVVM on Android; SwiftUI + shared use-cases on iOS.
- Dependency Injection (SheSafeDependenciesInjection).
- Kotlin Multiplatform for code reuse.
- Asynchronous calls via Coroutines.

##### Essential Elements
- Clear component names.
- Arrowheads indicating call direction (UI → ViewModel → UseCase → …).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Android Module
    subgraph "androidApp Module"
        direction TB
        %% Entry Points
        entry1["MainActivity"]:::frontend
        entry2["SheSafeApp"]:::frontend
        entry3["SheSafeApplication"]:::frontend
        fp["FirebaseProvider"]:::framework

        %% Layers
        subgraph "Presentation Layer"
            direction TB
            PL["Presentation Layer"]:::presentation
        end
        subgraph "Domain Layer"
            direction TB
            DL["Domain Layer"]:::domain
        end
        subgraph "Data Layer"
            direction TB
            DM["Models"]:::data
            RI["RepositoryImpl"]:::data
        end
        subgraph "Framework Layer"
            direction TB
            DS["DataSourceImpl"]:::framework
            SV["Firebase Services"]:::framework
            DI["SheSafeDependenciesInjection"]:::framework
        end
    end

    %% Shared Module
    subgraph "shared Module"
        direction TB
        SH1["KMP Business Logic"]:::shared
        SH2["Resources (strings, styles, icons)"]:::shared
    end

    %% iOS Module
    subgraph "iosApp Module"
        direction TB
        IOS1["iOSApp Entry"]:::frontend
        IOS2["ContentView"]:::frontend
        IOS3["Assets & Config"]:::frontend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        FA["Firebase Auth"]:::external
        FB["Firestore / Realtime DB"]:::external
        GS["Google Sign-In"]:::external
    end

    %% Connections Android Flow
    entry1 -->|launches| PL
    entry2 -->|initializes UI| PL
    entry3 -->|sets up DI| DI
    PL -->|calls UseCases| DL
    DL -->|invokes Repo| RI
    RI -->|uses DataSource| DS
    DS -->|calls| SV
    SV -->|auth via| FA
    SV -->|access data| FB
    GS -->|auth integration| FA
    fp -->|provides config| SV

    %% Shared usage
    PL -->|shared logic| SH1
    DL -->|shared logic| SH1
    IOS1 -->|calls| SH1
    IOS2 -->|calls| SH1

    %% iOS to external
    IOS1 -->|auth via| FA
    IOS1 -->|firestore| FB

    %% Click Events Android
    click PL "https://github.com/lucasomac/shesafe/tree/main/androidApp/src/main/java/br/com/lucolimac/shesafe/android/presentation"
    click DL "https://github.com/lucasomac/shesafe/tree/main/androidApp/src/main/java/br/com/lucolimac/shesafe/android/domain"
    click DM "https://github.com/lucasomac/shesafe/tree/main/androidApp/src/main/java/br/com/lucolimac/shesafe/android/data/model"
    click RI "https://github.com/lucasomac/shesafe/tree/main/androidApp/src/main/java/br/com/lucolimac/shesafe/android/data/repository"
    click DS "https://github.com/lucasomac/shesafe/tree/main/androidApp/src/main/java/br/com/lucolimac/shesafe/android/framework/data/source"
    click SV "https://github.com/lucasomac/shesafe/tree/main/androidApp/src/main/java/br/com/lucolimac/shesafe/android/framework/service"
    click DI "https://github.com/lucasomac/shesafe/blob/main/androidApp/src/main/java/br/com/lucolimac/shesafe/android/framework/di/SheSafeDependenciesInjection.kt"
    click entry1 "https://github.com/lucasomac/shesafe/blob/main/androidApp/src/main/java/br/com/lucolimac/shesafe/android/MainActivity.kt"
    click entry2 "https://github.com/lucasomac/shesafe/blob/main/androidApp/src/main/java/br/com/lucolimac/shesafe/android/SheSafeApp.kt"
    click entry3 "https://github.com/lucasomac/shesafe/blob/main/androidApp/src/main/java/br/com/lucolimac/shesafe/android/SheSafeApplication.kt"
    click fp "https://github.com/lucasomac/shesafe/blob/main/androidApp/src/main/java/br/com/lucolimac/shesafe/android/FirebaseProvider.kt"

    %% Click Events Shared
    click SH1 "https://github.com/lucasomac/shesafe/tree/main/shared/src/commonMain/kotlin/br/com/lucolimac/shesafe"
    click SH2 "https://github.com/lucasomac/shesafe/tree/main/shared/src/main/res"

    %% Click Events iOS
    click IOS1 "https://github.com/lucasomac/shesafe/blob/main/iosApp/iosApp/iOSApp.swift"
    click IOS2 "https://github.com/lucasomac/shesafe/blob/main/iosApp/iosApp/ContentView.swift"
    click IOS3 "https://github.com/lucasomac/shesafe/blob/main/iosApp/iosApp/Assets.xcassets"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366D6,color:#0366D6;
    classDef presentation fill:#EAF5FF,stroke:#2C7BE5,color:#2C7BE5;
    classDef domain fill:#FFF4E5,stroke:#F0AD4E,color:#F0AD4E;
    classDef data fill:#F8EAF6,stroke:#A84D79,color:#A84D79;
    classDef framework fill:#F0F0F0,stroke:#6A737D,color:#6A737D;
    classDef shared fill:#FFEFD5,stroke:#FF8C00,color:#FF8C00;
    classDef external fill:#E6FFEA,stroke:#28A745,color:#28A745;
```
