# ashawe/safana architecture

> Architecture diagram of the GitHub repository ashawe/safana, 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/ashawe/safana
- Repository: https://github.com/ashawe/safana

## Overview

##### Project Type and Purpose
- The project is an Android application built using Java. Its purpose is to manage employees, tasks, projects, leaves, allowances, and other aspects of workforce and project management.
- The README clarifies that the app has distinct interfaces for workers (employees) and supervisors, with features like task assignment, employee management, project analysis, and leave/allowance functionalities.
- That the project uses Firebase as its cloud database—this is key in illustrating backend data management.

##### Analyzing the File Structure
- The primary code resides under the “app” directory with the standard Android structure. Look at the following major directories:
- app/src/main/java/com/ashstudios/safana/activities: Contains all the activities (screens) such as Login, Dashboard (worker and supervisor), Splash, etc.
- app/src/main/java/com/ashstudios/safana/Fragments and app/src/main/java/com/ashstudios/safana/ui: These directories include UI fragments and ViewModels, indicating the use of UI separation (suggesting an MVVM or similar design pattern).
- app/src/main/java/com/ashstudios/safana/adapters, models, and others: These provide data handling, presentation adapters, and utility classes.
- The “res” directory contains layouts, menus, drawable assets, and navigation resources that show how the UI and navigation views (e.g., drawers, bottom sheets) are structured.
- Build files (build.gradle, settings.gradle, etc.) and configuration files (google-services.json) indicate integration with Firebase and Android build tooling.

##### Key Components
- Worker Side: Dashboard, Profile, Tasks, Calendar, Leave, Allowances, etc.
- Supervisor Side: Dashboard, Worker Details, New Project creation, Employee management, Leave management, Project Status, etc.
- Data Layer: Represent Firebase as the backend database where all user data, project details, tasks, leaves, and allowances are managed.
- Architectural Patterns:
- The use of adapters and models shows a separation between data representation and UI components.
- External Libraries and Tools:
- Picasso, CalendarView, Pie Charts, and TextDrawable are used for image loading, calendar functionalities, charting for statistics, and dynamic text images respectively.
- Navigation & Communication:
- The system utilizes multiple navigation resources (likely using drawer navigation and bottom sheets) as evidenced by the navigation XML files and fragment layouts.
- The directional flow from login screens → dashboards → feature-specific activities (e.g., Create Task, Edit Profile) should be depicted.

##### Relationships and Interactions
- Internal component relationships, for example:
- Activities hosting Fragments (e.g., SupervisorDashboard leading to fragments for project details or leave management).
- ViewModels binding with their related Fragments to update UI based on changes.
- Adapters providing lists for RecyclerViews in various features (tasks, allowances, etc.).

##### Being Detailed
- Create as many components as possible to reflect the multiple features (like individual fragments for “Calendar”, “Leave”, “Allowances”, etc.).
- Even seemingly small utilities (like the “SharedPref” for managing shared preferences) if it helps with understanding data persistence.
- Don’t shy away from mapping out the navigation structure if it helps explain how a user transitions from one feature area to another.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        A1("Android Activities"):::activities
        A2("UI Fragments"):::fragments
        A3("UI ViewModels"):::viewmodels
        A4("Navigation Resources"):::nav
    end

    %% Business Logic & Data Layer
    subgraph "Business Logic & Data Layer"
        B1("Adapters"):::business
        B2("Data Models"):::business
        B3("Utility Classes"):::business
    end

    %% Backend/Data Store
    subgraph "Backend/Data Store"
        C1("Firebase Cloud Database"):::backend
    end

    %% External Libraries
    subgraph "External Libraries"
        E1("Picasso"):::external
        E2("CalendarView"):::external
        E3("Pie Charts"):::external
        E4("TextDrawable"):::external
    end

    %% Connections within Presentation Layer
    A1 -->|"navigates"| A2
    A1 -->|"navigates"| A3
    A1 -->|"accesses"| A4
    A2 -->|"bindsTo"| A3

    %% Connections between Presentation Layer and Business Logic
    A3 -->|"fetchesData"| B1

    %% Connections within Business Logic & Data Layer
    B1 -->|"processes"| B2
    B2 -->|"utilizes"| B3
    B2 -->|"storesData"| C1

    %% External Libraries integration
    A1 -->|"integrates"| E1
    A2 -->|"integrates"| E2
    B1 -->|"integrates"| E3
    B3 -->|"integrates"| E4

    %% Click Events for Component Mapping
    click A1 "https://github.com/ashawe/safana/tree/master/app/src/main/java/com/ashstudios/safana/activities"
    click A2 "https://github.com/ashawe/safana/tree/master/app/src/main/java/com/ashstudios/safana/Fragments"
    click A3 "https://github.com/ashawe/safana/tree/master/app/src/main/java/com/ashstudios/safana/ui"
    click B1 "https://github.com/ashawe/safana/tree/master/app/src/main/java/com/ashstudios/safana/adapters"
    click B2 "https://github.com/ashawe/safana/tree/master/app/src/main/java/com/ashstudios/safana/models"
    click B3 "https://github.com/ashawe/safana/tree/master/app/src/main/java/com/ashstudios/safana/others"
    click C1 "https://github.com/ashawe/safana/blob/master/app/google-services.json"
    click A4 "https://github.com/ashawe/safana/tree/master/app/src/main/res/layout"

    %% Styles
    classDef activities fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef fragments fill:#87cefa,stroke:#000,stroke-width:2px;
    classDef viewmodels fill:#b0e0e6,stroke:#000,stroke-width:2px;
    classDef business fill:#98fb98,stroke:#000,stroke-width:2px;
    classDef backend fill:#ffa07a,stroke:#000,stroke-width:2px;
    classDef nav fill:#ffdead,stroke:#000,stroke-width:2px;
    classDef external fill:#d3d3d3,stroke:#000,stroke-width:2px;
```
