# maulananizhar/spk-ahp-kelompok-9 architecture

> Architecture diagram of the GitHub repository maulananizhar/spk-ahp-kelompok-9, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maulananizhar/spk-ahp-kelompok-9
- Repository: https://github.com/maulananizhar/spk-ahp-kelompok-9

## Overview

##### Main Components

a. Frontend Layer:
- User Interface Modules (from /src/modules)
- Dashboard
- Kriteria (Criteria)
- SubKriteria (Sub-criteria)
- Alternatif (Alternatives)
- Perhitungan (Calculations)
- Components (from /src/components)
- Tables (AlternatifTable, KriteriaTable, SubKriteriaTable)
- Interactive Elements (KriteriaSlider)

b. API Layer:
- Auth endpoints (/api/auth/*)
- CRUD operations for:
- Kriteria (Criteria)
- Sub-kriteria (Sub-criteria)
- Alternatif (Alternatives)
- Matriks-kriteria (Criteria Matrix)
- Matriks-sub-kriteria (Sub-criteria Matrix)
- Eigen calculations

c. Business Logic Layer:
- A "Calculation Engine" container showing the AHP implementation:
- Calculation libraries (from /src/libs):
- calculateEigen
- calculateLambda
- processMatrix
- normalizationMatrix
- Other mathematical operations

d. Data Layer:
- MongoDB connection and data models for:
- Criteria
- Sub-criteria
- Alternatives
- Matrix data

##### Interaction Flows

- User Interface → API Routes → Business Logic → Database
- Database → Business Logic → API Routes → User Interface

- Login/Register → Token Generation → Protected Routes

##### Technical Details

- Next.js 13+ App Router architecture
- TypeScript type system integration
- MongoDB database connection
- Authentication middleware
- AHP calculation pipeline

##### Notes

Annotations for:
- Scalability considerations
- Security implementations
- Mathematical processing flow
- Data validation points

Remember to indicate the stateless nature of the Next.js application and how it interfaces with the persistent storage layer through the API routes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend["Frontend Layer (Next.js)"]
        direction TB
        UI_Modules["UI Modules"]
        UI_Components["UI Components"]
        
        subgraph Modules
            Dashboard["Dashboard"]:::frontend
            Kriteria["Kriteria"]:::frontend
            SubKriteria["SubKriteria"]:::frontend
            Alternatif["Alternatif"]:::frontend
            Perhitungan["Perhitungan"]:::frontend
        end
        
        subgraph Components
            AlternatifTable["AlternatifTable"]:::frontend
            KriteriaTable["KriteriaTable"]:::frontend
            SubKriteriaTable["SubKriteriaTable"]:::frontend
            KriteriaSlider["KriteriaSlider"]:::frontend
        end
        
        UI_Modules --> Modules
        UI_Components --> Components
    end
    
    subgraph Auth["Authentication Layer"]
        direction TB
        Login["Login"]:::auth
        Register["Register"]:::auth
        AuthAPI["Auth API"]:::auth
        JWT["JWT Token Handler"]:::auth
    end
    
    subgraph API["API Layer"]
        direction TB
        KriteriaAPI["Kriteria API"]:::api
        SubKriteriaAPI["SubKriteria API"]:::api
        AlternatifAPI["Alternatif API"]:::api
        MatrixAPI["Matrix Operations API"]:::api
        EigenAPI["Eigen Calculations API"]:::api
    end
    
    subgraph Logic["Business Logic Layer"]
        direction TB
        CalcEigen["Calculate Eigen"]:::logic
        CalcLambda["Calculate Lambda"]:::logic
        ProcessMatrix["Process Matrix"]:::logic
        NormalizeMatrix["Normalize Matrix"]:::logic
        TransformMatrix["Transform Matrix"]:::logic
    end
    
    subgraph Data["Data Layer"]
        direction TB
        MongoDB[(MongoDB)]:::database
        Types["Type Definitions"]:::types
        Storage["Storage Service"]:::storage
    end
    
    Frontend --> Auth
    Auth --> API
    API --> Logic
    Logic --> Data
    
    %% Click events for components
    click Dashboard "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/modules/Dashboard.tsx"
    click Kriteria "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/modules/Kriteria.tsx"
    click SubKriteria "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/modules/SubKriteria.tsx"
    click Alternatif "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/modules/Alternatif.tsx"
    click Perhitungan "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/modules/Perhitungan.tsx"
    
    click AlternatifTable "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/components/AlternatifTable.tsx"
    click KriteriaTable "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/components/KriteriaTable.tsx"
    click SubKriteriaTable "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/components/SubKriteriaTable.tsx"
    click KriteriaSlider "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/components/KriteriaSlider.tsx"
    
    click Login "https://github.com/maulananizhar/spk-ahp-kelompok-9/tree/main/src/app/auth/login"
    click Register "https://github.com/maulananizhar/spk-ahp-kelompok-9/tree/main/src/app/auth/register"
    click AuthAPI "https://github.com/maulananizhar/spk-ahp-kelompok-9/tree/main/src/app/api/auth"
    
    click KriteriaAPI "https://github.com/maulananizhar/spk-ahp-kelompok-9/tree/main/src/app/api/kriteria"
    click SubKriteriaAPI "https://github.com/maulananizhar/spk-ahp-kelompok-9/tree/main/src/app/api/sub-kriteria"
    click AlternatifAPI "https://github.com/maulananizhar/spk-ahp-kelompok-9/tree/main/src/app/api/alternatif"
    click MatrixAPI "https://github.com/maulananizhar/spk-ahp-kelompok-9/tree/main/src/app/api/matriks-kriteria"
    click EigenAPI "https://github.com/maulananizhar/spk-ahp-kelompok-9/tree/main/src/app/api/eigen"
    
    click CalcEigen "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/libs/calculateEigen.ts"
    click CalcLambda "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/libs/calculateLambda.ts"
    click ProcessMatrix "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/libs/processMatrix.ts"
    click NormalizeMatrix "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/libs/normalizationMatrix.ts"
    click TransformMatrix "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/libs/transformMatrix.ts"
    
    click Types "https://github.com/maulananizhar/spk-ahp-kelompok-9/tree/main/src/types"
    click Storage "https://github.com/maulananizhar/spk-ahp-kelompok-9/blob/main/src/services/storage.tsx"
    
    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef auth fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef api fill:#4CAF50,stroke:#388E3C,color:white
    classDef logic fill:#FFC107,stroke:#FFA000,color:black
    classDef database fill:#F44336,stroke:#D32F2F,color:white
    classDef types fill:#607D8B,stroke:#455A64,color:white
    classDef storage fill:#795548,stroke:#5D4037,color:white
```
