Skip to content

Add comprehensive system documentation with ERD, DFD, flowmaps, UML diagrams and folder structure#23

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/create-erd-flowmap-dfd
Draft

Add comprehensive system documentation with ERD, DFD, flowmaps, UML diagrams and folder structure#23
Copilot wants to merge 6 commits intomainfrom
copilot/create-erd-flowmap-dfd

Conversation

Copy link

Copilot AI commented Dec 15, 2025

Analyzed the HerbaMed Jabar Android codebase and created complete technical documentation covering system architecture, data flows, and user interactions.

Created Documentation

DIAGRAMS.md (1600 lines, 20 Mermaid diagrams):

Data Model

  • ERD: 4 entities (User, ScanHistory, Post, Like) with relationships
    • Local: Room DB for scan history
    • Cloud: Firestore for forum posts
    • Auth: Firebase for user management

System Architecture

  • Context Diagram: System boundaries with 6 external integrations (Firebase Auth/Firestore, Cloudinary, Gemini AI)
  • MVVM Architecture: Layer diagram showing View → ViewModel → UseCase → Repository → DataSource with Hilt DI
  • MVVM Narrative: Comprehensive 4-paragraph explanation of MVVM + Clean Architecture implementation, covering layer responsibilities, dependency injection with Hilt/Dagger, team workflow benefits, and scalability considerations
  • Folder Structure: Complete visualization of app/src/main/java/edu/unikom/herbamedjabar directory structure with text-based tree and color-coded Mermaid diagram showing all 30 Kotlin files across 10 folders organized by architectural layer

Process Flows

  • DFD Level 0: 5 main processes (Authentication, Plant Scanning, Forum, History, Profile)
  • DFD Level 1: 20 sub-processes across all major features
  • Flowmaps: 5 complete user journeys from entry to exit points

UML Diagrams

  • Class Diagram: 20+ classes covering all architectural layers (View, ViewModel, UseCase, Repository, Data) with relationships
  • Use Case Diagram: 12 use cases showing user interactions with external systems (Firebase, Gemini AI, Cloudinary)
  • Activity Diagrams: 2 diagrams covering Scan Process (camera → AI → storage) and History Management (view, delete, share)
  • Sequence Diagrams: 2 diagrams showing Login/Scan flow (authentication → AI analysis) and Forum Posting flow (upload → Cloudinary → Firestore)

Technical Details

  • Technology stack mapping
  • Implementation notes (offline support, real-time sync, retry mechanisms)

Updated Files

  • README.md: Added reference section linking to DIAGRAMS.md

All diagrams use Mermaid syntax for native GitHub rendering. Documentation written in Indonesian to match codebase language.

Original prompt

Analisis codebase repositori ini, lalu buatkan ERD, Flowmap*, Diagram Konteks*, dan DFD dalam bentuk markdown atau mermaid-chart.

Note:

    • : Jika perlu/relevan

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 2 commits December 15, 2025 05:05
Co-authored-by: nirwanadoteth <121574317+nirwanadoteth@users.noreply.github.com>
Co-authored-by: nirwanadoteth <121574317+nirwanadoteth@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze codebase and create ERD, flowmap, context diagram, and DFD Add comprehensive system documentation with ERD, DFD, and flowmaps Dec 15, 2025
Copilot AI requested a review from nirwanadoteth December 15, 2025 05:11
@nirwanadoteth
Copy link
Collaborator

@copilot Buat narasi yang menggambarkan arsitektur sistem (MVVM?) yang digunakan secara umum (1 atau 2 paragraf), lalu buatkan juga Diagram UML yang mencakup Class Diagram, Use Case Diagram, Activity Diagram, dan Sequence Diagram.

…ctivity, Sequence)

Co-authored-by: nirwanadoteth <121574317+nirwanadoteth@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 2, 2026

@copilot Buat narasi yang menggambarkan arsitektur sistem (MVVM?) yang digunakan secara umum (1 atau 2 paragraf), lalu buatkan juga Diagram UML yang mencakup Class Diagram, Use Case Diagram, Activity ...

Sudah ditambahkan di commit 2bfe5cb:

Narasi Arsitektur MVVM (2 paragraf):

  • Penjelasan implementasi MVVM dengan Clean Architecture
  • Layer separation: View → ViewModel → UseCase → Repository → DataSource
  • Dependency Injection dengan Hilt/Dagger
  • Keuntungan skalabilitas dan maintainability

Diagram UML yang ditambahkan:

  1. Class Diagram - 20+ classes mencakup View, ViewModel, UseCase, Repository, dan Data layers dengan relationships
  2. Use Case Diagram - 12 use cases dengan interaksi external systems (Firebase, Gemini AI, Cloudinary)
  3. Activity Diagram - Scan Tanaman - Alur lengkap dari kamera/galeri, AI processing, sampai penyimpanan
  4. Activity Diagram - Manajemen Riwayat - Flow untuk view, delete, dan share history
  5. Sequence Diagram - Login & Scan - Interaksi objek untuk autentikasi dan pemindaian dengan AI
  6. Sequence Diagram - Posting Forum - Flow upload image ke Cloudinary dan save ke Firestore

Total 6 diagram UML baru ditambahkan ke DIAGRAMS.md (file bertambah dari 863 ke 1465 baris).

