# liam-dev96/secw architecture

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

- Interactive diagram: https://gitdiagram.com/liam-dev96/secw
- Repository: https://github.com/liam-dev96/secw

## Overview

##### Project type and purpose
- SECW is a cross-platform client application built with .NET MAUI.
- It targets mobile (Android, iOS, Tizen) and desktop (Windows, MacCatalyst).
- Purpose: a role‐based environment monitoring and management app. It handles user authentication (login/signup), user management (Admin operations), sensor data interaction, and local data persistence in SQLite.

##### File structure
- Root files: App.xaml(.cs), AppShell.xaml(.cs) (Shell navigation), MauiProgram.cs (DI & service registration).
- XAML UI pages & code-behind: Login, AdminPage, AdminSettingsPage, ManageUsers, EditUserPage, EnvironmentalScientist, OperationalManager.
- Helpers folder: DatabaseHelper.cs (SQLite CRUD), SensorsHelper.cs (sensor APIs), NullToBoolConverter.cs (UI converter), Password Hasher.py (prototype).
- Platforms: per-OS entry points/manifests under Platforms/{Android, iOS, MacCatalyst, Tizen, Windows}.
- Config & dependencies: SECW.csproj, packages.txt, launchSettings.json.

##### README for additional insights
- Uses Microsoft.Data.Sqlite for local DB.
- Bcrypt (via NuGet) for password hashing; DataAnnotations for validation.
- Docfx chosen for automated HTML docs from XML comments.
- Commands to restore .NET workloads, install Android workload, add packages, and generate docs.

##### Detail
– Show AppShell as the navigation root connecting pages.
– Illustrate the platform projects all pointing to the shared code.
– On the side, show Docfx consuming XML comments and producing documentation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Platform Host Layer
    subgraph "Platform Host Layer"
        direction TB
        Android["Android Project"]:::platform
        IOS["iOS Project"]:::platform
        MacCatalyst["MacCatalyst Project"]:::platform
        Tizen["Tizen Project"]:::platform
        Windows["Windows Project"]:::platform
    end

    Android -->|boots shared MAUI runtime| Shared[".NET MAUI Shared Code"]
    IOS -->|boots shared MAUI runtime| Shared
    MacCatalyst -->|boots shared MAUI runtime| Shared
    Tizen -->|boots shared MAUI runtime| Shared
    Windows -->|boots shared MAUI runtime| Shared

    %% Shared Code Layer
    subgraph "MAUI Shared Code" 
        direction TB

        %% Application Entry & DI
        subgraph "Bootstrap & Navigation"
            direction TB
            AppXaml["App.xaml/.cs"]:::service
            MauiProg["MauiProgram.cs"]:::service
            AppShell["AppShell.xaml/.cs"]:::ui
        end

        AppXaml -->|start| MauiProg
        MauiProg -->|register services| DatabaseHelper
        AppShell -->|navigates| LoginPage
        AppShell -->|navigates| AdminPage

        %% Presentation Layer
        subgraph "Presentation Layer"
            direction TB
            LoginPage["Login Page"]:::ui
            AdminPage["Admin Page"]:::ui
            AdminSettings["AdminSettings Page"]:::ui
            ManageUsers["ManageUsers Page"]:::ui
            EditUser["EditUser Page"]:::ui
            EnvSci["EnvironmentalScientist Page"]:::ui
            OpManager["OperationalManager Page"]:::ui
        end

        %% Business Logic Layer
        subgraph "Business Logic Layer"
            direction TB
            DatabaseHelper["DatabaseHelper"]:::service
            SensorsHelper["SensorsHelper"]:::service
            NullToBool["NullToBoolConverter"]:::service
        end

        %% Data Layer
        subgraph "Data Layer"
            direction TB
            SQLiteDB[(SQLite Database)]:::db
        end

        %% Resources & Styling
        subgraph "Resources & Styling"
            direction TB
            Styles["Styles.xaml"]:::service
            Colors["Colors.xaml"]:::service
            AppIcon["Resources/AppIcon"]:::service
        end

        %% Configuration & Dependencies
        subgraph "Config & Dependencies"
            direction TB
            CSProj["SECW.csproj"]:::service
            LaunchSettings["launchSettings.json"]:::service
            Packages["packages.txt"]:::service
        end

        %% Interactions
        LoginPage -->|uses| SensorsHelper
        LoginPage -->|uses| DatabaseHelper
        AdminPage -->|uses| DatabaseHelper
        AdminSettings -->|uses| DatabaseHelper
        ManageUsers -->|uses| DatabaseHelper
        EditUser -->|uses| DatabaseHelper
        EnvSci -->|uses| SensorsHelper
        OpManager -->|uses| SensorsHelper

        DatabaseHelper -->|CRUD operations| SQLiteDB
        SensorsHelper -->|access sensor APIs| ExternalSensors[sensor APIs]:::external

    end

    %% Documentation Pipeline
    subgraph "Documentation Pipeline"
        direction TB
        XMLComments["XML Comments in Code"]:::external
        Docfx["Docfx"]:::external
        HTMLSite["_site (HTML)"]:::external
    end

    Shared -->|contains XML comments| XMLComments
    XMLComments -->|generate docs| Docfx
    Docfx -->|outputs| HTMLSite

    %% Click Events
    click AppShell "https://github.com/liam-dev96/secw/blob/master/AppShell.xaml"
    click AppShell "https://github.com/liam-dev96/secw/blob/master/AppShell.xaml.cs"
    click LoginPage "https://github.com/liam-dev96/secw/blob/master/Login.xaml"
    click LoginPage "https://github.com/liam-dev96/secw/blob/master/Login.xaml.cs"
    click AdminPage "https://github.com/liam-dev96/secw/blob/master/AdminPage.xaml"
    click AdminPage "https://github.com/liam-dev96/secw/blob/master/AdminPage.xaml.cs"
    click AdminSettings "https://github.com/liam-dev96/secw/blob/master/AdminSettingsPage.xaml"
    click AdminSettings "https://github.com/liam-dev96/secw/blob/master/AdminSettingsPage.xaml.cs"
    click ManageUsers "https://github.com/liam-dev96/secw/blob/master/ManageUsers.xaml"
    click ManageUsers "https://github.com/liam-dev96/secw/blob/master/ManageUsers.xaml.cs"
    click EditUser "https://github.com/liam-dev96/secw/blob/master/EditUserPage.xaml"
    click EditUser "https://github.com/liam-dev96/secw/blob/master/EditUserPage.xaml.cs"
    click EnvSci "https://github.com/liam-dev96/secw/blob/master/EnvironmentalScientist.xaml"
    click EnvSci "https://github.com/liam-dev96/secw/blob/master/EnvironmentalScientist.xaml.cs"
    click OpManager "https://github.com/liam-dev96/secw/blob/master/OperationalManager.xaml"
    click OpManager "https://github.com/liam-dev96/secw/blob/master/OperationalManager.xaml.cs"
    click DatabaseHelper "https://github.com/liam-dev96/secw/blob/master/Helpers/DatabaseHelper.cs"
    click SensorsHelper "https://github.com/liam-dev96/secw/blob/master/Helpers/SensorsHelper.cs"
    click NullToBool "https://github.com/liam-dev96/secw/blob/master/Helpers/NullToBoolConverter.cs"
    click MauiProg "https://github.com/liam-dev96/secw/blob/master/MauiProgram.cs"
    click AppXaml "https://github.com/liam-dev96/secw/blob/master/App.xaml"
    click AppXaml "https://github.com/liam-dev96/secw/blob/master/App.xaml.cs"
    click CSProj "https://github.com/liam-dev96/secw/blob/master/SECW.csproj"
    click Android "https://github.com/liam-dev96/secw/blob/master/Platforms/Android/MainActivity.cs"
    click Android "https://github.com/liam-dev96/secw/blob/master/Platforms/Android/MainApplication.cs"
    click Android "https://github.com/liam-dev96/secw/blob/master/Platforms/Android/AndroidManifest.xml"
    click IOS "https://github.com/liam-dev96/secw/blob/master/Platforms/iOS/Program.cs"
    click IOS "https://github.com/liam-dev96/secw/blob/master/Platforms/iOS/AppDelegate.cs"
    click IOS "https://github.com/liam-dev96/secw/blob/master/Platforms/iOS/Info.plist"
    click MacCatalyst "https://github.com/liam-dev96/secw/blob/master/Platforms/MacCatalyst/Program.cs"
    click MacCatalyst "https://github.com/liam-dev96/secw/blob/master/Platforms/MacCatalyst/AppDelegate.cs"
    click MacCatalyst "https://github.com/liam-dev96/secw/blob/master/Platforms/MacCatalyst/Info.plist"
    click Tizen "https://github.com/liam-dev96/secw/blob/master/Platforms/Tizen/Main.cs"
    click Tizen "https://github.com/liam-dev96/secw/blob/master/Platforms/Tizen/tizen-manifest.xml"
    click Windows "https://github.com/liam-dev96/secw/blob/master/Platforms/Windows/App.xaml"
    click Windows "https://github.com/liam-dev96/secw/blob/master/Platforms/Windows/App.xaml.cs"
    click Windows "https://github.com/liam-dev96/secw/blob/master/Platforms/Windows/Package.appxmanifest"
    click Styles "https://github.com/liam-dev96/secw/blob/master/Resources/Styles/Styles.xaml"
    click Colors "https://github.com/liam-dev96/secw/blob/master/Resources/Styles/Colors.xaml"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFE5B4,stroke:#333,stroke-width:1px
    classDef platform fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
```
