# cmput301-w25/project-superiorintelligence architecture

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

- Interactive diagram: https://gitdiagram.com/cmput301-w25/project-superiorintelligence
- Repository: https://github.com/cmput301-w25/project-superiorintelligence

## Overview

##### Main Components Identification
a. Android Client:
- UI Layer: Includes Activities (e.g., HomeActivity, LoginPageActivity, ProfileActivity, etc.) and Fragments (DeleteMoodFragment, PostStatusFragment, etc.).
- UI Supporting Components: Adapters for RecyclerViews/ListViews (such as CommentsAdapter, EventAdapter, NotificationAdapter, UserAdapter).
- Business Logic / Managers: Classes like EventManager, HomeManager, FollowManager, SearchUserManager.
b. Data/Storage Layer:
- Local Data Handling: Classes like Database, Photo-related classes (Photobase) indicate local data storage or file handling.
- Remote/Cloud Integration: Firebase components (Firebase configuration, google-services.json) to manage remote data storage, authentication, and notifications.
c. Testing Components:
- Instrumented Tests (located under androidTest) for UI/Integration testing.
- Unit Tests (located under test) for business logic and components.
d. Build & Configuration:
- Gradle Scripts & Properties: Indicating dependencies, build configuration, and setup instructions.
- Firebase and other configuration files: firebase.json and google-services.json.

##### Relationships and Interactions
- UI components interact with the business logic (manager classes) to retrieve and display data.
- The business logic interfaces with both local data storage mechanisms (via the Database or Photobase classes) and Firebase for cloud operations.
- Adapters mediate between raw data (such as lists of events, users, or notifications) and the UI components.
- Testing layers interact with almost all components to ensure functionality from the UI down to the business logic and data layers.
- Gradle build configuration connects the source layers and dependencies, ensuring proper compilation and packaging.

##### Architectural Patterns and Design Principles
- The project uses separation of concerns by dividing UI, business logic, and data layers.
- Activity/Fragment based UI design is typical for Android apps.
- There is a clear emphasis on modularity: each feature (comments, events, notifications, and profile management) is implemented across dedicated classes and packages.
- Firebase integration suggests reliance on external cloud services to handle aspects like authentication, real-time data, or notifications.

##### Relevant Technologies & Frameworks
- Android Framework (Activities, Fragments, Adapters, Resource files in res/)
- Kotlin (as seen in build scripts and file extensions)
- Firebase (configured via google-services.json and firebase.json)
- Gradle (configured with *.gradle.kts scripts, wrapper directory, and version files)

##### Elements
- Clear and concise labels for every component (e.g., “HomeActivity”, “EventManager”, “Firebase Cloud”).
- Annotations for external services (Firebase) and configuration/build management (Gradle scripts).
- Adding notes that indicate where testing components live and how they validate interactions between layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        HA["HomeActivity"]:::ui
        LPA["LoginPageActivity"]:::ui
        PA["ProfileActivity"]:::ui
        CAA["CreateAccountActivity"]:::ui
        MCE["MoodCreateAndEditActivity"]:::ui
        OUA["OtherUserProfileActivity"]:::ui
        DMF["DeleteMoodFragment"]:::ui
        PSF["PostStatusFragment"]:::ui
        RMF["RecentMoodEventFragment"]:::ui
        CAda["CommentsAdapter"]:::ui
        EAda["EventAdapter"]:::ui
        NAda["NotificationAdapter"]:::ui
        UAda["UserAdapter"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        EM["EventManager"]:::logic
        HM["HomeManager"]:::logic
        FM["FollowManager"]:::logic
        SUM["SearchUserManager"]:::logic
        Mapper["Mapper"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["Database.java"]:::data
        PB["Photobase.java"]:::data
        PAct["PhotoActivity.java"]:::data
        MM["MoodMap"]:::data
        RMER["RecentMoodEventRepository"]:::data
    end

    %% Firebase Cloud
    subgraph "Firebase Cloud"
        F1["google-services.json"]:::remote
        F2["firebase.json"]:::remote
    end

    %% Testing
    subgraph "Testing"
        Instr["Instrumented Tests"]:::test
        Unit["Unit Tests"]:::test
    end

    %% Build & Configuration
    subgraph "Build & Configuration"
        GradleApp["build.gradle.kts (app)"]:::build
        GradleProj["build.gradle.kts (project)"]:::build
        GradleSettings["settings.gradle.kts"]:::build
        GradleDir["gradle directories & files"]:::build
    end

    %% UI to Business Logic Relationships
    HA -->|"calls"| HM
    LPA -->|"calls"| SUM
    PA -->|"calls"| FM
    DMF -->|"triggers"| EM
    PSF -->|"triggers"| HM
    RMF -->|"triggers"| EM
    CAda -->|"bindsData"| HM
    EAda -->|"displaysEventData"| EM
    NAda -->|"bindsData"| HM
    UAda -->|"bindsData"| FM

    %% Business Logic to Data Layer Relationships
    EM -->|"fetches"| DB
    HM -->|"readsWrites"| PB
    Mapper -->|"mapsData"| DB
    DB -->|"returnsData"| EM
    PB -->|"returnsData"| HM

    %% Business Logic to Firebase Relationships
    FM -->|"syncs"| F1
    SUM -->|"authenticates"| F2

    %% Testing Relationships
    Instr -->|"testsUI"| HA
    Unit -->|"testsLogic"| HM

    %% Build & Configuration Relationships
    GradleApp -->|"builds"| HA
    GradleProj -->|"builds"| EM
    GradleSettings -->|"configures"| F1
    GradleDir -->|"includes"| GradleApp

    %% Class Definitions for Colour Coding
    classDef ui fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef logic fill:#A9DFBF,stroke:#1D8348,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef remote fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef test fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef build fill:#FAD7A0,stroke:#D35400,stroke-width:2px;

    %% Click Events for UI Layer (Activities, Fragments and Adapters)
    click HA "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click LPA "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click PA "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click CAA "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click MCE "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click OUA "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click DMF "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click PSF "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click RMF "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click CAda "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click EAda "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click NAda "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click UAda "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"

    %% Click Events for Business Logic / Manager Classes
    click EM "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click HM "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click FM "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click SUM "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click Mapper "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"

    %% Click Events for Data Layer
    click DB "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click PB "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click PAct "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click MM "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"
    click RMER "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/main/java/com/example/superior_intelligence"

    %% Click Events for Firebase Integration
    click F1 "https://github.com/cmput301-w25/project-superiorintelligence/blob/main/code/app/google-services.json"
    click F2 "https://github.com/cmput301-w25/project-superiorintelligence/blob/main/firebase.json"

    %% Click Events for Testing Components
    click Instr "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/androidTest/java/com/example/superior_intelligence"
    click Unit "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/app/src/test/java/com/example/superior_intelligence"

    %% Click Events for Build & Configuration
    click GradleApp "https://github.com/cmput301-w25/project-superiorintelligence/blob/main/code/app/build.gradle.kts"
    click GradleProj "https://github.com/cmput301-w25/project-superiorintelligence/blob/main/code/build.gradle.kts"
    click GradleSettings "https://github.com/cmput301-w25/project-superiorintelligence/blob/main/code/settings.gradle.kts"
    click GradleDir "https://github.com/cmput301-w25/project-superiorintelligence/tree/main/code/gradle"
```