Co-authored-by: nirwanadoteth <121574317+nirwanadoteth@users.noreply.github.com>
Copilot AI changed the title Add comprehensive system documentation with ERD, DFD, and flowmaps Add comprehensive system documentation with ERD, DFD, flowmaps and UML diagrams Jan 2, 2026
@nirwanadoteth
Copy link
Collaborator

@coderabbitai tolong buatkan class diagram untuk repositori ini

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@nirwanadoteth, saya akan membuatkan class diagram untuk repositori ini. Izinkan saya menganalisis struktur kodebase terlebih dahulu.


🏁 Script executed:

#!/bin/bash
# Explore the main package structure
fd -t f -e kt . app/src/main/java/edu/unikom/herbamedjabar/ | head -50

Length of output: 2036


🏁 Script executed:

#!/bin/bash
# Find all Activities and Fragments
fd -t f -e kt "(Activity|Fragment)" app/src/main/java/edu/unikom/herbamedjabar/

Length of output: 804


🏁 Script executed:

#!/bin/bash
# Find all ViewModels
fd -t f -e kt "ViewModel" app/src/main/java/edu/unikom/herbamedjabar/

Length of output: 507


🏁 Script executed:

#!/bin/bash
# Find all Repositories
fd -t f -e kt "Repository" app/src/main/java/edu/unikom/herbamedjabar/

Length of output: 144


🏁 Script executed:

#!/bin/bash
# Find all Use Cases
fd -t f -e kt "UseCase" app/src/main/java/edu/unikom/herbamedjabar/

Length of output: 73


🏁 Script executed:

#!/bin/bash
# Find data models and entities
fd -t f -e kt . app/src/main/java/edu/unikom/herbamedjabar/data/

Length of output: 118


🏁 Script executed:

#!/bin/bash
# Find adapters
fd -t f -e kt "Adapter" app/src/main/java/edu/unikom/herbamedjabar/

Length of output: 134


🏁 Script executed:

#!/bin/bash
# Get the complete directory structure
fd -t d . app/src/main/java/edu/unikom/herbamedjabar/ | sort

Length of output: 452


🏁 Script executed:

#!/bin/bash
# Examine key data models
cat app/src/main/java/edu/unikom/herbamedjabar/data/ScanHistory.kt

Length of output: 415


🏁 Script executed:

#!/bin/bash
# Examine Post model
cat app/src/main/java/edu/unikom/herbamedjabar/data/Post.kt

Length of output: 532


🏁 Script executed:

#!/bin/bash
# Examine ScanViewModel
cat app/src/main/java/edu/unikom/herbamedjabar/viewModel/ScanViewModel.kt

Length of output: 1695


🏁 Script executed:

#!/bin/bash
# Examine AuthViewModel
cat app/src/main/java/edu/unikom/herbamedjabar/viewModel/AuthViewModel.kt

Length of output: 4083


🏁 Script executed:

#!/bin/bash
# Examine PlantRepository
cat app/src/main/java/edu/unikom/herbamedjabar/repository/PlantRepository.kt

Length of output: 3239


🏁 Script executed:

#!/bin/bash
# Examine PostRepository
cat app/src/main/java/edu/unikom/herbamedjabar/repository/PostRepository.kt

Length of output: 5229


🏁 Script executed:

#!/bin/bash
# Examine AnalyzePlantUseCase
cat app/src/main/java/edu/unikom/herbamedjabar/useCase/AnalyzePlantUseCase.kt

Length of output: 2258


🏁 Script executed:

#!/bin/bash
# Examine AppDatabase
cat app/src/main/java/edu/unikom/herbamedjabar/db/AppDatabase.kt

Length of output: 378


🏁 Script executed:

#!/bin/bash
# Examine ScanHistoryDao
cat app/src/main/java/edu/unikom/herbamedjabar/dao/ScanHistoryDao.kt

Length of output: 635


🏁 Script executed:

#!/bin/bash
# Examine other ViewModels
cat app/src/main/java/edu/unikom/herbamedjabar/viewModel/HistoryViewModel.kt
cat app/src/main/java/edu/unikom/herbamedjabar/viewModel/ForumViewModel.kt
cat app/src/main/java/edu/unikom/herbamedjabar/viewModel/ProfileViewModel.kt

Length of output: 4384


🏁 Script executed:

#!/bin/bash
# Examine ResultViewModel and HistoryDetailViewModel
cat app/src/main/java/edu/unikom/herbamedjabar/viewModel/ResultViewModel.kt
cat app/src/main/java/edu/unikom/herbamedjabar/viewModel/HistoryDetailViewModel.kt

Length of output: 4236


🏁 Script executed:

#!/bin/bash
# Examine AppModule for DI configuration
cat app/src/main/java/edu/unikom/herbamedjabar/di/AppModule.kt

Length of output: 2128


🏁 Script executed:

#!/bin/bash
# Examine Adapter classes
cat app/src/main/java/edu/unikom/herbamedjabar/adapter/HistoryAdapter.kt
cat app/src/main/java/edu/unikom/herbamedjabar/adapter/PostAdapter.kt

Length of output: 7579


@nirwanadoteth, berikut adalah Class Diagram lengkap untuk repositori HerbaMed-Jabar:

classDiagram
    %% ============================================
    %% APPLICATION LAYER
    %% ============================================
    class HerbaAppApplication {
        <<Application>>
        +onCreate()
    }

    %% ============================================
    %% PRESENTATION LAYER - VIEW
    %% ============================================
    class SplashActivity {
        <<Activity>>
        +onCreate()
        -navigateToAuth()
        -navigateToMain()
    }

    class AuthActivity {
        <<Activity>>
        +onCreate()
        -setupNavigation()
    }

    class MainActivity {
        <<Activity>>
        +onCreate()
        -setupBottomNavigation()
        -setupFragments()
    }

    class LoginFragment {
        <<Fragment>>
        -binding: FragmentLoginBinding
        -authViewModel: AuthViewModel
        +onViewCreated()
        -observeAuthState()
        -handleGoogleSignIn()
    }

    class RegisterFragment {
        <<Fragment>>
        -binding: FragmentRegisterBinding
        -authViewModel: AuthViewModel
        +onViewCreated()
        -observeAuthState()
    }

    class ScanFragment {
        <<Fragment>>
        -binding: FragmentScanBinding
        -scanViewModel: ScanViewModel
        -imageCapture: ImageCapture
        +onViewCreated()
        -startCamera()
        -takePhoto()
        -observeUiState()
    }

    class ResultFragment {
        <<Fragment>>
        -binding: FragmentResultBinding
        -resultViewModel: ResultViewModel
        -analysisResult: AnalysisResult
        +onViewCreated()
        -displayResult()
        -shareToForum()
    }

    class ForumFragment {
        <<Fragment>>
        -binding: FragmentForumBinding
        -forumViewModel: ForumViewModel
        -postAdapter: PostAdapter
        +onViewCreated()
        -observePosts()
        -handleLike()
    }

    class ProfileFragment {
        <<Fragment>>
        -binding: FragmentProfileBinding
        -profileViewModel: ProfileViewModel
        -postAdapter: PostAdapter
        +onViewCreated()
        -observeUserData()
        -observeUserPosts()
        -handleLogout()
    }

    class HistoryFragment {
        <<Fragment>>
        -binding: FragmentHistoryBinding
        -historyViewModel: HistoryViewModel
        -historyAdapter: HistoryAdapter
        +onViewCreated()
        -observeHistory()
    }

    class HistoryDetailFragment {
        <<Fragment>>
        -binding: FragmentHistoryDetailBinding
        -historyDetailViewModel: HistoryDetailViewModel
        -scanHistory: ScanHistory
        +onViewCreated()
        -displayDetails()
        -handleDelete()
    }

    class ProcessingDialogFragment {
        <<DialogFragment>>
        +onCreateDialog()
    }

    %% ============================================
    %% PRESENTATION LAYER - ADAPTERS
    %% ============================================
    class HistoryAdapter {
        <<RecyclerView.Adapter>>
        -onClick: (ScanHistory) → Unit
        +onCreateViewHolder()
        +onBindViewHolder()
        -HistoryViewHolder
    }

    class PostAdapter {
        <<RecyclerView.Adapter>>
        -onLikeClicked: (String) → Unit
        -onDeleteClicked: (Post) → Unit
        +onCreateViewHolder()
        +onBindViewHolder()
        -PostViewHolder
    }

    %% ============================================
    %% PRESENTATION LAYER - VIEWMODELS
    %% ============================================
    class AuthViewModel {
        <<ViewModel>>
        -firebaseAuth: FirebaseAuth
        -_authState: MutableLiveData~AuthState~
        +authState: LiveData~AuthState~
        +loginUser(email, password)
        +signInWithGoogleToken(idToken)
        +registerUser(name, email, password, confirmPassword)
    }

    class ScanViewModel {
        <<ViewModel>>
        -analyzePlantUseCase: AnalyzePlantUseCase
        -_uiState: MutableLiveData~UiState~
        +uiState: LiveData~UiState~
        -_navigateToResult: MutableLiveData~AnalysisResult~
        +navigateToResult: LiveData~AnalysisResult~
        +analyzeImage(bitmap: Bitmap)
        +onNavigationComplete()
    }

    class ResultViewModel {
        <<ViewModel>>
        -postRepository: PostRepository
        -auth: FirebaseAuth
        -_postResult: MutableLiveData~Result~
        +postResult: LiveData~Result~
        -_isLoading: MutableLiveData~Boolean~
        +isLoading: LiveData~Boolean~
        +createPostFromScan(imageUri, plantName, description)
        -parsePlantData(text): Map
    }

    class ForumViewModel {
        <<ViewModel>>
        -postRepository: PostRepository
        -auth: FirebaseAuth
        -_posts: MutableLiveData~List~Post~~
        +posts: LiveData~List~Post~~
        -_isLoading: MutableLiveData~Boolean~
        +isLoading: LiveData~Boolean~
        -_error: MutableLiveData~String~
        +error: LiveData~String~
        -fetchPosts()
        +toggleLikeOnPost(postId)
        +deletePost(post)
    }

    class ProfileViewModel {
        <<ViewModel>>
        -auth: FirebaseAuth
        -postRepository: PostRepository
        -_user: MutableLiveData~FirebaseUser~
        +user: LiveData~FirebaseUser~
        -_userPosts: MutableLiveData~List~Post~~
        +userPosts: LiveData~List~Post~~
        -fetchUserPosts()
        +toggleLikeOnPost(postId)
        +deletePost(post)
        +logout()
    }

    class HistoryViewModel {
        <<ViewModel>>
        -plantRepository: PlantRepository
        +allHistory: LiveData~List~ScanHistory~~
    }

    class HistoryDetailViewModel {
        <<ViewModel>>
        -plantRepository: PlantRepository
        +deleteHistory(history)
    }

    %% ============================================
    %% PRESENTATION LAYER - STATE CLASSES
    %% ============================================
    class UiState {
        <<sealed class>>
    }

    class UiStateIdle {
        <<object>>
    }

    class UiStateLoading {
        <<object>>
    }

    class UiStateSuccess {
        <<object>>
    }

    class UiStateError {
        <<data class>>
        +message: String
    }

    class AuthState {
        <<sealed class>>
    }

    class AuthStateIdle {
        <<object>>
    }

    class AuthStateLoading {
        <<object>>
    }

    class AuthStateAuthenticated {
        <<object>>
    }

    class AuthStateError {
        <<data class>>
        +message: String
    }

    %% ============================================
    %% DOMAIN LAYER - USE CASES
    %% ============================================
    class AnalyzePlantUseCase {
        <<UseCase>>
        -plantRepository: PlantRepository
        +invoke(bitmap: Bitmap): Result~AnalysisResult~
    }

    %% ============================================
    %% DATA LAYER - REPOSITORIES
    %% ============================================
    class PlantRepository {
        <<interface>>
        +analyzePlant(bitmap, prompt): AnalysisResult
        +getAllHistory(): Flow~List~ScanHistory~~
        +deleteHistory(history)
    }

    class PlantRepositoryImpl {
        <<Repository>>
        -generativeModel: GenerativeModel
        -scanHistoryDao: ScanHistoryDao
        -application: Application
        +analyzePlant(bitmap, prompt): AnalysisResult
        +getAllHistory(): Flow~List~ScanHistory~~
        +deleteHistory(history)
        -saveBitmapToFile(bitmap): String
    }

    class PostRepository {
        <<Repository>>
        -firestore: FirebaseFirestore
        +getPosts(): Flow~List~Post~~
        +getPostsByUserId(userId): Flow~List~Post~~
        +createPost(userId, username, userProfilePictureUrl, imageUri, plantName, description, parsedData)
        +toggleLike(postId, userId)
        +deletePost(post)
        -uploadImageToCloudinary(imageUri): String
    }

    %% ============================================
    %% DATA LAYER - LOCAL DATA SOURCES
    %% ============================================
    class AppDatabase {
        <<RoomDatabase>>
        +scanHistoryDao(): ScanHistoryDao
    }

    class ScanHistoryDao {
        <<DAO>>
        +insertHistory(scanHistory)
        +getAllHistory(): Flow~List~ScanHistory~~
        +deleteHistory(scanHistory)
    }

    %% ============================================
    %% DATA LAYER - ENTITIES & MODELS
    %% ============================================
    class ScanHistory {
        <<Entity>>
        +id: Int
        +resultText: String
        +imagePath: String
        +timestamp: Long
    }

    class Post {
        <<Data Class>>
        +id: String
        +userId: String
        +username: String
        +userProfilePictureUrl: String?
        +imageUrl: String
        +plantName: String
        +description: String
        +timestamp: Long
        +likes: List~String~
        +content: String?
        +benefit: String?
        +warning: String?
    }

    class AnalysisResult {
        <<Data Class>>
        +resultText: String
        +imagePath: String
    }

    %% ============================================
    %% DATA LAYER - EXTERNAL SERVICES
    %% ============================================
    class FirebaseAuth {
        <<External Service>>
        +signInWithEmailAndPassword()
        +signInWithCredential()
        +createUserWithEmailAndPassword()
        +signOut()
        +currentUser: FirebaseUser?
    }

    class FirebaseFirestore {
        <<External Service>>
        +collection(path): CollectionReference
    }

    class GenerativeModel {
        <<External Service - Gemini AI>>
        +generateContent(content): GenerateContentResponse
    }

    class MediaManager {
        <<External Service - Cloudinary>>
        +upload(uri): RequestUploader
    }

    %% ============================================
    %% DEPENDENCY INJECTION
    %% ============================================
    class AppModule {
        <<Hilt Module>>
        +provideFirebaseAuth(): FirebaseAuth
        +provideFirebaseFirestore(): FirebaseFirestore
        +provideFirebaseStorage(): FirebaseStorage
        +provideGenerativeModel(): GenerativeModel
        +provideAppDatabase(): AppDatabase
        +provideScanHistoryDao(): ScanHistoryDao
        +providePlantRepository(): PlantRepository
    }

    %% ============================================
    %% RELATIONSHIPS
    %% ============================================
    
    %% Application
    HerbaAppApplication ..> AppModule : uses

    %% Activities contain Fragments
    AuthActivity *-- LoginFragment
    AuthActivity *-- RegisterFragment
    MainActivity *-- ScanFragment
    MainActivity *-- ResultFragment
    MainActivity *-- ForumFragment
    MainActivity *-- ProfileFragment
    MainActivity *-- HistoryFragment
    MainActivity *-- HistoryDetailFragment

    %% Fragments use ViewModels
    LoginFragment --> AuthViewModel : uses
    RegisterFragment --> AuthViewModel : uses
    ScanFragment --> ScanViewModel : uses
    ResultFragment --> ResultViewModel : uses
    ForumFragment --> ForumViewModel : uses
    ProfileFragment --> ProfileViewModel : uses
    HistoryFragment --> HistoryViewModel : uses
    HistoryDetailFragment --> HistoryDetailViewModel : uses

    %% Fragments use Adapters
    ForumFragment --> PostAdapter : uses
    ProfileFragment --> PostAdapter : uses
    HistoryFragment --> HistoryAdapter : uses

    %% ViewModels use UseCases/Repositories
    AuthViewModel --> FirebaseAuth : uses
    ScanViewModel --> AnalyzePlantUseCase : uses
    ResultViewModel --> PostRepository : uses
    ResultViewModel --> FirebaseAuth : uses
    ForumViewModel --> PostRepository : uses
    ForumViewModel --> FirebaseAuth : uses
    ProfileViewModel --> PostRepository : uses
    ProfileViewModel --> FirebaseAuth : uses
    HistoryViewModel --> PlantRepository : uses
    HistoryDetailViewModel --> PlantRepository : uses

    %% ViewModels use State
    ScanViewModel --> UiState : uses
    AuthViewModel --> AuthState : uses

    %% State inheritance
    UiState <|-- UiStateIdle
    UiState <|-- UiStateLoading
    UiState <|-- UiStateSuccess
    UiState <|-- UiStateError
    AuthState <|-- AuthStateIdle
    AuthState <|-- AuthStateLoading
    AuthState <|-- AuthStateAuthenticated
    AuthState <|-- AuthStateError

    %% UseCases use Repositories
    AnalyzePlantUseCase --> PlantRepository : uses

    %% Repository implementation
    PlantRepository <|.. PlantRepositoryImpl : implements

    %% Repositories use DAOs and External Services
    PlantRepositoryImpl --> ScanHistoryDao : uses
    PlantRepositoryImpl --> GenerativeModel : uses
    PostRepository --> FirebaseFirestore : uses
    PostRepository --> MediaManager : uses

    %% Database provides DAO
    AppDatabase --> ScanHistoryDao : provides

    %% DAOs work with Entities
    ScanHistoryDao --> ScanHistory : CRUD

    %% Repositories work with Models
    PlantRepository --> AnalysisResult : returns
    PlantRepository --> ScanHistory : returns
    PostRepository --> Post : returns

    %% Adapters work with Models
    HistoryAdapter --> ScanHistory : displays
    PostAdapter --> Post : displays

    %% DI Module provides dependencies
    AppModule ..> FirebaseAuth : provides
    AppModule ..> FirebaseFirestore : provides
    AppModule ..> GenerativeModel : provides
    AppModule ..> AppDatabase : provides
    AppModule ..> ScanHistoryDao : provides
    AppModule ..> PlantRepository : provides
