# changeplusplusvandy/nami architecture

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

- Interactive diagram: https://gitdiagram.com/changeplusplusvandy/nami
- Repository: https://github.com/changeplusplusvandy/nami

## Overview

##### Project Type and Purpose
- This is an iOS mobile application developed in Swift that focuses on streamlining event registration and providing mental health support. It serves both end users (event attendees, those seeking help) and administrators (event creation, chat support).

##### Analyzing the File Structure
- The project has a “NAMI” directory containing all major UI components and views. Directories like “Authentication”, “Chat”, “Events”, “Home”, and “Member” denote logical features or modules.
- Within modules, notice that each major feature (e.g., Chat) is further split into submodules such as “Admins”, “Users”, and “ChatRoom”. Similarly, the “Events” module also contains a dedicated “Calendar” folder and helper files.
- The presence of utility classes in the “Utilities” folder indicates shared helper functionalities (caching, image processing, custom search bars, etc.), which are likely used across multiple modules.
- Configuration and integration files (GoogleService-Info.plist, Info.plist, NAMI.entitlements) indicate the app’s integration with external services and build environment.

##### Key Components and Their Interactions
a. Frontend Modules (iOS Client App):
- Authentication Module: Contains views like Login, Onboarding, and user-related models (AuthenticationManager, UserModel). This module handles user sign-in and session management.
- Chat Module: Split into submodules for Admins, Users, and ChatRoom functionalities. It encompasses chat helpers for routing and models for chat messaging.
- Events Module: Manages event registration, event detail views, event creation, and a calendar interface (CalendarManager, CalendarGrid, EventModel, etc.).
- Home and Member Modules: These include home screen routing, user profiles, member details, and promotion views.
- General Utilities: Helper functionalities (CacheManager, image compression, custom controls) which support UI and backend integration.

b. Backend Integration:
- Google Firebase acts as the backend providing Authentication services, real-time database updates (Firestore), Cloud Storage for assets, and Cloud Functions for server-side logic.
- The GoogleService-Info.plist file is used for configuration and linking the iOS app to the correct Firebase resources.

▸ Authentication: Show components like LoginView, AppWelcomeView, and AuthenticationManager.
▸ Chat: Break this into sub-components – Chat (Users, Admins, ChatRoom) and include connectivity with ChatRouter and ChatModel.
▸ Events: Display both Event listing (EventView, EventDetailView) and Calendar subcomponent (CalendarDayCell, CalendarManager).
▸ Home and Member: Outline HomeView, HomeScreenRouter, and Member-specific views.
▸ Utilities: Indicate that shared functionalities support all modules (e.g., CacheManager, ImageCompressor, CustomSearchBar).
▸ From each module (e.g., Authentication, Events, Chat) to the respective Firebase services.
- Integration points such as how the GoogleService-Info.plist configures the connection between the app and Firebase.

