# ohtarr/whereuat architecture

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

- Interactive diagram: https://gitdiagram.com/ohtarr/whereuat
- Repository: https://github.com/ohtarr/whereuat

## Overview

##### Main Components

a) Core Application Layer:
- Main service providers and bootstrapping components
- Console commands system for synchronization tasks

b) Data Management Layer:
- Database layer showing the relationships between key entities:
- Buildings
- Sites
- Rooms
- Addresses
- E911-related entities (E911, E911Erl, E911Switch)
- Teams-related entities (TeamsCivic, TeamsLocation, TeamsSubnet)

c) External Integration Services:
- Microsoft Teams E911 Service
- Intrado/West Corporation E911 Gateway
- ServiceNow Integration (evident from ServiceNowLocation and ServiceNowUser models)

d) API Layer:
- REST API endpoints (from the API controllers)
- Authentication/Authorization layer (Sanctum)

##### Component Relationships

- Synchronization flow between external services and the core application
- Data flow between API endpoints and the database
- Command execution paths for various sync operations
- Integration points between Microsoft Teams and E911 Gateway

##### Specific Implementation Details

- Blue rectangles for core application components
- Green rectangles for external services
- Yellow diamonds for API endpoints
- Purple rectangles for sync commands

b) Specific sections for:
- Collection classes (showing data aggregation)
- Query classes (showing data retrieval patterns)
- Model relationships
- Command scheduling and execution flow

##### Technical Stack Indicators

Technology badges/labels for:
- Laravel Framework
- MySQL/Database
- API Authentication (Sanctum)
- Frontend components (Tailwind CSS)

##### Data Flow Visualization

- Bidirectional sync between Teams and E911 systems
- Data flow from external services to local database
- API request/response paths
- Command execution flows

##### Architectural Patterns

Following patterns in use:
- MVC architecture (Controllers, Models, Views)
- Repository pattern (Collections and Queries)
- Command pattern (Console Commands)
- REST API architecture

##### Integration Points