Loading

Penjelasan Class Diagram:

Class diagram ini menampilkan seluruh struktur kelas dalam aplikasi HerbaMed-Jabar yang diorganisir berdasarkan layer arsitektur:

  1. Application Layer: HerbaAppApplication sebagai entry point aplikasi

  2. Presentation Layer - View:

    • 3 Activities: SplashActivity, AuthActivity, MainActivity
    • 9 Fragments untuk berbagai fitur (Login, Register, Scan, Result, Forum, Profile, History, dll.)
    • 2 Adapters: HistoryAdapter dan PostAdapter untuk RecyclerView
  3. Presentation Layer - ViewModel:

    • 7 ViewModels yang mengelola UI state dan business logic
    • Sealed classes untuk state management (UiState, AuthState)
  4. Domain Layer:

    • AnalyzePlantUseCase untuk business logic analisis tanaman
  5. Data Layer:

    • Repositories: PlantRepository, PlantRepositoryImpl, PostRepository
    • Local data source: AppDatabase, ScanHistoryDao
    • Entities: ScanHistory, Post, AnalysisResult
    • External services: Firebase Auth, Firestore, Gemini AI, Cloudinary
  6. Dependency Injection:

    • AppModule dengan Hilt/Dagger untuk menyediakan semua dependencies

