# hasan-alhamwi/eventapp architecture

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

- Interactive diagram: https://gitdiagram.com/hasan-alhamwi/eventapp
- Repository: https://github.com/hasan-alhamwi/eventapp

## Overview

##### Project Type & Purpose
- This is an Android-based event booking application that implements Clean Architecture with the MVVM design pattern.
- The app’s purpose is to allow users to browse events, view event details, and perform simulated event booking and payment processes.
- It emphasizes secure authentication, offline support (with local Room persistence), and a well-structured separation of concerns.

##### File Structure
- The project is organized into clear architectural layers:
- The “presentation” package contains various fragments, view models, and UI-related classes.
- The “domain” package includes use cases, domain models, and repository interfaces.
- The “data” package implements data sources for both local (Room database and DAOs) and remote (simulated API) data, along with repository implementations.
- There is a dedicated “di” (dependency injection) package that uses Hilt to provide dependencies across the app.
- The presence of extensive tests also indicates a focus on maintainability and testability.

##### Key Architectural Components to Capture
a. Presentation Layer:
- UI components: Fragments (e.g., LoginFragment, EventListFragment, EventDetailFragment, PaymentBottomSheetFragment).
- ViewModels: Manage UI state and state flows for each screen.
- Navigation: Managed via Jetpack Navigation Component with clear transitions.
b. Domain Layer:
- Use Cases: Represent business logic such as Login, Registration, GetEvents, GetEventDetails, CreateBooking, and ProcessPayment.
- Domain Models: Core representations (e.g., BookingDomain, EventDomain, PaymentDomain, UserDomain).
- Repository Interfaces: Contracts (e.g., IAuthRepository, IEventRepository) that abstract data operations.
c. Data Layer:
- Repository Implementations: Handle data operations and coordinate local vs remote data sources.
- Local Data Source: Room Database, DAOs (e.g., EventDao) for persistence and offline support.
- Remote Data Source: Mock API Service simulating network behavior.
- Data Models: Representations of entities used for both database and API interactions.