##### Architectural Patterns and Technology Stack
- Separation of concerns: There is a clear division among UI components, business logic (managers and routers), and utility services.
- Modularity where each major feature is broken into its own directory, facilitating future scalability and maintenance.
- Mention that the use of SwiftUI (and some UIKit elements) for the frontend implies reactive UI updates, while Firebase provides a robust scalable backend.
- Optionally, denote the navigation/routing mechanism (e.g., HomeScreenRouter, MemberRouter, ChatRouter) which orchestrates view transitions.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "iOS Mobile Client"
        subgraph "Authentication Module"
            A_W["AppWelcomeView"]:::ios
            A_L["LoginView"]:::ios
            A_O["UserOnboardingView"]:::ios
            A_M["AuthenticationManager"]:::ios
            A_U["UserModel"]:::ios
        end
        subgraph "Chat Module"
            subgraph "Admins"
                CAH["ChatAdminHomeView"]:::ios
                CRCell["ChatRequestCell"]:::ios
                CROCell["ChatRoomCell"]:::ios
            end
            subgraph "Chat Helpers"
                CH_Model["ChatModel"]:::ios
                CH_Router["ChatRouter"]:::ios
            end
            subgraph "Chat Room"
                CR_View["ChatRoomView"]:::ios
                CR_ViewModel["ChatRoomViewModel"]:::ios
                MsgBubble["MessageBubble"]:::ios
                MsgInput["MessageInputView"]:::ios
            end
            subgraph "Users"
                CU_Request["ChatRequestView"]:::ios
                CU_Starting["ChatStartingView"]:::ios
                CU_Unavailable["ChatUnavailableView"]:::ios
                CU_Manager["ChatUserManager"]:::ios
                CU_Waiting["ChatWaitingView"]:::ios
            end
        end
        subgraph "Events Module"
            subgraph "Calendar"
                Cal_DayCell["CalendarDayCell"]:::ios
                Cal_DayDetail["CalendarDayDetailView"]:::ios
                Cal_Grid["CalendarGrid"]:::ios
                Cal_Manager["CalendarManager"]:::ios
                Cal_Selection["CalendarSelection"]:::ios
                Cal_MonthYear["MonthYearPickerView"]:::ios
            end
            E_Card["EventCardView"]:::ios
            E_Create["EventCreationView"]:::ios
            E_Detail["EventDetailView"]:::ios
            E_Model["EventModel"]:::ios
            E_Manager["EventsManager"]:::ios
            E_Router["EventsViewRouter"]:::ios
            E_Success["EventRegisteredSuccessSheet"]:::ios
            E_View["EventsView"]:::ios
        end
        subgraph "Home Module"
            H_Router["HomeScreenRouter"]:::ios
            H_View["HomeView"]:::ios
            UP_Edit["UserProfileEditView"]:::ios
            UP_View["UserProfileView"]:::ios
        end
        subgraph "Member Module"
            M_Column["MemberColumnView"]:::ios
            M_Info["MemberInfoSheet"]:::ios
            M_Router["MemberRouter"]:::ios
            M_View["MemberView"]:::ios
            P_View["PromotionView"]:::ios
        end
        subgraph "Utilities"
            U_Cache["CacheManager"]:::ios
            U_Cached["CachedAsyncImage"]:::ios
            U_Search["CustomSearchBar"]:::ios
            U_Helpers["Helpers"]:::ios
            U_Image["ImageCompressor"]:::ios
            U_Color["NAMIColor"]:::ios
            U_Tabs["TabsControl"]:::ios
            U_User["UserManager"]:::ios
        end
        subgraph "App Configuration"
            AC_Info["Info.plist"]:::ios
            AC_Ent["NAMI.entitlements"]:::ios
        end
    end

    subgraph "Firebase Cloud Backend"
        F_Config["Firebase Config"]:::firebase
        F_Auth["Firebase Authentication"]:::firebase
        F_Firestore["Firestore Database"]:::firebase
        F_Storage["Cloud Storage"]:::firebase
        F_Functions["Cloud Functions"]:::firebase
    end

    %% Connections from iOS modules to Firebase Backend
    A_M -->|"auth"| F_Auth
    E_Manager -->|"update"| F_Firestore
    CH_Router -->|"route"| F_Functions
    AC_Info -->|"config"| F_Config

    %% Click Events
    click A_W "https://github.com/changeplusplusvandy/nami/tree/main/NAMI/Authentication"
    click CH_Router "https://github.com/changeplusplusvandy/nami/tree/main/NAMI/Chat/ChatHelpers"
    click CAH "https://github.com/changeplusplusvandy/nami/tree/main/NAMI/Chat/Admins"
    click CR_View "https://github.com/changeplusplusvandy/nami/tree/main/NAMI/Chat/ChatRoom"
    click CU_Request "https://github.com/changeplusplusvandy/nami/tree/main/NAMI/Chat/Users"
    click Cal_Manager "https://github.com/changeplusplusvandy/nami/tree/main/NAMI/Events/Calendar"
    click E_Manager "https://github.com/changeplusplusvandy/nami/tree/main/NAMI/Events"
    click H_View "https://github.com/changeplusplusvandy/nami/tree/main/NAMI/Home"
    click M_Router "https://github.com/changeplusplusvandy/nami/tree/main/NAMI/Member"
    click U_Cache "https://github.com/changeplusplusvandy/nami/tree/main/NAMI/Utilities"
    click AC_Info "https://github.com/changeplusplusvandy/nami/blob/main/NAMI/Info.plist"
    click F_Config "https://github.com/changeplusplusvandy/nami/blob/main/NAMI/GoogleService-Info.plist"

    %% Styles
    classDef ios fill:#e1f5fe,stroke:#0277bd,stroke-width:2px;
    classDef firebase fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
```