Diagram ini menunjukkan alur data dan dependencies yang jelas dari View → ViewModel → UseCase → Repository → Data Source, mengikuti prinsip MVVM + Clean Architecture.


🧠 Learnings used
Learnt from: nirwanadoteth
Repo: ebinugraha/HerbaMed-Jabar PR: 22
File: app/src/main/java/edu/unikom/herbamedjabar/adapter/HistoryAdapter.kt:44-45
Timestamp: 2025-09-01T08:33:28.199Z
Learning: In the HerbaMed-Jabar Android app, all fields in ScanHistory and AnalysisResult (plantName, content, benefit, warning, etc.) are generated exclusively by Gemini AI and cannot be edited by users, eliminating the need for HTML sanitization when rendering these fields.

@nirwanadoteth
Copy link
Collaborator

@coderabbitai untuk class diagram itu, apakah bisa hanya class-class yang utama saja, saya rasa versi yang lengkap itu tidak akan muat untuk saya masukkan ke dalam dokumen laporan.

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Tip

For best results, initiate chat on the files or code changes.

@nirwanadoteth, tentu! Berikut adalah Class Diagram versi simplified yang hanya menampilkan class-class utama:

classDiagram
    %% ============================================
    %% PRESENTATION LAYER - VIEW
    %% ============================================
    class MainActivity {
        <<Activity>>
        +onCreate()
        -setupBottomNavigation()
    }

    class ScanFragment {
        <<Fragment>>
        -scanViewModel: ScanViewModel
        +onViewCreated()
        -startCamera()
        -takePhoto()
    }

    class ForumFragment {
        <<Fragment>>
        -forumViewModel: ForumViewModel
        +onViewCreated()
        -observePosts()
    }

    class HistoryFragment {
        <<Fragment>>
        -historyViewModel: HistoryViewModel
        +onViewCreated()
        -observeHistory()
    }

    %% ============================================
    %% PRESENTATION LAYER - VIEWMODELS
    %% ============================================
    class AuthViewModel {
        <<ViewModel>>
        -firebaseAuth: FirebaseAuth
        +loginUser(email, password)
        +registerUser(name, email, password)
        +signInWithGoogleToken(idToken)
    }

    class ScanViewModel {
        <<ViewModel>>
        -analyzePlantUseCase: AnalyzePlantUseCase
        +analyzeImage(bitmap: Bitmap)
    }

    class ForumViewModel {
        <<ViewModel>>
        -postRepository: PostRepository
        +fetchPosts()
        +toggleLikeOnPost(postId)
        +deletePost(post)
    }

    class HistoryViewModel {
        <<ViewModel>>
        -plantRepository: PlantRepository
        +getAllHistory()
    }

    %% ============================================
    %% DOMAIN LAYER - USE CASES
    %% ============================================
    class AnalyzePlantUseCase {
        <<UseCase>>
        -plantRepository: PlantRepository
        +invoke(bitmap: Bitmap): AnalysisResult
    }

    %% ============================================
    %% DATA LAYER - REPOSITORIES
    %% ============================================
    class PlantRepository {
        <<Repository>>
        -generativeModel: GenerativeModel
        -scanHistoryDao: ScanHistoryDao
        +analyzePlant(bitmap, prompt): AnalysisResult
        +getAllHistory(): Flow
        +deleteHistory(history)
    }

    class PostRepository {
        <<Repository>>
        -firestore: FirebaseFirestore
        +getPosts(): Flow
        +createPost(...)
        +toggleLike(postId, userId)
        +deletePost(post)
    }

    %% ============================================
    %% DATA LAYER - DATABASE
    %% ============================================
    class AppDatabase {
        <<RoomDatabase>>
        +scanHistoryDao(): ScanHistoryDao
    }

    class ScanHistoryDao {
        <<DAO>>
        +insertHistory(scanHistory)
        +getAllHistory(): Flow
        +deleteHistory(scanHistory)
    }

    %% ============================================
    %% DATA LAYER - ENTITIES
    %% ============================================
    class ScanHistory {
        <<Entity>>
        +id: Int
        +resultText: String
        +imagePath: String
        +timestamp: Long
    }

    class Post {
        <<DataClass>>
        +id: String
        +userId: String
        +imageUrl: String
        +plantName: String
        +description: String
        +likes: List
    }

    class AnalysisResult {
        <<DataClass>>
        +resultText: String
        +imagePath: String
    }

    %% ============================================
    %% EXTERNAL SERVICES
    %% ============================================
    class FirebaseAuth {
        <<ExternalService>>
    }

    class FirebaseFirestore {
        <<ExternalService>>
    }

    class GenerativeModel {
        <<ExternalService>>
    }

    %% ============================================
    %% RELATIONSHIPS
    %% ============================================
    
    MainActivity *-- ScanFragment
    MainActivity *-- ForumFragment
    MainActivity *-- HistoryFragment

    ScanFragment --> ScanViewModel
    ForumFragment --> ForumViewModel
    HistoryFragment --> HistoryViewModel

    AuthViewModel --> FirebaseAuth
    ScanViewModel --> AnalyzePlantUseCase
    ForumViewModel --> PostRepository
    HistoryViewModel --> PlantRepository

    AnalyzePlantUseCase --> PlantRepository

    PlantRepository --> GenerativeModel
    PlantRepository --> ScanHistoryDao
    PlantRepository --> AnalysisResult
    PostRepository --> FirebaseFirestore
    PostRepository --> Post

    AppDatabase --> ScanHistoryDao
    ScanHistoryDao --> ScanHistory
