# software-engineering-group-3/crisis-guard architecture

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

- Interactive diagram: https://gitdiagram.com/software-engineering-group-3/crisis-guard
- Repository: https://github.com/software-engineering-group-3/crisis-guard

## Overview

##### Main Components Identification

a) Frontend Layer:
- React-based web application
- OpenStreetMap integration
- OAuth authentication component
- User interface components (Login, Reports, Maps)

b) Backend Layer:
- Spring Boot application
- Security configuration
- Controllers (Login, Place, Report)
- Repository layer
- Model entities (Place, Report, Severity)

c) External Services:
- Firebase Cloud Messaging (for push notifications)
- OAuth provider
- OpenStreetMap services
- Email service (for alerts)

d) Database:
- PostgreSQL database

##### Connection and Data Flow

a) Client-Side Flow:
- User → Frontend (HTTP/HTTPS)
- Frontend → OAuth (Authentication flow)
- Frontend → OpenStreetMap (Map data)

b) Server-Side Flow:
- Frontend → Backend (REST API calls)
- Backend → Database (CRUD operations)
- Backend → Firebase (Push notifications)
- Backend → Email Service (Alert notifications)

##### Detailed Components

a) Frontend Components:
- Login component
- Interface
- Report submission
- Notification handling

b) Backend Components:
- Security layer (SecurityConfig)
- Controllers layer
- Repository layer
- Model layer

##### Additional Elements

Important aspects:

- Load balancers (if applicable)
- API endpoints
- Database tables/relationships
- Caching mechanisms (if implemented)

##### Technical Details

- Spring Boot version
- React version
- Database version
- Protocol specifications (REST, WebSocket)
- Authentication flow
- External API integration points

##### Deployment Information

Deployment-specific details:
- Microsoft Azure hosting
- Heroku deployment endpoints
- Environment-specific configurations

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#dae8fc,stroke:#6c8ebf
    classDef backend fill:#d5e8d4,stroke:#82b366
    classDef database fill:#fff2cc,stroke:#d6b656
    classDef external fill:#f5f5f5,stroke:#666666
    classDef api fill:#ffffff,stroke:#000000
    
    %% Frontend Layer
    subgraph Frontend
        WebApp["React Web Application"]:::frontend
        Login["Login Component"]:::frontend
        Map["Map Interface"]:::frontend
        Reports["Reports Component"]:::frontend
        NotificationHandler["Notification Handler"]:::frontend
    end
    
    %% Backend Layer
    subgraph Backend
        MainApp["Spring Boot Application"]:::backend
        SecurityConfig["Security Configuration"]:::backend
        
        subgraph Controllers
            LoginCtrl["Login Controller"]:::backend
            PlaceCtrl["Place Controller"]:::backend
            ReportCtrl["Report Controller"]:::backend
        end
        
        subgraph Models
            PlaceModel["Place Model"]:::backend
            ReportModel["Report Model"]:::backend
            SeverityModel["Severity Model"]:::backend
        end
        
        subgraph Repositories
            PlaceRepo["Place Repository"]:::backend
            ReportRepo["Report Repository"]:::backend
        end
    end
    
    %% External Services
    OAuth["OAuth Provider"]:::external
    FCM["Firebase Cloud Messaging"]:::external
    OSM["OpenStreetMap Services"]:::external
    EmailService["Email Service"]:::external
    
    %% Database
    DB[(PostgreSQL Database)]:::database
    
    %% Connections
    WebApp --> Login
    WebApp --> Map
    WebApp --> Reports
    WebApp --> NotificationHandler
    
    Login --> LoginCtrl
    Map --> PlaceCtrl
    Reports --> ReportCtrl
    
    LoginCtrl --> SecurityConfig
    PlaceCtrl --> SecurityConfig
    ReportCtrl --> SecurityConfig
    
    LoginCtrl --> OAuth
    Map --> OSM
    
    PlaceCtrl --> PlaceRepo
    ReportCtrl --> ReportRepo
    
    PlaceRepo --> DB
    ReportRepo --> DB
    
    MainApp --> FCM
    MainApp --> EmailService
    
    %% Click Events
    click WebApp "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Frontend/src/app.jsx"
    click Login "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Frontend/src/components/Login.jsx"
    click MainApp "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Backend/src/main/java/com/crisisguard/crisisguard/CrisisguardApplication.java"
    click SecurityConfig "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Backend/src/main/java/com/crisisguard/crisisguard/config/SecurityConfig.java"
    click LoginCtrl "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Backend/src/main/java/com/crisisguard/crisisguard/controller/LoginController.java"
    click PlaceCtrl "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Backend/src/main/java/com/crisisguard/crisisguard/controller/PlaceController.java"
    click ReportCtrl "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Backend/src/main/java/com/crisisguard/crisisguard/controller/ReportController.java"
    click PlaceModel "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Backend/src/main/java/com/crisisguard/crisisguard/models/Place.java"
    click ReportModel "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Backend/src/main/java/com/crisisguard/crisisguard/models/Report.java"
    click SeverityModel "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Backend/src/main/java/com/crisisguard/crisisguard/models/Severity.java"
    click PlaceRepo "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Backend/src/main/java/com/crisisguard/crisisguard/repository/PlaceRepository.java"
    click ReportRepo "https://github.com/software-engineering-group-3/crisis-guard/blob/master/SourceCode/Backend/src/main/java/com/crisisguard/crisisguard/repository/ReportRepository.java"
```
