# teguhadip34/project_hg architecture

> Architecture diagram of the GitHub repository teguhadip34/project_hg, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/teguhadip34/project_hg
- Repository: https://github.com/teguhadip34/project_hg

## Overview

This is a Laravel waste-scanning and eco-gamification application, with a Python YOLO service for image detection. The main workflow is user sign-in, image submission, remote detection, scan recording and XP award, followed by a result view. Separate features include history, dashboard metrics, achievements and challenges, leaderboard, profile, and reward redemption. The README describes a browser-side material-classification stage, but the supplied tree does not contain that browser app or its model; the available scan-controller excerpt instead maps detection labels to waste types. Links reflect shown routes and calls; unsampled implementations are represented without speculative internal wiring.

Main entry points: [`routes/web.php`](https://github.com/teguhadip34/project_hg/blob/main/routes/web.php) (Web routes), [`app/Services/GamificationService.php`](https://github.com/teguhadip34/project_hg/blob/main/app/Services/GamificationService.php) (XP and metrics), [`app/Http/Controllers/ScanController.php`](https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/ScanController.php) (Scan workflow), [`app/Models/EcoProfile.php`](https://github.com/teguhadip34/project_hg/blob/main/app/Models/EcoProfile.php) (Eco profile)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and routing"]
  node_routes["Web routes<br/>[web.php]"]
  node_auth["Authentication<br/>[AuthController.php]"]
end

subgraph group_scanning["Waste scanning"]
  node_scan["Scan workflow<br/>[ScanController.php]"]
  node_yolo["YOLO API<br/>[server.py]"]
  node_scanview["Scan and result pages<br/>[scan.blade.php]"]
end

subgraph group_progress["Progress and competition"]
  node_gamification["XP and metrics"]
  node_dashboard["Dashboard"]
  node_history["Scan history"]
  node_achievements["Achievements"]
  node_challenges["Challenges"]
  node_leaderboard["Leaderboard"]
  node_profile["Profile"]
  node_dashboardview["Dashboard page"]
end

subgraph group_rewards["Rewards"]
  node_rewardflow["Reward redemption"]
end

subgraph group_records["Domain records"]
  node_scanrecords["Scan records<br/>[Scan.php]"]
  node_wastetype["Waste types<br/>[WasteType.php]"]
  node_wastecategory["Waste categories<br/>[WasteCategory.php]"]
  node_profiledata["Eco profile<br/>[EcoProfile.php]"]
  node_userrecord["User record<br/>[User.php]"]
  node_achievementdata["Achievement records<br/>[Achievement.php]"]
  node_rewarddata["Reward records<br/>[Reward.php]"]
  node_redemptions["Redemption records"]
end

node_user(("User"))

node_user -->|"requests pages"| node_routes
node_routes -->|"routes auth"| node_auth
node_routes -->|"routes scans"| node_scan
node_routes -->|"routes dashboard"| node_dashboard
node_routes -->|"routes history"| node_history
node_routes -->|"routes achievements"| node_achievements
node_routes -->|"routes challenges"| node_challenges
node_routes -->|"routes rankings"| node_leaderboard
node_routes -->|"routes profile"| node_profile
node_routes -->|"routes rewards"| node_rewardflow
node_auth -->|"creates users"| node_userrecord
node_auth -->|"creates profiles"| node_profiledata
node_scan -->|"posts image"| node_yolo
node_scan -->|"matches label"| node_wastetype
node_scan -->|"stores scan"| node_scanrecords
node_scan -->|"awards XP"| node_gamification
node_scan -.->|"shows scan form"| node_scanview
node_scan -->|"renders result"| node_scanview
node_gamification -->|"reads scans"| node_scanrecords
node_gamification -->|"updates XP"| node_profiledata
node_gamification -->|"checks unlocks"| node_achievementdata
node_dashboard -->|"gets metrics"| node_gamification
node_dashboard -.->|"renders dashboard"| node_dashboardview
node_history -->|"queries categories"| node_wastecategory
node_achievements -->|"loads achievements"| node_achievementdata
node_achievements -->|"gets progress"| node_gamification
node_challenges -->|"gets challenges"| node_gamification
node_leaderboard -->|"ranks users"| node_userrecord
node_profile -->|"loads profile"| node_profiledata
node_profile -->|"gets metrics"| node_gamification
node_rewardflow -->|"checks balance"| node_profiledata
node_rewardflow -->|"checks stock"| node_rewarddata
node_rewardflow -->|"creates redemption"| node_redemptions
node_profiledata -->|"sums spent XP"| node_redemptions
node_scanrecords -->|"references type"| node_wastetype
node_wastetype -->|"belongs to"| node_wastecategory
node_userrecord -->|"has profile"| node_profiledata
node_userrecord -->|"has scans"| node_scanrecords
node_userrecord -->|"has achievements"| node_achievementdata
node_redemptions -->|"references reward"| node_rewarddata

click node_routes "https://github.com/teguhadip34/project_hg/blob/main/routes/web.php"
click node_auth "https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/AuthController.php"
click node_scan "https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/ScanController.php"
click node_yolo "https://github.com/teguhadip34/project_hg/blob/main/ai-server/server.py"
click node_scanview "https://github.com/teguhadip34/project_hg/blob/main/resources/views/scan.blade.php"
click node_scanrecords "https://github.com/teguhadip34/project_hg/blob/main/app/Models/Scan.php"
click node_wastetype "https://github.com/teguhadip34/project_hg/blob/main/app/Models/WasteType.php"
click node_wastecategory "https://github.com/teguhadip34/project_hg/blob/main/app/Models/WasteCategory.php"
click node_profiledata "https://github.com/teguhadip34/project_hg/blob/main/app/Models/EcoProfile.php"
click node_userrecord "https://github.com/teguhadip34/project_hg/blob/main/app/Models/User.php"
click node_gamification "https://github.com/teguhadip34/project_hg/blob/main/app/Services/GamificationService.php"
click node_dashboard "https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/DashboardController.php"
click node_history "https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/HistoryController.php"
click node_achievements "https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/AchievementController.php"
click node_achievementdata "https://github.com/teguhadip34/project_hg/blob/main/app/Models/Achievement.php"
click node_challenges "https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/ChallengeController.php"
click node_leaderboard "https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/LeaderboardController.php"
click node_profile "https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/ProfileController.php"
click node_rewardflow "https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/RewardController.php"
click node_rewarddata "https://github.com/teguhadip34/project_hg/blob/main/app/Models/Reward.php"
click node_redemptions "https://github.com/teguhadip34/project_hg/blob/main/app/Models/RewardRedemption.php"
click node_dashboardview "https://github.com/teguhadip34/project_hg/blob/main/resources/views/dashboard.blade.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_routes,node_auth,node_user toneBlue
class node_scan,node_yolo,node_scanview toneAmber
class node_gamification,node_dashboard,node_history,node_achievements,node_challenges,node_leaderboard,node_profile,node_dashboardview toneMint
class node_rewardflow toneRose
class node_scanrecords,node_wastetype,node_wastecategory,node_profiledata,node_userrecord,node_achievementdata,node_rewarddata,node_redemptions toneIndigo
```

## Components

### Access and routing

- [Web routes](https://github.com/teguhadip34/project_hg/blob/main/routes/web.php): `routes/web.php`
- [Authentication](https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/AuthController.php): `app/Http/Controllers/AuthController.php`

### Waste scanning

- [Scan workflow](https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/ScanController.php): `app/Http/Controllers/ScanController.php`
- [YOLO API](https://github.com/teguhadip34/project_hg/blob/main/ai-server/server.py): `ai-server/server.py`
- [Scan and result pages](https://github.com/teguhadip34/project_hg/blob/main/resources/views/scan.blade.php): `resources/views/scan.blade.php`

### Progress and competition

- [XP and metrics](https://github.com/teguhadip34/project_hg/blob/main/app/Services/GamificationService.php): `app/Services/GamificationService.php`
- [Dashboard](https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/DashboardController.php): `app/Http/Controllers/DashboardController.php`
- [Scan history](https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/HistoryController.php): `app/Http/Controllers/HistoryController.php`
- [Achievements](https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/AchievementController.php): `app/Http/Controllers/AchievementController.php`
- [Challenges](https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/ChallengeController.php): `app/Http/Controllers/ChallengeController.php`
- [Leaderboard](https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/LeaderboardController.php): `app/Http/Controllers/LeaderboardController.php`
- [Profile](https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/ProfileController.php): `app/Http/Controllers/ProfileController.php`
- [Dashboard page](https://github.com/teguhadip34/project_hg/blob/main/resources/views/dashboard.blade.php): `resources/views/dashboard.blade.php`

### Rewards

- [Reward redemption](https://github.com/teguhadip34/project_hg/blob/main/app/Http/Controllers/RewardController.php): `app/Http/Controllers/RewardController.php`

### Domain records

- [Scan records](https://github.com/teguhadip34/project_hg/blob/main/app/Models/Scan.php): `app/Models/Scan.php`
- [Waste types](https://github.com/teguhadip34/project_hg/blob/main/app/Models/WasteType.php): `app/Models/WasteType.php`
- [Waste categories](https://github.com/teguhadip34/project_hg/blob/main/app/Models/WasteCategory.php): `app/Models/WasteCategory.php`
- [Eco profile](https://github.com/teguhadip34/project_hg/blob/main/app/Models/EcoProfile.php): `app/Models/EcoProfile.php`
- [User record](https://github.com/teguhadip34/project_hg/blob/main/app/Models/User.php): `app/Models/User.php`
- [Achievement records](https://github.com/teguhadip34/project_hg/blob/main/app/Models/Achievement.php): `app/Models/Achievement.php`
- [Reward records](https://github.com/teguhadip34/project_hg/blob/main/app/Models/Reward.php): `app/Models/Reward.php`
- [Redemption records](https://github.com/teguhadip34/project_hg/blob/main/app/Models/RewardRedemption.php): `app/Models/RewardRedemption.php`

### Other components

- **User**

## Connections

- User → Web routes: requests pages (evidence: `routes/web.php`)
- Web routes → Authentication: routes auth (evidence: `routes/web.php`)
- Web routes → Scan workflow: routes scans (evidence: `routes/web.php`)
- Web routes → Dashboard: routes dashboard (evidence: `routes/web.php`)
- Web routes → Scan history: routes history (evidence: `routes/web.php`)
- Web routes → Achievements: routes achievements (evidence: `routes/web.php`)
- Web routes → Challenges: routes challenges (evidence: `routes/web.php`)
- Web routes → Leaderboard: routes rankings (evidence: `routes/web.php`)
- Web routes → Profile: routes profile (evidence: `routes/web.php`)
- Web routes → Reward redemption: routes rewards (evidence: `routes/web.php`)
- Authentication → User record: creates users (evidence: `app/Http/Controllers/AuthController.php`)
- Authentication → Eco profile: creates profiles (evidence: `app/Http/Controllers/AuthController.php`)
- Scan workflow → YOLO API: posts image (evidence: `app/Http/Controllers/ScanController.php`)
- Scan workflow → Waste types: matches label (evidence: `app/Http/Controllers/ScanController.php`)
- Scan workflow → Scan records: stores scan (evidence: `app/Http/Controllers/ScanController.php`)
- Scan workflow → XP and metrics: awards XP (evidence: `app/Http/Controllers/ScanController.php`)
- Scan workflow → Scan and result pages: shows scan form
- Scan workflow → Scan and result pages: renders result (evidence: `app/Http/Controllers/ScanController.php`)
- XP and metrics → Scan records: reads scans (evidence: `app/Services/GamificationService.php`)
- XP and metrics → Eco profile: updates XP (evidence: `app/Services/GamificationService.php`)
- XP and metrics → Achievement records: checks unlocks (evidence: `app/Services/GamificationService.php`)
- Dashboard → XP and metrics: gets metrics (evidence: `app/Http/Controllers/DashboardController.php`)
- Dashboard → Dashboard page: renders dashboard
- Scan history → Waste categories: queries categories (evidence: `app/Http/Controllers/HistoryController.php`)
- Achievements → Achievement records: loads achievements (evidence: `app/Http/Controllers/AchievementController.php`)
- Achievements → XP and metrics: gets progress (evidence: `app/Http/Controllers/AchievementController.php`)
- Challenges → XP and metrics: gets challenges (evidence: `app/Http/Controllers/ChallengeController.php`)
- Leaderboard → User record: ranks users (evidence: `app/Http/Controllers/LeaderboardController.php`)
- Profile → Eco profile: loads profile (evidence: `app/Http/Controllers/ProfileController.php`)
- Profile → XP and metrics: gets metrics (evidence: `app/Http/Controllers/ProfileController.php`)
- Reward redemption → Eco profile: checks balance (evidence: `app/Http/Controllers/RewardController.php`)
- Reward redemption → Reward records: checks stock (evidence: `app/Http/Controllers/RewardController.php`)
- Reward redemption → Redemption records: creates redemption (evidence: `app/Http/Controllers/RewardController.php`)
- Eco profile → Redemption records: sums spent XP (evidence: `app/Models/EcoProfile.php`)
- Scan records → Waste types: references type (evidence: `app/Models/Scan.php`)
- Waste types → Waste categories: belongs to (evidence: `app/Models/WasteType.php`)
- User record → Eco profile: has profile (evidence: `app/Models/User.php`)
- User record → Scan records: has scans (evidence: `app/Models/User.php`)
- User record → Achievement records: has achievements (evidence: `app/Models/User.php`)
- Redemption records → Reward records: references reward (evidence: `app/Models/RewardRedemption.php`)