Loading

Perbedaan dengan versi lengkap:

  1. Hanya 1 Activity (MainActivity) sebagai representasi layer View
  2. 3 Fragment utama yang mewakili fitur-fitur inti (Scan, Forum, History)
  3. 4 ViewModel utama untuk business logic
  4. 1 Use Case sebagai contoh domain layer
  5. 2 Repository untuk data layer
  6. Database & DAO yang esensial
  7. 3 Entity/Model utama
  8. 3 External Service yang krusial

Versi ini tetap menunjukkan arsitektur MVVM + Clean Architecture dengan jelas namun lebih ringkas dan cocok untuk dokumentasi laporan.


🧠 Learnings used
Learnt from: nirwanadoteth
Repo: ebinugraha/HerbaMed-Jabar PR: 22
File: app/src/main/java/edu/unikom/herbamedjabar/adapter/HistoryAdapter.kt:44-45
Timestamp: 2025-09-01T08:33:28.199Z
Learning: In the HerbaMed-Jabar Android app, all fields in ScanHistory and AnalysisResult (plantName, content, benefit, warning, etc.) are generated exclusively by Gemini AI and cannot be edited by users, eliminating the need for HTML sanitization when rendering these fields.

@nirwanadoteth
Copy link
Collaborator

@coderabbitai berikan deskripsi singkat untuk disisipkan setelah gambar (1 paragraf, 1-2 kalimat). Contoh (utk diagram activity) seperti ini:
"Di Gambar tersebut ada beberapa proses hasil breakdown dari proses-proses use case pada gambar sebelum nya, jadi di atas terdapat decision yang dimana ketika analisis tanaman selesai maka user bisa memilih apakah akan diposting atau tidak."

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Tip

