# rizki-habibi/fitur-spk-wp-dan-saw architecture

> Architecture diagram of the GitHub repository rizki-habibi/fitur-spk-wp-dan-saw, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rizki-habibi/fitur-spk-wp-dan-saw
- Repository: https://github.com/rizki-habibi/fitur-spk-wp-dan-saw

## Overview

1. **Overall shape**
   - This is a Laravel 12 monolith for a decision-support system (SPK) focused on scholarship selection.
   - The core domain is **multi-project** SPK data: each project owns its own criteria, alternatives, and assessments, and the app always works within one “active” project context.

2. **Primary domain boundary: active project isolation**
   - `Proyek` is the top-level container for all decision data.
   - A `HasActiveProyek` controller trait suggests the active project is stored in session and reused across CRUD, calculation, report, and AI flows.
   - Architecturally, this means almost every read/write path is scoped by `proyek_id`, so project selection is a key boundary in the system.

3. **Core data model**
   - `Kriteria`, `Alternatif`, and `Penilaian` form the main decision matrix.
   - `Kriteria` stores weight, type (`benefit` / `cost`), and metadata.
   - `Alternatif` stores candidate identity data.
   - `Penilaian` is the many-to-many scoring table between alternatives and criteria, with a uniqueness rule per pair.
   - The models and migrations show a normalized relational design rather than denormalized spreadsheet-style storage.

4. **Decision engine subsystem**
   - The calculation logic is separated into `SAWService` and `WeightedProductService`.
   - `PerhitunganController` is the orchestration layer that loads project data, invokes the appropriate service, and passes ranked results to views.
   - This is the main business-logic boundary: controllers manage request/response, services encapsulate the mathematical methods.

5. **SAW and WP data flow**
   - Both methods consume the same underlying dataset: criteria weights/types plus the assessment matrix.
   - SAW normalizes each criterion column, then computes weighted sums.
   - WP normalizes weights, applies exponentiation by criterion type, then multiplies and normalizes the resulting scores.
   - The repository is structured so the same input data can produce two independent rankings for comparison.

6. **User-facing CRUD layer**
   - `KriteriaController`, `AlternatifController`, `PenilaianController`, and `ProyekController` handle the main data-entry workflows.
   - The corresponding Blade views are organized by feature area, which indicates a classic server-rendered Laravel UI rather than an SPA.
   - The UX emphasizes modal-based CRUD and bulk matrix entry, which fits the decision-support workflow.

7. **Dashboard, reports, and comparison views**
   - `DashboardController`, `LaporanController`, and `PerhitunganController` provide the analytical views.
   - The dashboard likely summarizes counts, completeness, and top-ranked results; reports present full method outputs and comparison tables.
   - This layer is read-heavy and consumes the computed results from the service layer rather than recomputing business rules inline.

8. **Import/export subsystem**
   - `ExcelController` is the integration boundary for spreadsheet import/export and Word export.
   - Export concerns are split into dedicated classes under `app/Exports`, including an “all-in-one” workbook and per-domain exports.
   - The sheet classes under `app/Exports/Sheets` indicate a compositional Excel architecture: separate worksheets for criteria, alternatives, assessment data, comparison, and formula-based SAW/WP outputs.
   - Imports are similarly separated into `AlternatifImport` and `KriteriaImport`, keeping file parsing outside controllers.

9. **AI assistant subsystem**
   - `AiController` exposes chat and “generate all” endpoints.
   - `AiProvider` suggests provider selection is modeled in the database, not hardcoded.
   - The README shows multi-provider support across Groq, GitHub Models, OpenRouter, and Gemini, with auto-detection from API key format.
   - Architecturally, AI is an auxiliary service boundary that can generate or explain data, but it does not replace the core calculation engine.

10. **Visualization and guidance**
   - `FlowchartController` and `PanduanController` serve educational/illustrative pages for method flow and formula explanation.
   - These are documentation-oriented subsystems inside the app, supporting user understanding of the SAW/WP process rather than data manipulation.
   - `app/Http/Controllers/AiController.php` and these guidance pages together show the product is both operational and instructional.

