# xamuel17/siyp--whisperv2-backend architecture

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

- Interactive diagram: https://gitdiagram.com/xamuel17/siyp--whisperv2-backend
- Repository: https://github.com/xamuel17/siyp--whisperv2-backend

## Overview

##### Main Components

a. Client Layer:
- Web Interface (Admin Dashboard)
- Mobile Application Interface

b. API Layer:
- REST API endpoints (shown in routes/api.php)
- Authentication/Authorization middleware

c. Core Services:
- User Management Service
- Emergency/Distress Service
- Community Service
- Guardian Service
- Volunteer Service
- Tracking Service
- Notification Service

d. Data Layer:
- Database (MySQL/PostgreSQL)
- File Storage (for images/videos/audio)
- Cache Layer

##### Component Relationships

- Client → API Layer (REST calls)
- API Layer → Core Services (internal calls)
- Core Services → Data Layer (data persistence)
- Core Services ↔ Other Services (inter-service communication)

##### Special Components to Highlight

a. Security Layer:
- Fortify authentication
- Sanctum API tokens
- Role-based access control

b. Communication Systems:
- Email notifications (PHPMailer)
- Push notifications (OneSignal)
- Real-time updates

c. File Handling:
- Media storage for distress messages
- User uploads
- Community content

##### Architectural Patterns

- MVC pattern (Controllers, Models, Views)
- Service-based architecture
- Repository pattern for data access
- Event-driven communication for notifications

##### External Integrations

- Email service
- Push notification service
- Geographic services (for tracking)

##### Key Workflows to Illustrate

- Distress message handling
- Emergency response coordination
- Community interaction flow
- Guardian-user relationship

##### Additional Elements

- Component types
- Security boundaries

##### Infrastructure Layer (Optional)

Deployment-related components:
- Web server
- Queue workers
- Cache server
- Storage services

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Clients
        WebUI["Web Interface\n(Admin Dashboard)"]:::client
        MobileApp["Mobile Application\nInterface"]:::client
    end

    %% API Gateway Layer
    subgraph API
        APIGateway["REST API Gateway"]:::api
        Auth["Authentication/\nAuthorization"]:::security
        click Auth "https://github.com/xamuel17/SIYP--WhisperV2-Backend/blob/main/app/Http/Middleware/Authenticate.php"
        Fortify["Laravel Fortify"]:::security
        click Fortify "https://github.com/xamuel17/SIYP--WhisperV2-Backend/tree/main/app/Actions/Fortify/"
    end

    %% Core Services Layer
    subgraph Services
        UserMgmt["User Management\nService"]:::service
        click UserMgmt "https://github.com/xamuel17/SIYP--WhisperV2-Backend/blob/main/app/Http/Controllers/UserController.php"
        
        EmergencyService["Emergency/Distress\nService"]:::service
        click EmergencyService "https://github.com/xamuel17/SIYP--WhisperV2-Backend/blob/main/app/Http/Controllers/EmergencyController.php"
        
        CommunityService["Community\nService"]:::service
        click CommunityService "https://github.com/xamuel17/SIYP--WhisperV2-Backend/blob/main/app/Http/Controllers/CommunityController.php"
        
        GuardianService["Guardian\nService"]:::service
        click GuardianService "https://github.com/xamuel17/SIYP--WhisperV2-Backend/blob/main/app/Http/Controllers/GuardianController.php"
        
        VolunteerService["Volunteer\nService"]:::service
        click VolunteerService "https://github.com/xamuel17/SIYP--WhisperV2-Backend/blob/main/app/Http/Controllers/VolunteerController.php"
        
        TrackingService["Tracking\nService"]:::service
        click TrackingService "https://github.com/xamuel17/SIYP--WhisperV2-Backend/blob/main/app/Http/Controllers/TrackController.php"
        
        NotificationService["Notification\nService"]:::service
        click NotificationService "https://github.com/xamuel17/SIYP--WhisperV2-Backend/blob/main/app/Http/Controllers/NotificationsController.php"
    end

    %% Communication Systems
    subgraph Communication
        EmailService["Email Service"]:::external
        click EmailService "https://github.com/xamuel17/SIYP--WhisperV2-Backend/blob/main/app/Mail/DistressMail.php"
        PushNotif["Push Notifications\n(OneSignal)"]:::external
        click PushNotif "https://github.com/xamuel17/SIYP--WhisperV2-Backend/blob/main/app/Notifications/PushNotification.php"
    end

    %% Data Layer
    subgraph Storage
        DB[(Database)]:::storage
        FileStorage["File Storage"]:::storage
        click FileStorage "https://github.com/xamuel17/SIYP--WhisperV2-Backend/tree/main/public/distress-photo/"
        Cache[(Cache)]:::storage
    end

    %% Relationships
    WebUI --> APIGateway
    MobileApp --> APIGateway
    APIGateway --> Auth
    Auth --> Fortify
    APIGateway --> Services

    UserMgmt --> DB
    EmergencyService --> DB
    CommunityService --> DB
    GuardianService --> DB
    VolunteerService --> DB
    TrackingService --> DB
    NotificationService --> DB

    EmergencyService --> FileStorage
    UserMgmt --> FileStorage
    VolunteerService --> FileStorage

    NotificationService --> EmailService
    NotificationService --> PushNotif

    %% Styles
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef storage fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        Client["Client Interface"]:::client
        APIComp["API Component"]:::api
        ServiceComp["Core Service"]:::service
        SecurityComp["Security Component"]:::security
        StorageComp["Storage"]:::storage
        ExternalComp["External Service"]:::external
    end
```