For best results, initiate chat on the files or code changes.

@nirwanadoteth, berikut deskripsi singkat untuk class diagram:

"Diagram kelas di atas menunjukkan struktur utama aplikasi yang mengikuti arsitektur MVVM + Clean Architecture, di mana setiap layer (View, ViewModel, Domain, Repository) memiliki tanggung jawab yang terpisah dengan alur data yang jelas dari UI hingga data source. Fragment-fragment menggunakan ViewModel untuk business logic, ViewModel menggunakan Use Case dan Repository, sementara Repository berinteraksi dengan database lokal (Room) dan services eksternal (Firebase, Gemini AI)."


🧠 Learnings used
Learnt from: nirwanadoteth
Repo: ebinugraha/HerbaMed-Jabar PR: 22
File: app/src/main/java/edu/unikom/herbamedjabar/adapter/HistoryAdapter.kt:44-45
Timestamp: 2025-09-01T08:33:28.199Z
Learning: In the HerbaMed-Jabar Android app, all fields in ScanHistory and AnalysisResult (plantName, content, benefit, warning, etc.) are generated exclusively by Gemini AI and cannot be edited by users, eliminating the need for HTML sanitization when rendering these fields.

@nirwanadoteth
Copy link
Collaborator

@coderabbitai persingkat lagi!

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Tip

For best results, initiate chat on the files or code changes.

@nirwanadoteth, berikut deskripsi yang lebih singkat:

"Diagram menunjukkan arsitektur MVVM aplikasi dengan alur data dari View → ViewModel → Repository → Data Source (Room, Firebase, Gemini AI)."


🧠 Learnings used
Learnt from: nirwanadoteth
Repo: ebinugraha/HerbaMed-Jabar PR: 22
File: app/src/main/java/edu/unikom/herbamedjabar/adapter/HistoryAdapter.kt:44-45
Timestamp: 2025-09-01T08:33:28.199Z
Learning: In the HerbaMed-Jabar Android app, all fields in ScanHistory and AnalysisResult (plantName, content, benefit, warning, etc.) are generated exclusively by Gemini AI and cannot be edited by users, eliminating the need for HTML sanitization when rendering these fields.

@nirwanadoteth
Copy link
Collaborator

@copilot @coderabbitai gambar stuktur folder path app/src/main/java/edu/unikom/herbamedjabar

@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@nirwanadoteth, saya akan membuatkan diagram struktur folder untuk path tersebut.


🏁 Script executed:

#!/bin/bash
# Get the directory structure of the main package
tree -L 3 -I 'build|*.xml|*.gradle' app/src/main/java/edu/unikom/herbamedjabar/

Length of output: 949


🏁 Script executed:

#!/bin/bash
# Alternative if tree doesn't work - use fd to show structure
fd -t d . app/src/main/java/edu/unikom/herbamedjabar/ | sort

Length of output: 452


🏁 Script executed:

#!/bin/bash
# Get all files to show complete structure
fd . app/src/main/java/edu/unikom/herbamedjabar/ -t f -t d | sort

Length of output: 2489


@nirwanadoteth, berikut adalah struktur folder untuk app/src/main/java/edu/unikom/herbamedjabar:

graph TB
    root["📁 herbamedjabar"]
    
    root --> app["📄 HerbaAppApplication.kt"]
    
    root --> adapter["📁 adapter"]
    adapter --> adapter1["📄 HistoryAdapter.kt"]
    adapter --> adapter2["📄 PostAdapter.kt"]
    
    root --> dao["📁 dao"]
    dao --> dao1["📄 ScanHistoryDao.kt"]
    
    root --> data["📁 data"]
    data --> data1["📄 Post.kt"]
    data --> data2["📄 ScanHistory.kt"]
    
    root --> db["📁 db"]
    db --> db1["📄 AppDatabase.kt"]
    
    root --> di["📁 di"]
    di --> di1["📄 AppModule.kt"]
    
    root --> repo["📁 repository"]
    repo --> repo1["📄 PlantRepository.kt"]
    repo --> repo2["📄 PostRepository.kt"]
    
    root --> usecase["📁 useCase"]
    usecase --> usecase1["📄 AnalyzePlantUseCase.kt"]
    
    root --> view["📁 view"]
    view --> view1["📄 AuthActivity.kt"]
    view --> view2["📄 ForumFragment.kt"]
    view --> view3["📄 HistoryDetailFragment.kt"]
    view --> view4["📄 HistoryFragment.kt"]
    view --> view5["📄 LoginFragment.kt"]
    view --> view6["📄 MainActivity.kt"]
    view --> view7["📄 ProcessingDialogFragment.kt"]
    view --> view8["📄 ProfileFragment.kt"]
    view --> view9["📄 RegisterFragment.kt"]
    view --> view10["📄 ResultFragment.kt"]
    view --> view11["📄 ScanFragment.kt"]
    view --> view12["📄 SplashActivity.kt"]
    
    root --> vm["📁 viewModel"]
    vm --> vm1["📄 AuthViewModel.kt"]
    vm --> vm2["📄 ForumViewModel.kt"]
    vm --> vm3["📄 HistoryDetailViewModel.kt"]
    vm --> vm4["📄 HistoryViewModel.kt"]
    vm --> vm5["📄 ProfileViewModel.kt"]
    vm --> vm6["📄 ResultViewModel.kt"]
    vm --> vm7["📄 ScanViewModel.kt"]
    
    style root fill:`#e1f5ff`
    style adapter fill:`#fff4e1`
    style dao fill:`#fff4e1`
    style data fill:`#fff4e1`
    style db fill:`#fff4e1`
    style di fill:`#fff4e1`
    style repo fill:`#fff4e1`
    style usecase fill:`#fff4e1`
    style view fill:`#fff4e1`
    style vm fill:`#fff4e1`