##### Elements
- The Presentation Layer communicates with the Domain Layer via ViewModels invoking Use Cases.
- The Domain Layer depends on Repository interfaces which are implemented in the Data Layer.
- The Data Layer integrates both local (Room Database with DAOs) and remote (Mock API Service) data sources.
- UI elements (e.g., rounded rectangles for fragments and view models).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        P1("LoginFragment"):::presentation
        P2("EventListFragment"):::presentation
        P3("EventDetailFragment"):::presentation
        P4("PaymentBottomSheetFragment"):::presentation
        P5("LoginViewModel"):::presentation
        P6("EventListViewModel"):::presentation
        P7("EventDetailViewModel"):::presentation
        P8("PaymentViewModel"):::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        D1("LoginUseCase"):::domain
        D2("RegisterUseCase"):::domain
        D3("GetEventsUseCase"):::domain
        D4("GetEventDetailsUseCase"):::domain
        D5("CreateBookingUseCase"):::domain
        D6("ProcessPaymentUseCase"):::domain
        DM1("EventDomain"):::domain
        DM2("BookingDomain"):::domain
        DM3("PaymentDomain"):::domain
        DM4("UserDomain"):::domain
        RI1("IAuthRepository"):::domain
        RI2("IEventRepository"):::domain
        RI3("IBookingRepository"):::domain
        RI4("IPaymentRepository"):::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        DAT1("AuthRepository"):::data
        DAT2("EventRepository"):::data
        DAT3("BookingRepository"):::data
        DAT4("PaymentRepository"):::data
        LD1("EventDatabase"):::data
        LD2("EventDao"):::data
        RD1("MockApiService"):::data
        DM_Data1("Booking"):::data
        DM_Data2("Event"):::data
        DM_Data3("Payment"):::data
        DM_Data4("User"):::data
        DMgr1("MockDataManager"):::data
        DMgr2("UserManager"):::data
    end

    %% Dependency Injection
    subgraph "Dependency Injection"
        DI1("AppModule"):::di
        DI2("DatabaseModule"):::di
        DI3("RepositoryModule"):::di
        DI4("UseCaseModule"):::di
    end

    %% Connections: Presentation Layer
    P1 -->|"calls"| P5
    P2 -->|"calls"| P6
    P3 -->|"calls"| P7
    P4 -->|"calls"| P8

    %% Connections: Presentation to Domain
    P5 -->|"invokes"| D1
    P6 -->|"invokes"| D3
    P7 -->|"invokes"| D4
    P8 -->|"invokes"| D6

    %% Connections: Domain Layer - UseCases to Repository Interfaces
    D1 -->|"calls"| RI1
    D2 -->|"calls"| RI1
    D3 -->|"calls"| RI2
    D4 -->|"calls"| RI2
    D5 -->|"calls"| RI3
    D6 -->|"calls"| RI4

    %% Connections: Domain to Data Layer (Repository Implementations)
    RI1 -->|"implementedBy"| DAT1
    RI2 -->|"implementedBy"| DAT2
    RI3 -->|"implementedBy"| DAT3
    RI4 -->|"implementedBy"| DAT4

    %% Connections: Data Layer - Repository Implementations to Data Sources
    DAT1 -->|"uses"| LD1
    DAT1 -->|"uses"| RD1
    DAT2 -->|"uses"| LD1
    DAT2 -->|"uses"| RD1
    DAT3 -->|"uses"| LD1
    DAT3 -->|"uses"| RD1
    DAT4 -->|"uses"| LD1
    DAT4 -->|"uses"| RD1

    %% Connections: Data Managers and Data Models
    DMgr1 -->|"manages"| DM_Data1
    DMgr2 -->|"manages"| DM_Data4

    %% Connections: Dependency Injection providing dependencies
    DI1 -->|"injects"| P5
    DI2 -->|"injects"| LD1
    DI3 -->|"injects"| DAT1
    DI3 -->|"injects"| DAT2
    DI4 -->|"injects"| D1

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef domain fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef data fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef di fill:#fff3cd,stroke:#856404,stroke-width:2px;

    %% Click Events - Presentation Layer
    click P1 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/presentation/auth/login/LoginFragment.kt"
    click P2 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/presentation/events/list/EventListFragment.kt"
    click P3 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/presentation/events/detail/EventDetailFragment.kt"
    click P4 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/presentation/payment/PaymentBottomSheetFragment.kt"
    click P5 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/presentation/auth/login/LoginViewModel.kt"
    click P6 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/presentation/events/list/EventListViewModel.kt"
    click P7 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/presentation/events/detail/EventDetailViewModel.kt"
    click P8 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/presentation/payment/PaymentViewModel.kt"

    %% Click Events - Domain Layer
    click D1 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/usecases/auth/LoginUseCase.kt"
    click D2 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/usecases/auth/RegisterUseCase.kt"
    click D3 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/usecases/events/GetEventsUseCase.kt"
    click D4 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/usecases/events/GetEventDetailsUseCase.kt"
    click D5 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/usecases/booking/CreateBookingUseCase.kt"
    click D6 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/usecases/payment/ProcessPaymentUseCase.kt"
    click DM1 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/models/EventDomain.kt"
    click DM2 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/models/BookingDomain.kt"
    click DM3 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/models/PaymentDomain.kt"
    click DM4 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/models/UserDomain.kt"
    click RI1 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/repositories/IAuthRepository.kt"
    click RI2 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/repositories/IEventRepository.kt"
    click RI3 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/repositories/IBookingRepository.kt"
    click RI4 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/domain/repositories/IPaymentRepository.kt"

    %% Click Events - Data Layer
    click DAT1 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/repositories/AuthRepository.kt"
    click DAT2 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/repositories/EventRepository.kt"
    click DAT3 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/repositories/BookingRepository.kt"
    click DAT4 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/repositories/PaymentRepository.kt"
    click LD1 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/local/EventDatabase.kt"
    click LD2 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/local/dao/EventDao.kt"
    click RD1 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/remote/MockApiService.kt"
    click DM_Data1 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/models/Booking.kt"
    click DM_Data2 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/models/Event.kt"
    click DM_Data3 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/models/Payment.kt"
    click DM_Data4 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/models/User.kt"
    click DMgr1 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/managers/MockDataManager.kt"
    click DMgr2 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/data/managers/UserManager.kt"

    %% Click Events - Dependency Injection
    click DI1 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/di/modules/AppModule.kt"
    click DI2 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/di/modules/DatabaseModule.kt"
    click DI3 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/di/modules/RepositoryModule.kt"
    click DI4 "https://github.com/hasan-alhamwi/eventapp/blob/master/app/src/main/java/com/hasan/eventapp/di/modules/UseCaseModule.kt"
```