11. **Frontend and rendering model**
   - Views are Blade templates under `resources/views`, with a shared layout in `layouts/app.blade.php`.
   - Styling and client behavior are built with Bootstrap 5, Bootstrap Icons, and Vite-managed assets (`resources/css`, `resources/js`).
   - The UI features described in the README—dark mode, settings panel, reminders, shortcuts—live in the frontend layer and persist via browser storage, separate from the Laravel domain logic.

12. **Operational and tooling boundaries**
   - The app uses standard Laravel infrastructure: `config/*`, `routes/web.php`, `database/migrations`, seeders, and tests.
   - Excel/Word generation depends on PhpSpreadsheet / PhpWord, with a patch file indicating a local customization to spreadsheet behavior.
   - Overall architecture is a single web application with clear internal module boundaries: project-scoped domain data, calculation services, export/import adapters, AI integration, and server-rendered presentation.

Main entry points: [`routes/web.php`](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/routes/web.php) (Web routes), [`resources/views`](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/tree/main/resources/views) (Blade UI), [`app/Http/Controllers/PenilaianController.php`](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/PenilaianController.php) (Assessment entry), [`app/Exports`](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/tree/main/app/Exports) (Exports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_domain["Domain"]
  node_proyek[("Proyek<br/>model<br/>[Proyek.php]")]
  node_kriteria[("Kriteria<br/>model<br/>[Kriteria.php]")]
  node_alternatif[("Alternatif<br/>model<br/>[Alternatif.php]")]
  node_penilaian[("Penilaian<br/>model<br/>[Penilaian.php]")]
end

subgraph group_application["Application"]
  node_active_proyek{{"Active project<br/>trait"}}
  node_project_crud["Project CRUD<br/>controller"]
  node_criteria_crud["Criteria CRUD<br/>controller"]
  node_alternatif_crud["Alternative CRUD<br/>controller"]
  node_penilaian_crud["Assessment entry<br/>controller"]
  node_perhitungan["Calculation<br/>controller"]
  node_saw_service{{"SAW service<br/>[SAWService.php]"}}
  node_wp_service{{"WP service"}}
  node_dashboard["Dashboard<br/>controller"]
  node_laporan["Reports<br/>controller"]
  node_routes["Web routes<br/>routing<br/>[web.php]"]
end

subgraph group_integration["Integration"]
  node_excel["Excel export<br/>controller"]
  node_ai["AI assistant<br/>controller<br/>[AiController.php]"]
  node_ai_provider[("AI provider<br/>model<br/>[AiProvider.php]")]
  node_exports["Exports<br/>export set"]
  node_imports["Imports<br/>import set"]
end

subgraph group_presentation["Presentation"]
  node_views["Blade UI<br/>views"]
end

node_routes -->|"routes"| node_project_crud
node_routes -->|"routes"| node_criteria_crud
node_routes -->|"routes"| node_alternatif_crud
node_routes -->|"routes"| node_penilaian_crud
node_routes -->|"routes"| node_perhitungan
node_routes -->|"routes"| node_dashboard
node_routes -->|"routes"| node_laporan
node_routes -->|"routes"| node_excel
node_routes -->|"routes"| node_ai
node_project_crud -->|"uses"| node_active_proyek
node_criteria_crud -->|"uses"| node_active_proyek
node_alternatif_crud -->|"uses"| node_active_proyek
node_penilaian_crud -->|"uses"| node_active_proyek
node_perhitungan -->|"uses"| node_active_proyek
node_dashboard -->|"uses"| node_active_proyek
node_laporan -->|"uses"| node_active_proyek
node_penilaian_crud -->|"writes"| node_penilaian
node_penilaian_crud -->|"reads"| node_alternatif
node_penilaian_crud -->|"reads"| node_kriteria
node_criteria_crud -->|"writes"| node_kriteria
node_alternatif_crud -->|"writes"| node_alternatif
node_project_crud -->|"writes"| node_proyek
node_perhitungan -->|"calls"| node_saw_service
node_perhitungan -->|"calls"| node_wp_service
node_saw_service -->|"reads"| node_kriteria
node_saw_service -->|"reads"| node_alternatif
node_saw_service -->|"reads"| node_penilaian
node_wp_service -->|"reads"| node_kriteria
node_wp_service -->|"reads"| node_alternatif
node_wp_service -->|"reads"| node_penilaian
node_excel -->|"uses"| node_exports
node_excel -->|"uses"| node_imports
node_exports -->|"includes"| node_kriteria
node_exports -->|"includes"| node_alternatif
node_exports -->|"includes"| node_penilaian
node_exports -->|"includes"| node_saw_service
node_exports -->|"includes"| node_wp_service
node_imports -->|"loads"| node_kriteria
node_imports -->|"loads"| node_alternatif
node_ai -->|"uses"| node_ai_provider
node_ai -->|"renders"| node_views
node_dashboard -->|"renders"| node_views
node_laporan -->|"renders"| node_views
node_perhitungan -->|"renders"| node_views
node_project_crud -->|"renders"| node_views
node_criteria_crud -->|"renders"| node_views
node_alternatif_crud -->|"renders"| node_views
node_penilaian_crud -->|"renders"| node_views

click node_proyek "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Models/Proyek.php"
click node_kriteria "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Models/Kriteria.php"
click node_alternatif "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Models/Alternatif.php"
click node_penilaian "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Models/Penilaian.php"
click node_active_proyek "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/Traits/HasActiveProyek.php"
click node_project_crud "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/ProyekController.php"
click node_criteria_crud "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/KriteriaController.php"
click node_alternatif_crud "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/AlternatifController.php"
click node_penilaian_crud "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/PenilaianController.php"
click node_perhitungan "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/PerhitunganController.php"
click node_saw_service "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Services/SAWService.php"
click node_wp_service "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Services/WeightedProductService.php"
click node_dashboard "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/DashboardController.php"
click node_laporan "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/LaporanController.php"
click node_excel "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/ExcelController.php"
click node_ai "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/AiController.php"
click node_ai_provider "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Models/AiProvider.php"
click node_exports "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/tree/main/app/Exports"
click node_imports "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/tree/main/app/Imports"
click node_views "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/tree/main/resources/views"
click node_routes "https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/routes/web.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_proyek,node_kriteria,node_alternatif,node_penilaian toneBlue
class node_active_proyek,node_project_crud,node_criteria_crud,node_alternatif_crud,node_penilaian_crud,node_perhitungan,node_saw_service,node_wp_service,node_dashboard,node_laporan,node_routes toneAmber
class node_excel,node_ai,node_ai_provider,node_exports,node_imports toneMint
class node_views toneRose
```

## Components

### Domain

Project-scoped decision data and models

- [Proyek](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Models/Proyek.php): model · Active project container for all decision data · `app/Models/Proyek.php`
- [Kriteria](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Models/Kriteria.php): model · Criteria with weights and benefit/cost type · `app/Models/Kriteria.php`
- [Alternatif](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Models/Alternatif.php): model · Candidate alternatives in a project · `app/Models/Alternatif.php`
- [Penilaian](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Models/Penilaian.php): model · Assessment matrix linking alternatives and criteria · `app/Models/Penilaian.php`

### Application

Controllers, traits, and calculation services

- [Active project](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/Traits/HasActiveProyek.php): trait · Session-backed active project scoping · `app/Http/Controllers/Traits/HasActiveProyek.php`
- [Project CRUD](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/ProyekController.php): controller · Project management and selection flow · `app/Http/Controllers/ProyekController.php`
- [Criteria CRUD](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/KriteriaController.php): controller · Criteria entry and maintenance · `app/Http/Controllers/KriteriaController.php`
- [Alternative CRUD](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/AlternatifController.php): controller · Alternative entry and maintenance · `app/Http/Controllers/AlternatifController.php`
- [Assessment entry](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/PenilaianController.php): controller · Matrix-style scoring workflow · `app/Http/Controllers/PenilaianController.php`
- [Calculation](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/PerhitunganController.php): controller · Orchestrates ranking and comparison outputs · `app/Http/Controllers/PerhitunganController.php`
- [SAW service](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Services/SAWService.php): service · Simple Additive Weighting calculations · `app/Services/SAWService.php`
- [WP service](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Services/WeightedProductService.php): service · Weighted Product calculations · `app/Services/WeightedProductService.php`
- [Dashboard](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/DashboardController.php): controller · Summary and status overview · `app/Http/Controllers/DashboardController.php`
- [Reports](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/LaporanController.php): controller · Read-heavy analytical report views · `app/Http/Controllers/LaporanController.php`
- [Web routes](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/routes/web.php): routing · HTTP entrypoints for the monolith · `routes/web.php`

### Integration

Import/export and AI boundaries

- [Excel export](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/ExcelController.php): controller · Spreadsheet and Word import/export boundary · `app/Http/Controllers/ExcelController.php`
- [AI assistant](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Http/Controllers/AiController.php): controller · Chat and generation endpoints · `app/Http/Controllers/AiController.php`
- [AI provider](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/blob/main/app/Models/AiProvider.php): model · Persisted provider selection and metadata · `app/Models/AiProvider.php`
- [Exports](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/tree/main/app/Exports): export set · Workbook and document generators · `app/Exports`
- [Imports](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/tree/main/app/Imports): import set · Spreadsheet parsers for bulk data load · `app/Imports`

### Presentation

Blade views and UI pages

- [Blade UI](https://github.com/rizki-habibi/fitur-spk-wp-dan-saw/tree/main/resources/views): views · Server-rendered feature pages and layouts · `resources/views`

## Connections

- Web routes → Project CRUD: routes · Maps project pages and actions
- Web routes → Criteria CRUD: routes · Maps criteria pages and actions
- Web routes → Alternative CRUD: routes · Maps alternative pages and actions
- Web routes → Assessment entry: routes · Maps assessment matrix pages and actions
- Web routes → Calculation: routes · Maps calculation views
- Web routes → Dashboard: routes · Maps dashboard view
- Web routes → Reports: routes · Maps reporting views
- Web routes → Excel export: routes · Maps import/export endpoints
- Web routes → AI assistant: routes · Maps AI endpoints
- Project CRUD → Active project: uses · Reads and sets active project context
- Criteria CRUD → Active project: uses · Scopes criteria to active project
- Alternative CRUD → Active project: uses · Scopes alternatives to active project
- Assessment entry → Active project: uses · Scopes assessments to active project
- Calculation → Active project: uses · Loads data for the active project only
- Dashboard → Active project: uses · Summarizes the active project
- Reports → Active project: uses · Builds reports for the active project
- Assessment entry → Penilaian: writes · Stores pairwise scores
- Assessment entry → Alternatif: reads · Needs alternatives for matrix entry
- Assessment entry → Kriteria: reads · Needs criteria for matrix entry
- Criteria CRUD → Kriteria: writes · Creates and updates criteria
- Alternative CRUD → Alternatif: writes · Creates and updates alternatives
- Project CRUD → Proyek: writes · Creates and updates projects
- Calculation → SAW service: calls · Runs SAW ranking
- Calculation → WP service: calls · Runs WP ranking
- SAW service → Kriteria: reads · Consumes criteria weights and types
- SAW service → Alternatif: reads · Consumes candidate alternatives
- SAW service → Penilaian: reads · Consumes score matrix
- WP service → Kriteria: reads · Consumes criteria weights and types
- WP service → Alternatif: reads · Consumes candidate alternatives
- WP service → Penilaian: reads · Consumes score matrix
- Excel export → Exports: uses · Generates spreadsheets and documents
- Excel export → Imports: uses · Parses uploaded spreadsheets
- Exports → Kriteria: includes · Exports criteria data
- Exports → Alternatif: includes · Exports alternatives data
- Exports → Penilaian: includes · Exports assessment matrix
- Exports → SAW service: includes · Exports SAW results and formulas
- Exports → WP service: includes · Exports WP results and formulas
- Imports → Kriteria: loads · Imports criteria data
- Imports → Alternatif: loads · Imports alternatives data
- AI assistant → AI provider: uses · Selects or stores provider metadata
- AI assistant → Blade UI: renders · Serves chat and module pages
- Dashboard → Blade UI: renders · Serves dashboard UI
- Reports → Blade UI: renders · Serves report UI
- Calculation → Blade UI: renders · Serves comparison and ranking UI
- Project CRUD → Blade UI: renders · Serves project UI
- Criteria CRUD → Blade UI: renders · Serves criteria UI
- Alternative CRUD → Blade UI: renders · Serves alternative UI
- Assessment entry → Blade UI: renders · Serves assessment UI