Loading

Deskripsi:

Struktur folder aplikasi terorganisir berdasarkan arsitektur MVVM + Clean Architecture dengan 9 folder utama yang masing-masing memiliki tanggung jawab spesifik: view untuk UI layer, viewModel untuk presentation logic, useCase untuk business logic, repository untuk data access, data untuk entities, dao untuk database access, db untuk database configuration, di untuk dependency injection, dan adapter untuk RecyclerView adapters.


🧠 Learnings used
Learnt from: nirwanadoteth
Repo: ebinugraha/HerbaMed-Jabar PR: 22
File: app/src/main/java/edu/unikom/herbamedjabar/adapter/HistoryAdapter.kt:44-45
Timestamp: 2025-09-01T08:33:28.199Z
Learning: In the HerbaMed-Jabar Android app, all fields in ScanHistory and AnalysisResult (plantName, content, benefit, warning, etc.) are generated exclusively by Gemini AI and cannot be edited by users, eliminating the need for HTML sanitization when rendering these fields.

…djabar

Co-authored-by: nirwanadoteth <121574317+nirwanadoteth@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 25, 2026

@copilot @coderabbitai gambar stuktur folder path app/src/main/java/edu/unikom/herbamedjabar

Sudah ditambahkan di commit 2711933.

Struktur folder untuk path app/src/main/java/edu/unikom/herbamedjabar telah ditambahkan ke DIAGRAMS.md dengan:

  1. Tree structure text-based lengkap dengan deskripsi setiap file
  2. Mermaid diagram visual yang menampilkan hierarki folder dan file dengan color-coding berdasarkan layer (View: pink, ViewModel: purple, Repository: blue, dll)
  3. Penjelasan singkat tentang organisasi Clean Architecture

Total 10 folder dengan 30 file Kotlin tercakup dalam diagram.

@nirwanadoteth
Copy link
Collaborator

@coderabbitai gambarkan seperti list folder (kebawah)

@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2026

Tip

For best results, initiate chat on the files or code changes.

@nirwanadoteth, berikut adalah struktur folder dalam format list:

app/src/main/java/edu/unikom/herbamedjabar/
│
├── HerbaAppApplication.kt
│
├── adapter/
│   ├── HistoryAdapter.kt
│   └── PostAdapter.kt
│
├── dao/
│   └── ScanHistoryDao.kt
│
├── data/
│   ├── Post.kt
│   └── ScanHistory.kt
│
├── db/
│   └── AppDatabase.kt
│
├── di/
│   └── AppModule.kt
│
├── repository/
│   ├── PlantRepository.kt
│   └── PostRepository.kt
│
├── useCase/
│   └── AnalyzePlantUseCase.kt
│
├── view/
│   ├── AuthActivity.kt
│   ├── ForumFragment.kt
│   ├── HistoryDetailFragment.kt
│   ├── HistoryFragment.kt
│   ├── LoginFragment.kt
│   ├── MainActivity.kt
│   ├── ProcessingDialogFragment.kt
│   ├── ProfileFragment.kt
│   ├── RegisterFragment.kt
│   ├── ResultFragment.kt
│   ├── ScanFragment.kt
│   └── SplashActivity.kt
│
└── viewModel/
    ├── AuthViewModel.kt
    ├── ForumViewModel.kt
    ├── HistoryDetailViewModel.kt
    ├── HistoryViewModel.kt
    ├── ProfileViewModel.kt
    ├── ResultViewModel.kt
    └── ScanViewModel.kt

Penjelasan:

Struktur folder mengikuti prinsip Clean Architecture dengan separation of concerns: View layer (12 files UI), ViewModel layer (7 files presentation logic), UseCase layer (business logic), Repository layer (data access), Data layer (entities), DAO/DB layer (local database), DI layer (dependency injection), dan Adapter layer (RecyclerView).

Copilot AI changed the title Add comprehensive system documentation with ERD, DFD, flowmaps and UML diagrams Add comprehensive system documentation with ERD, DFD, flowmaps, UML diagrams and folder structure Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants