# iqbalsiagian17/sistem-pelaporan-lingkungan architecture

> Architecture diagram of the GitHub repository iqbalsiagian17/sistem-pelaporan-lingkungan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iqbalsiagian17/sistem-pelaporan-lingkungan
- Repository: https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan

## Overview

##### Project Type and Purpose
- This is a full-stack, multi-platform reporting system (“sistem-pelaporan-lingkungan”) comprising three main deliverables:
- A cross-platform mobile app (bb_mobile) built with Flutter/Dart
- A web-based dashboard/admin SPA (spl_web) built with React/Vite
- A RESTful backend service (web-service) built with Node.js/Express and Sequelize
- Its purpose is to allow users to submit environmental reports (with photos, videos, location), interact via forums, and for admins to manage content, view analytics, and send notifications.

##### High-Level Components
- Mobile App (bb_mobile)
- Presentation layer: Flutter widgets (features/*/presentation)
- Domain layer: entities, repositories, use-cases (clean architecture)
- Data layer: remote data sources, models, services (API calls via Dio, Firebase messaging)
- Web SPA (spl_web)
- UI components: atoms, molecules, pages under src/components and src/pages
- State management: React Contexts under src/context
- Services: API wrappers under src/services
- Routing: Vite router under src/router
- Backend API (web-service)
- Routes layer: Express routers under routes/*
- Controllers: request handlers under controllers/*
- Services: business logic under services/*
- Data layer: Sequelize models under models/* and migrations/seeders
- Middleware: auth, rate limiting, file uploads under middleware/*
- Scheduler: cron jobs under scheduler/*

##### Data Flow and Interactions
- Mobile App & Web SPA → HTTP(S) REST calls → Backend API
- Backend API → ORM (Sequelize) → Database (e.g., PostgreSQL)
- Backend API ↔ Firebase Admin SDK for messaging and OTP verification
- Scheduler jobs ←→ Backend API services to auto-close campaigns, send notifications, clean up inactive users
- File uploads: Mobile App uploads evidence/media via API endpoints → stored in web-service/uploads

##### Architectural Patterns & Design Principles
- Mobile App: Clean Architecture with clear separation of presentation, domain, data
- Web SPA: Component-based architecture with Context API for state, service layer abstracts HTTP
- Backend: MVC-inspired structure (Routes → Controllers → Services → Models)
- Reusable layers: common error handling, interceptors (Dio interceptors on mobile, middleware in backend)
- Use-case driven design: each feature encapsulated by domain/usecase on mobile and service functions on backend

##### Technologies & Frameworks
- Flutter/Dart, Dio, Provider, Firebase Messaging (Mobile)
- React, Vite, Context API, Axios (or fetchWithAuth), SCSS, Bootstrap (Web SPA)
- Node.js, Express, Sequelize (ORM), PostgreSQL (Database), Firebase Admin SDK, cron (Scheduler)

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend: Mobile App
    subgraph "Mobile App (bb_mobile)" 
        direction TB
        MA_Main["main.dart"]:::frontend
        MA_Inj["injection.dart"]:::frontend
        MA_Routes["app_routes.dart"]:::frontend
        MA_Pres["Presentation Layer"]:::frontend
        MA_Dom["Domain Layer"]:::frontend
        MA_Data["Data Layer"]:::frontend
        MA_Core["Core Services & Utils"]:::frontend
    end

    %% Frontend: Web SPA
    subgraph "Web SPA (spl_web)" 
        direction TB
        WS_Main["main.jsx"]:::frontend
        WS_App["App.jsx"]:::frontend
        WS_Routes["AppRoutes.jsx"]:::frontend
        WS_Prot["ProtectedRoute.jsx"]:::frontend
        WS_Comp["UI Components"]:::frontend
        WS_CTX["State Management (Contexts)"]:::frontend
        WS_Svc["Service Layer"]:::frontend
    end

    %% Backend API
    subgraph "Backend API (web-service)" 
        direction TB
        BE_Server["server.js"]:::backend
        BE_Conf["config"]:::backend
        BE_Routes["Routes"]:::backend
        BE_Controllers["Controllers"]:::backend
        BE_Services["Services"]:::backend
        BE_Models["Sequelize Models"]:::backend
        BE_MigSeed["Migrations & Seeders"]:::backend
        BE_Mw["Middleware"]:::backend
        BE_Uploads["File Storage"]:::backend
    end

    %% Database
    subgraph "Database (PostgreSQL)" 
        direction TB
        DB["Sequelize Tables"]:::database
    end

    %% External Services
    subgraph "External Services"
        direction TB
        EXT_Firebase["Firebase"]:::external
        EXT_OAuth["Google OAuth"]:::external
        EXT_Mailer["Mailer Service"]:::external
    end

    %% Scheduler
    subgraph "Scheduler" 
        direction TB
        SCH["Cron Jobs"]:::scheduler
    end

    %% Data Flows
    MA_Main -->|uses| MA_Inj
    MA_Inj --> MA_Routes
    MA_Routes --> MA_Pres
    MA_Pres --> MA_Dom
    MA_Dom --> MA_Data
    MA_Data --> BE_Server
    WS_Comp --> WS_Svc
    WS_CTX --> WS_Svc
    WS_Svc --> BE_Server
    WS_Routes --> WS_Comp
    WS_Routes --> WS_Prot
    BE_Server --> BE_Routes
    BE_Routes --> BE_Controllers
    BE_Controllers --> BE_Services
    BE_Services --> BE_Models
    BE_Models --> DB
    BE_Services --> EXT_Firebase
    BE_Server --> BE_Mw
    BE_Controllers --> BE_Uploads
    SCH -->|triggers| BE_Services
    BE_Services -->|async| EXT_Mailer
    BE_Services -->|async| EXT_OAuth

    %% Click Events - Mobile App
    click MA_Pres "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/bb_mobile/lib/features/auth/presentation"
    click MA_Pres "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/bb_mobile/lib/features/report/presentation"
    click MA_Dom "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/bb_mobile/lib/features/auth/domain"
    click MA_Dom "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/bb_mobile/lib/features/report/domain"
    click MA_Data "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/bb_mobile/lib/features/auth/data"
    click MA_Data "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/bb_mobile/lib/features/report/data"
    click MA_Core "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/bb_mobile/lib/core/services"
    click MA_Core "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/bb_mobile/lib/core/utils/back_interceptor_wrapper.dart"
    click MA_Core "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/bb_mobile/lib/core/providers"
    click MA_Core "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/bb_mobile/lib/core/constants"
    click MA_Main "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/bb_mobile/lib/main.dart"
    click MA_Inj "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/bb_mobile/lib/injection.dart"
    click MA_Routes "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/bb_mobile/lib/routes/app_routes.dart"

    %% Click Events - Web SPA
    click WS_Comp "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/spl_web/src/components"
    click WS_Comp "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/spl_web/src/pages"
    click WS_CTX "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/context/AnnouncementContext.jsx"
    click WS_CTX "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/context/ReportContext.jsx"
    click WS_CTX "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/context/UserContext.jsx"
    click WS_Svc "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/services/api.js"
    click WS_Svc "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/services/authService.js"
    click WS_Svc "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/services/reportService.js"
    click WS_Svc "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/services/announcementService.js"
    click WS_Svc "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/services/parameterService.js"
    click WS_Svc "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/services/postService.js"
    click WS_Svc "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/services/notificationService.js"
    click WS_Svc "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/services/userService.js"
    click WS_Svc "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/services/mediaCarouselService.js"
    click WS_Svc "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/services/analyticsService.js"
    click WS_Routes "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/router/AppRoutes.jsx"
    click WS_Routes "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/router/ProtectedRoute.jsx"
    click WS_Main "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/main.jsx"
    click WS_App "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/spl_web/src/App.jsx"

    %% Click Events - Backend API
    click BE_Routes "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/web-service/routes"
    click BE_Controllers "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/web-service/controllers"
    click BE_Services "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/web-service/services"
    click BE_Models "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/web-service/models"
    click BE_MigSeed "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/web-service/migrations"
    click BE_MigSeed "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/web-service/seeders"
    click BE_Mw "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/web-service/middleware"
    click SCH "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/web-service/scheduler"
    click BE_Conf "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/web-service/config"
    click BE_Server "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/blob/main/web-service/server.js"
    click BE_Uploads "https://github.com/iqbalsiagian17/sistem-pelaporan-lingkungan/tree/main/web-service/uploads"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px;
    classDef backend fill:#DFFFE0,stroke:#228B22,stroke-width:1px;
    classDef database fill:#FFE8A0,stroke:#FF8C00,stroke-width:1px;
    classDef external fill:#F0D0FF,stroke:#9400D3,stroke-width:1px;
    classDef scheduler fill:#E2E2E2,stroke:#555555,stroke-width:1px;
```