Integration points for:
- Microsoft Teams E911
- Intrado/West E911 Gateway
- ServiceNow
- Any other external services

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        AppCore["Laravel Core"]:::core
        ServiceProvider["Service Provider"]:::core
        Bootstrap["Application Bootstrap"]:::core
        Commands["Console Commands"]:::core
    end

    subgraph "Data Layer"
        DB[(Database)]:::database
        subgraph "Models"
            Building["Building Model"]:::model
            Site["Site Model"]:::model
            Room["Room Model"]:::model
            Address["Address Model"]:::model
            E911["E911 Model"]:::model
            E911Erl["E911 ERL Model"]:::model
            E911Switch["E911 Switch Model"]:::model
        end
    end

    subgraph "External Services"
        Teams["Microsoft Teams E911"]:::external
        Intrado["Intrado/West E911"]:::external
        ServiceNow["ServiceNow"]:::external
    end

    subgraph "API Layer"
        APIControllers["API Controllers"]:::api
        Auth["Authentication/Sanctum"]:::api
        Routes["API Routes"]:::api
    end

    subgraph "Collections & Queries"
        AddressCol["Address Collection"]:::collection
        BuildingCol["Building Collection"]:::collection
        SiteCol["Site Collection"]:::collection
        RoomCol["Room Collection"]:::collection
        AddressQ["Address Query"]:::query
        BuildingQ["Building Query"]:::query
        SiteQ["Site Query"]:::query
        RoomQ["Room Query"]:::query
    end

    subgraph "Sync Commands"
        SyncAll["Sync All Command"]:::command
        SyncE911["E911 Sync Command"]:::command
        SyncLoc["Location Sync Command"]:::command
        SyncBuild["Building Sync Command"]:::command
    end

    %% Relationships
    AppCore --> ServiceProvider
    AppCore --> Bootstrap
    AppCore --> Commands
    
    Commands --> SyncAll
    Commands --> SyncE911
    Commands --> SyncLoc
    Commands --> SyncBuild

    APIControllers --> Auth
    APIControllers --> Routes
    
    Building --> DB
    Site --> DB
    Room --> DB
    Address --> DB
    E911 --> DB
    E911Erl --> DB
    E911Switch --> DB

    Teams --> SyncAll
    Intrado --> SyncE911
    ServiceNow --> SyncLoc

    AddressCol --> Address
    BuildingCol --> Building
    SiteCol --> Site
    RoomCol --> Room

    AddressQ --> DB
    BuildingQ --> DB
    SiteQ --> DB
    RoomQ --> DB

    %% Click Events
    click ServiceProvider "https://github.com/ohtarr/whereuat/blob/master/app/Providers/AppServiceProvider.php"
    click Commands "https://github.com/ohtarr/whereuat/tree/master/app/Console/Commands/"
    click Bootstrap "https://github.com/ohtarr/whereuat/blob/master/bootstrap/app.php"
    click Building "https://github.com/ohtarr/whereuat/blob/master/app/Models/Building.php"
    click Site "https://github.com/ohtarr/whereuat/blob/master/app/Models/Site.php"
    click Room "https://github.com/ohtarr/whereuat/blob/master/app/Models/Room.php"
    click Address "https://github.com/ohtarr/whereuat/blob/master/app/Models/Address.php"
    click E911 "https://github.com/ohtarr/whereuat/blob/master/app/Models/E911.php"
    click E911Erl "https://github.com/ohtarr/whereuat/blob/master/app/Models/E911Erl.php"
    click E911Switch "https://github.com/ohtarr/whereuat/blob/master/app/Models/E911Switch.php"
    click APIControllers "https://github.com/ohtarr/whereuat/tree/master/app/Http/Controllers/API/"
    click Auth "https://github.com/ohtarr/whereuat/blob/master/config/sanctum.php"
    click Routes "https://github.com/ohtarr/whereuat/blob/master/routes/api.php"
    click AddressCol "https://github.com/ohtarr/whereuat/blob/master/app/Collections/AddressCollection.php"
    click BuildingCol "https://github.com/ohtarr/whereuat/blob/master/app/Collections/BuildingCollection.php"
    click SiteCol "https://github.com/ohtarr/whereuat/blob/master/app/Collections/SiteCollection.php"
    click RoomCol "https://github.com/ohtarr/whereuat/blob/master/app/Collections/RoomCollection.php"
    click AddressQ "https://github.com/ohtarr/whereuat/blob/master/app/Queries/AddressQuery.php"
    click BuildingQ "https://github.com/ohtarr/whereuat/blob/master/app/Queries/BuildingQuery.php"
    click SiteQ "https://github.com/ohtarr/whereuat/blob/master/app/Queries/SiteQuery.php"
    click RoomQ "https://github.com/ohtarr/whereuat/blob/master/app/Queries/RoomQuery.php"
    click SyncAll "https://github.com/ohtarr/whereuat/blob/master/app/Console/Commands/SyncAll.php"
    click SyncE911 "https://github.com/ohtarr/whereuat/blob/master/app/Console/Commands/SyncE911Erls.php"
    click SyncLoc "https://github.com/ohtarr/whereuat/blob/master/app/Console/Commands/SyncServiceNowLocations.php"
    click SyncBuild "https://github.com/ohtarr/whereuat/blob/master/app/Console/Commands/SyncBuildings.php"

    %% Styling
    classDef core fill:#b3e0ff,stroke:#333,stroke-width:2px
    classDef model fill:#ffcc99,stroke:#333,stroke-width:2px
    classDef database fill:#ff9999,stroke:#333,stroke-width:2px
    classDef external fill:#99ff99,stroke:#333,stroke-width:2px
    classDef api fill:#ffff99,stroke:#333,stroke-width:2px
    classDef collection fill:#cc99ff,stroke:#333,stroke-width:2px
    classDef query fill:#ff99cc,stroke:#333,stroke-width:2px
    classDef command fill:#99ccff,stroke:#333,stroke-width:2px
```
