# ivanpastorcic/letecimedvjedici architecture

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

## Overview

##### Main Components

a) Frontend Layer:
- React.js application structure with key components:
- User Interface Components (Anonymous, Login, Register)
- Feature Components (Report, AidActions, ResourceRequests)
- Page Components (HomePage, MapPage, ProfilePage)

b) Backend Layer:
- Spring Boot application with:
- Controllers (ActionController, ReportController, etc.)
- Services Layer
- Repository Layer
- Security Components (OAuth2)

c) Database Layer:
- H2 Database with main entities:
- Users (AppUser, HumanitarianOrganization)
- Disaster Management (Report, NaturalDisaster)
- Location Data (County, Settlement)
- Resources and Needs (Action, Need, Resource)

##### Key Interactions to Highlight

a) User Flows:
- Anonymous disaster reporting path
- Authenticated user reporting path
- Humanitarian organization resource management
- Administrative oversight and verification

b) Data Flows:
- Report submission and verification process
- Notification system
- Resource allocation and management
- Location-based services

**[Frontend Layer]**

- (REST API/OAuth2)
- v
**[Backend Layer]**

- (JPA/Hibernate)
- v
**[Database Layer]**

##### Component Relationships

- Frontend components and their corresponding backend controllers
- Controllers and services
- Services and repositories
- Cross-cutting concerns (security, notifications)

##### Architectural Patterns to Emphasize

- MVC pattern in the frontend
- Service-oriented architecture in the backend
- Repository pattern for data access
- Observer pattern for notifications

Remember to highlight the key functional requirements from the README, such as:
- Interactive map functionality
- Real-time notifications
- Resource management
- User role management
- Location-based services
- Anonymous reporting capabilities

This system design should reflect the comprehensive nature of the application while maintaining clarity about how different components interact to fulfill the core mission of crisis management and response coordination.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef security fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#e67e22,stroke:#d35400,color:white
    classDef api fill:#9b59b6,stroke:#8e44ad,color:white

    %% Frontend Layer
    subgraph Frontend
        UI[UI Components]
        UI --> Anonymous["Anonymous Component"]:::frontend
        UI --> Login["Login Component"]:::frontend
        UI --> Register["Register Component"]:::frontend
        UI --> Report["Report Component"]:::frontend
        UI --> AidActions["Aid Actions Component"]:::frontend
        UI --> ResourceReq["Resource Requests"]:::frontend

        Pages[Pages]
        Pages --> Home["Home Page"]:::frontend
        Pages --> Map["Map Page"]:::frontend
        Pages --> Profile["Profile Page"]:::frontend
    end

    %% Backend Layer
    subgraph Backend
        Controllers[Controllers]
        Controllers --> ActionCtrl["Action Controller"]:::backend
        Controllers --> ReportCtrl["Report Controller"]:::backend
        Controllers --> LocationCtrl["Location Controller"]:::backend

        Services[Services]
        Services --> ActionSvc["Action Service"]:::backend
        Services --> ReportSvc["Report Service"]:::backend
        Services --> OAuth2Svc["OAuth2 Service"]:::security

        Security[Security Components]
        Security --> SecConfig["Security Config"]:::security
        Security --> WebConfig["Web Config"]:::security

        Models[Data Models]
        Models --> UserModel["User Model"]:::backend
        Models --> ReportModel["Report Model"]:::backend
        Models --> DisasterModel["Natural Disaster Model"]:::backend
        Models --> LocationModel["Location Model"]:::backend
    end

    %% Database Layer
    subgraph Database
        H2DB[(H2 Database)]:::database
        DBConfig["Database Config"]:::database
    end

    %% Relationships
    Frontend --> |REST API/OAuth2| Backend
    Backend --> |JPA/Hibernate| Database

    %% Click Events
    click Anonymous "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/src/components/Anonymous/Anonymous.js"
    click Login "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/src/components/Login/Login.js"
    click Register "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/src/components/Register/Register.js"
    click Report "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/src/components/Report/ReportComponent.js"
    click AidActions "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/src/components/AidActions/AidActions.js"
    click ResourceReq "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/src/components/ResourceRequests/ResourceRequests.js"
    click Home "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/src/pages/HomePage/HomePage.js"
    click Map "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/src/pages/MapPage/MapPage.js"
    click Profile "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/src/pages/ProfilePage/ProfilePage.js"
    click ActionCtrl "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/controller/ActionController.java"
    click ReportCtrl "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/controller/ReportController.java"
    click LocationCtrl "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/controller/LocationController.java"
    click ActionSvc "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/service/ActionService.java"
    click ReportSvc "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/service/ReportService.java"
    click OAuth2Svc "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/service/OAuth2Service.java"
    click SecConfig "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/security/SecurityConfig.java"
    click WebConfig "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/security/WebConfig.java"
    click UserModel "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/model/AppUser.java"
    click ReportModel "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/model/Report.java"
    click DisasterModel "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/model/NaturalDisaster.java"
    click LocationModel "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/java/hr/fer/progi/backend/model/Location.java"
    click DBConfig "https://github.com/IvanPastorcic/LeteciMedvjedici/blob/main/IzvorniKod/backend/src/main/resources/application.properties"
    click H2DB "https://github.com/IvanPastorcic/LeteciMedvjedici/tree/main/IzvorniKod/backend/db/"
```
