Skip to content

About

project pengembangan aplikasi management document BPP

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

420 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Document Management System (SimDoc)

A comprehensive Flutter-based document management application with Firebase integration, designed for efficient document storage, categorization, and user management following object-oriented design principles.

πŸ“‹ Table of Contents

πŸš€ Project Overview

Vision & Scope

SimDoc is a modern document management system that enables organizations to efficiently manage their digital documents with enterprise-grade security and user experience.

Target Users

  • Administrators: Full system access, user management, analytics
  • Regular Users: Document upload, download, view, and basic management

Core Problems Solved

  • Document Organization: Hierarchical categorization system
  • Access Control: Role-based permissions and security
  • Activity Tracking: Comprehensive audit trails
  • File Management: Upload, download, preview, and lifecycle management
  • User Management: Admin-controlled user provisioning and permissions

Key Features

  • πŸ” Secure Authentication: Firebase Auth with role-based access
  • πŸ“ Category Management: Hierarchical document organization
  • πŸ“€ File Upload/Download: Hybrid cloud processing for optimal performance
  • πŸ—‘οΈ Recycle Bin: Soft delete with recovery options
  • πŸ“Š Analytics Dashboard: Real-time statistics and insights
  • πŸ‘₯ User Management: Admin-controlled user provisioning
  • πŸ“± Activity Tracking: Comprehensive audit logs
  • πŸ” Search & Filter: Advanced document discovery
  • πŸ“‹ Responsive Design: Optimized for various screen sizes

πŸ—οΈ Architecture

Hybrid State Management Architecture

This application implements a Riverpod + BLoC Hybrid Architecture that combines the best of both state management solutions:

Riverpod Usage (Simple State & UI)

  • UI state management (loading, selections, form states)
  • Settings and preferences
  • Computed values and derived state
  • Simple data transformations
  • Provider composition and dependency injection

BLoC Usage (Complex Business Logic)

  • Authentication flows and user sessions
  • Document operations (CRUD, file processing)
  • Category management with real-time updates
  • User management and permissions
  • Sync operations and background tasks

Repository Pattern

  • Abstract data access layer
  • Firebase service abstraction
  • Consistent error handling
  • Caching and offline support
  • Testing and mocking capabilities

Clean Architecture Principles

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                Presentation             β”‚
β”‚  (Screens, Widgets, BLoC, Riverpod)    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                 Domain                  β”‚
β”‚     (Models, Repositories, Use Cases)   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                  Data                   β”‚
β”‚    (Firebase Services, Local Storage)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Technology Stack

  • Frontend: Flutter 3.8.0+ (Dart)
  • Backend: Firebase (Firestore, Storage, Authentication, Functions)
  • State Management: Riverpod + BLoC Hybrid
  • Local Storage: SharedPreferences
  • File Handling: Cross-platform file selection and processing
  • Cloud Functions: Node.js/TypeScript for server-side processing

🎯 Object-Oriented Design Patterns

Abstraction

The application uses abstract base classes to define common interfaces:

BaseNotifier (Riverpod)

abstract class BaseNotifier<T> extends StateNotifier<T> {
  void safeUpdate(T Function() updater);
  void handleError(Object error);
  void reset();
}

BaseBloc (BLoC)

abstract class BaseBloc<Event extends BaseEvent, State extends BaseState>
    extends Bloc<Event, State> {
  Future<void> onRefresh(Emitter<State> emit);
}

BaseRepository

abstract class BaseRepository {
  Future<T> executeWithTimeout<T>(Future<T> Function() operation);
  Future<T> executeWithRetry<T>(Future<T> Function() operation);
  Future<bool> isAvailable();
}

Encapsulation

Data and methods are properly encapsulated within classes:

  • Models: Private fields with public getters/setters
  • Services: Internal state hidden behind public interfaces
  • Providers: State encapsulated within notifiers
  • BLoCs: Business logic encapsulated within event handlers

Polymorphism

Multiple implementations share common interfaces:

  • Repository Pattern: Different data sources (Firebase, local storage)
  • File Processors: Various file type handlers
  • Authentication Methods: Multiple auth providers
  • State Notifiers: Different state management strategies

Inheritance

Class hierarchies provide code reuse and consistency:

  • BaseNotifier β†’ Feature-specific notifiers
  • BaseBloc β†’ Feature-specific BLoCs
  • BaseRepository β†’ Service-specific repositories
  • BaseState/BaseEvent β†’ Feature-specific states/events

πŸ“ Project Structure

Directory Organization

lib/
β”œβ”€β”€ core/                           # Core application components
β”‚   β”œβ”€β”€ bloc/                      # Base BLoC classes
β”‚   β”‚   β”œβ”€β”€ base_bloc.dart         # Abstract base BLoC
β”‚   β”‚   β”œβ”€β”€ base_event.dart        # Base event classes
β”‚   β”‚   └── base_state.dart        # Base state classes
β”‚   β”œβ”€β”€ config/                    # Configuration files
β”‚   β”‚   β”œβ”€β”€ anr_config.dart        # ANR prevention config
β”‚   β”‚   β”œβ”€β”€ cloud_functions_config.dart # Cloud Functions setup
β”‚   β”‚   └── feature_flags.dart     # Feature toggles
β”‚   β”œβ”€β”€ constants/                 # App constants
β”‚   β”‚   β”œβ”€β”€ app_colors.dart        # Color palette
β”‚   β”‚   β”œβ”€β”€ app_routes.dart        # Route definitions
β”‚   β”‚   └── app_strings.dart       # String constants
β”‚   β”œβ”€β”€ repositories/              # Base repository classes
β”‚   β”‚   └── base_repository.dart   # Abstract repository
β”‚   β”œβ”€β”€ riverpod/                  # Riverpod base classes
β”‚   β”‚   └── notifiers.dart         # Base notifiers
β”‚   β”œβ”€β”€ services/                  # Core services
β”‚   β”‚   β”œβ”€β”€ auth_service.dart      # Authentication service
β”‚   β”‚   β”œβ”€β”€ document_service.dart  # Document operations
β”‚   β”‚   β”œβ”€β”€ firebase_service.dart  # Firebase initialization
β”‚   β”‚   └── network_service.dart   # Network operations
β”‚   β”œβ”€β”€ utils/                     # Utility functions
β”‚   β”‚   β”œβ”€β”€ anr_prevention.dart    # ANR prevention utilities
β”‚   β”‚   β”œβ”€β”€ circuit_breaker.dart   # Circuit breaker pattern
β”‚   β”‚   └── debug_log_controller.dart # Logging utilities
β”‚   └── widgets/                   # Reusable core widgets
β”‚       β”œβ”€β”€ loading/               # Loading indicators
β”‚       β”œβ”€β”€ error/                 # Error handling widgets
β”‚       └── common/                # Common UI components
β”œβ”€β”€ features/                      # Feature-based organization
β”‚   β”œβ”€β”€ auth/                      # Authentication feature
β”‚   β”‚   β”œβ”€β”€ bloc/                  # Auth BLoC
β”‚   β”‚   β”œβ”€β”€ models/                # Auth models
β”‚   β”‚   β”œβ”€β”€ providers/             # Auth Riverpod providers
β”‚   β”‚   └── repositories/          # Auth repositories
β”‚   β”œβ”€β”€ documents/                 # Document management
β”‚   β”‚   β”œβ”€β”€ bloc/                  # Document BLoC
β”‚   β”‚   β”œβ”€β”€ models/                # Document models
β”‚   β”‚   β”œβ”€β”€ providers/             # Document providers
β”‚   β”‚   └── repositories/          # Document repositories
β”‚   β”œβ”€β”€ category/                  # Category management
β”‚   β”œβ”€β”€ users/                     # User management
β”‚   β”œβ”€β”€ upload/                    # File upload
β”‚   β”œβ”€β”€ sync/                      # Data synchronization
β”‚   β”œβ”€β”€ notification/              # Notifications
β”‚   β”œβ”€β”€ settings/                  # App settings
β”‚   └── file_selection/            # File selection
β”œβ”€β”€ models/                        # Shared data models
β”‚   β”œβ”€β”€ category_model.dart        # Category data structure
β”‚   β”œβ”€β”€ document_model.dart        # Document data structure
β”‚   β”œβ”€β”€ user_model.dart            # User data structure
β”‚   └── notification_model.dart    # Notification structure
β”œβ”€β”€ screens/                       # UI screens by feature
β”‚   β”œβ”€β”€ admin/                     # Admin screens
β”‚   β”‚   β”œβ”€β”€ user_management_screen.dart
β”‚   β”‚   β”œβ”€β”€ create_user_screen.dart
β”‚   β”‚   └── edit_user_screen.dart
β”‚   β”œβ”€β”€ auth/                      # Authentication screens
β”‚   β”‚   β”œβ”€β”€ splash_screen.dart
β”‚   β”‚   └── login_screen.dart
β”‚   β”œβ”€β”€ category/                  # Category screens
β”‚   β”‚   β”œβ”€β”€ manage_category_screen.dart
β”‚   β”‚   └── category_files_screen.dart
β”‚   β”œβ”€β”€ common/                    # Shared screens
β”‚   β”‚   β”œβ”€β”€ home_screen.dart       # Dashboard
β”‚   β”‚   └── file_preview_screen.dart
β”‚   β”œβ”€β”€ profile/                   # Profile screens
β”‚   β”œβ”€β”€ files/                     # File management screens
β”‚   β”œβ”€β”€ recycle_bin/               # Recycle bin screens
β”‚   β”œβ”€β”€ activity/                  # Activity screens
β”‚   └── upload/                    # Upload screens
β”œβ”€β”€ services/                      # Additional services
β”‚   β”œβ”€β”€ bulk_operations_service.dart
β”‚   β”œβ”€β”€ hybrid_upload_service.dart
β”‚   β”œβ”€β”€ file_download_service.dart
β”‚   └── share_service.dart
β”œβ”€β”€ widgets/                       # Feature-specific widgets
β”‚   β”œβ”€β”€ common/                    # Shared widgets
β”‚   β”‚   β”œβ”€β”€ app_scaffold_with_navigation.dart
β”‚   β”‚   β”œβ”€β”€ file_list_widget.dart
β”‚   β”‚   └── responsive_stats_grid.dart
β”‚   β”œβ”€β”€ statistics/                # Statistics widgets
β”‚   β”œβ”€β”€ notification/              # Notification widgets
β”‚   β”œβ”€β”€ upload/                    # Upload widgets
β”‚   └── user/                      # User widgets
└── utils/                         # App-specific utilities
    β”œβ”€β”€ filename_utils.dart
    β”œβ”€β”€ file_type_utils.dart
    └── date_utils.dart

πŸ”₯ Firebase Integration

Firestore Collections Structure

Core Collections

// Users collection
users/{userId} {
  id: string,
  email: string,
  fullName: string,
  role: 'admin' | 'user',
  status: 'active' | 'inactive',
  permissions: {
    documents: string[],
    categories: string[],
    system: string[]
  },
  createdAt: timestamp,
  lastLogin: timestamp
}

// Documents collection
documents/{documentId} {
  id: string,
  fileName: string,
  fileSize: number,
  fileType: string,
  filePath: string,
  uploadedBy: string,
  uploadedAt: timestamp,
  category: string,
  status: 'active' | 'deleted',
  isDeleted: boolean,
  deletedAt?: timestamp,
  deletedBy?: string,
  downloadUrl: string,
  metadata: object
}

// Categories collection
categories/{categoryId} {
  id: string,
  name: string,
  description: string,
  createdBy: string,
  createdAt: timestamp,
  permissions: string[],
  isActive: boolean,
  documentCount: number
}

// Activities collection
activities/{activityId} {
  id: string,
  type: 'login' | 'logout' | 'upload' | 'download' | 'delete' | 'view',
  userId: string,
  timestamp: timestamp,
  details: object,
  metadata: object
}

Backend Collections (Cloud Functions)

  • upload-statistics: Real-time file count tracking
  • file-validation-logs: Security monitoring
  • duplicate-cache: Duplicate file detection
  • storage_history: Storage analytics

Firebase Storage Organization

/documents/
β”œβ”€β”€ {categoryId}/           # Category-specific files
β”‚   └── {secureFileName}    # Sanitized file names
β”œβ”€β”€ profile_images/         # User profile images
β”‚   └── {userId}/
└── temp/                   # Temporary upload storage
    └── {userId}/

Security Rules

Firestore Rules

  • Authentication Required: All operations require valid authentication
  • Role-Based Access: Admin vs user permissions
  • Document Permissions: Category-level access control
  • Admin-Only Operations: Hard deletes, user management
  • Pagination Limits: Query size restrictions for performance

Storage Rules

  • File Type Validation: Allowed file types enforcement
  • Size Restrictions: 15MB file size limit
  • User Isolation: Users can only access their own files
  • Admin Override: Admins have full access

Cloud Functions

hybridProcessFileUpload

// Server-side file processing
export const processFileUpload = functions
  .runWith({ timeoutSeconds: 540, memory: '2GB' })
  .https.onCall(async (data, context) => {
    // Heavy server-side processing
    // File validation and metadata extraction
    // Firestore document creation
    // Storage organization
  });

Features:

  • File validation and sanitization
  • Metadata extraction
  • Duplicate detection
  • Security scanning
  • Firestore document creation
  • Storage path organization

πŸ”§ Installation & Setup

Prerequisites

  • Flutter SDK: 3.8.0 or higher
  • Dart SDK: Latest stable version
  • Development Environment: Android Studio / VS Code
  • Firebase Project: Configured with required services
  • Node.js: 16+ (for Cloud Functions development)

Environment Configuration

Development Environment

  1. Clone the repository

    git clone <repository-url>
    cd management-document-app
  2. Install Flutter dependencies

    flutter pub get
  3. Firebase Setup

    • Create Firebase project at Firebase Console
    • Enable Authentication, Firestore, Storage, and Functions
    • Download google-services.json for Android
    • Place in android/app/ directory
    • Download GoogleService-Info.plist for iOS
    • Place in ios/Runner/ directory
  4. Cloud Functions Setup

    cd functions
    npm install
    npm run build
    firebase deploy --only functions
  5. Firestore Security Rules

    firebase deploy --only firestore:rules
    firebase deploy --only storage

Production Environment

  1. Firebase Project Configuration

    • Separate production Firebase project
    • Production security rules
    • Performance monitoring enabled
    • Analytics configured
  2. Build Configuration

    • Release signing keys
    • ProGuard configuration
    • App bundle optimization

Running the Application

Development Mode

flutter run --debug

Release Mode

flutter run --release

Specific Platform

flutter run -d android    # Android device
flutter run -d ios        # iOS device
flutter run -d chrome     # Web browser

οΏ½ Page-by-Page Documentation

Authentication Flow

1. Splash Screen (screens/auth/splash_screen.dart)

Purpose: App initialization and authentication state checking

State Management:

  • BLoC: AuthBloc for authentication state
  • Riverpod: firebaseInitializationProvider for Firebase status

Widget Hierarchy:

SplashScreen
β”œβ”€β”€ Scaffold
β”‚   └── SafeArea
β”‚       └── Column
β”‚           β”œβ”€β”€ Logo (SVG)
β”‚           β”œβ”€β”€ Loading Indicator
β”‚           └── Version Text

Firebase Integration:

  • Firebase initialization check
  • Authentication state verification
  • Automatic navigation based on auth status

Navigation Flow:

  • Authenticated β†’ Home Screen
  • Unauthenticated β†’ Login Screen
  • Error β†’ Error handling with retry

2. Login Screen (screens/auth/login_screen.dart)

Purpose: User authentication with email/password

State Management:

  • BLoC: AuthBloc for login operations
  • Riverpod: authStateProvider for reactive auth state

Widget Hierarchy:

LoginScreen
β”œβ”€β”€ Scaffold
β”‚   └── SafeArea
β”‚       └── Form
β”‚           β”œβ”€β”€ Logo Section
β”‚           β”œβ”€β”€ Email TextFormField
β”‚           β”œβ”€β”€ Password TextFormField
β”‚           β”œβ”€β”€ Remember Me Checkbox
β”‚           β”œβ”€β”€ Login Button
β”‚           └── Forgot Password Link

Features:

  • Real-time email validation (specific domains)
  • Remember Me functionality with SharedPreferences
  • Forgot password modal with admin contact
  • Error handling with specific messages

OOP Patterns:

  • Encapsulation: Form validation logic encapsulated
  • Polymorphism: Different authentication methods

Dashboard & Home

3. Home Screen (screens/common/home_screen.dart)

Purpose: Main dashboard with statistics, search, and file listing

State Management:

  • BLoC: DocumentBloc, CategoryBloc, SyncBloc
  • Riverpod: currentUserSyncProvider, notificationProvider

Widget Hierarchy:

HomeScreen
β”œβ”€β”€ AppScaffoldWithNavigation
β”‚   β”œβ”€β”€ BellNotificationWidget
β”‚   β”œβ”€β”€ FileSelectionBar
β”‚   └── RefreshIndicator
β”‚       └── SingleChildScrollView
β”‚           β”œβ”€β”€ HomeGreetingSection
β”‚           β”œβ”€β”€ ResponsiveStatsGrid (Admin only)
β”‚           β”œβ”€β”€ HomeSearchSection
β”‚           └── HomeFileListSection

Components:

  • HomeGreetingSection: User greeting with profile access
  • ResponsiveStatsGrid: Statistics widgets (4 in top row, 2 in bottom)
  • HomeSearchSection: Search functionality
  • HomeFileListSection: Recent files with pagination

OOP Patterns:

  • Composition: Multiple specialized components
  • Inheritance: Extends StatefulWidget with RouteAware
  • Abstraction: Abstract file operations through services

File Management

4. Total Files Screen (screens/files/total_files_screen.dart)

Purpose: Complete file listing with search and filters

State Management:

  • BLoC: DocumentBloc for file operations
  • Riverpod: File selection state management

Widget Hierarchy:

TotalFilesScreen
β”œβ”€β”€ Scaffold (no bottom navigation)
β”‚   β”œβ”€β”€ AppBar with back button
β”‚   └── Column
β”‚       β”œβ”€β”€ SearchWidget
β”‚       β”œβ”€β”€ Title and Filter Section
β”‚       └── FileListSection

Features:

  • Search functionality
  • Category filtering
  • Bulk operations
  • Infinite scroll pagination

5. Recycle Bin Screen (screens/recycle_bin/recycle_bin_screen.dart)

Purpose: Manage deleted files with restore/permanent delete options

State Management:

  • BLoC: DocumentBloc for deleted documents
  • Riverpod: Bulk operations state

Widget Hierarchy:

RecycleBinScreen
β”œβ”€β”€ Scaffold (no bottom navigation)
β”‚   β”œβ”€β”€ AppBar with back button
β”‚   └── Column
β”‚       β”œβ”€β”€ QuickAccessWidget (4 cards, stats grid style)
β”‚       └── DeletedFilesList
β”‚           β”œβ”€β”€ Restore functionality
β”‚           └── Permanent delete (Admin only)

Features:

  • 7-day retention policy
  • Restore functionality
  • Admin-only permanent deletion
  • Activity logging for all operations

Category Management

6. Manage Categories Screen (screens/category/manage_category_screen.dart)

Purpose: Category CRUD operations and management

State Management:

  • BLoC: CategoryBloc for category operations
  • Riverpod: Category selection and UI state

Widget Hierarchy:

ManageCategoryScreen
β”œβ”€β”€ AppScaffoldWithNavigation
β”‚   β”œβ”€β”€ FloatingActionButton (Add Category)
β”‚   └── CategoryList
β”‚       β”œβ”€β”€ CategoryCard
β”‚       β”‚   β”œβ”€β”€ Category Info
β”‚       β”‚   β”œβ”€β”€ Document Count
β”‚       β”‚   └── Action Menu
β”‚       └── EmptyState

Features:

  • Real-time category updates
  • Document count tracking
  • Permission management
  • Category activation/deactivation

7. Category Files Screen (screens/category/category_files_screen.dart)

Purpose: Display files within a specific category

State Management:

  • BLoC: DocumentBloc with category filtering
  • Riverpod: File selection state

Navigation: Accessed via category selection with CategoryModel argument

User Management

8. Profile Screen (screens/profile/profile_screen.dart)

Purpose: User profile management and navigation hub

State Management:

  • Riverpod: currentUserSyncProvider, isAdminProvider

Widget Hierarchy:

ProfileScreen
β”œβ”€β”€ AppScaffoldWithNavigation
β”‚   └── SingleChildScrollView
β”‚       β”œβ”€β”€ ProfileSection (Avatar, Name, Role)
β”‚       β”œβ”€β”€ Personal Information Menu
β”‚       β”œβ”€β”€ User Management Menu (Admin only)
β”‚       β”œβ”€β”€ Activity Menu
β”‚       β”œβ”€β”€ Settings Menu
β”‚       └── Logout Button

Features:

  • Role-based menu visibility
  • Profile image management
  • Integrated user management access

9. User Management Screen (screens/admin/user_management_screen.dart)

Purpose: Admin-only user administration

State Management:

  • BLoC: UserBloc for user operations
  • Riverpod: User selection and filtering

Widget Hierarchy:

UserManagementScreen
β”œβ”€β”€ Scaffold (no bottom navigation)
β”‚   β”œβ”€β”€ AppBar with back button
β”‚   β”œβ”€β”€ FloatingActionButton (Create User)
β”‚   └── UserList
β”‚       β”œβ”€β”€ UserCard
β”‚       β”‚   β”œβ”€β”€ User Info
β”‚       β”‚   β”œβ”€β”€ Role Badge
β”‚       β”‚   β”œβ”€β”€ Status Indicator
β”‚       β”‚   └── Action Menu
β”‚       └── EmptyState

Features:

  • User creation, editing, deletion
  • Role management
  • Status control (active/inactive)
  • Bulk operations

Activity & Monitoring

10. Activity Screen (screens/activity/new_activity_page.dart)

Purpose: Display user activity logs with filtering and pagination

State Management:

  • BLoC: Activity-specific BLoC for activity operations
  • Riverpod: Activity filtering and pagination state

Widget Hierarchy:

NewActivityPage
β”œβ”€β”€ Scaffold (no bottom navigation)
β”‚   β”œβ”€β”€ AppBar with back button
β”‚   └── Column
β”‚       β”œβ”€β”€ QuickAccessWidget (4 cards, stats grid style)
β”‚       └── ActivityList
β”‚           β”œβ”€β”€ ActivityCard (color-coded icons)
β”‚           β”œβ”€β”€ Infinite Scroll (25 items per page)
β”‚           └── Skeleton Loading States

Features:

  • Activity type filtering (login, logout, upload, download, delete, view)
  • Color-coded icons for each activity type
  • 25 items per page with infinite scroll
  • Skeleton loading states
  • Lazy loading for performance

11. Upload Document Screen (screens/upload/upload_document_screen.dart)

Purpose: File upload with category selection and validation

State Management:

  • BLoC: UploadBloc for upload operations
  • Riverpod: File selection and upload progress

Widget Hierarchy:

UploadDocumentScreen
β”œβ”€β”€ AppScaffoldWithNavigation
β”‚   └── Form
β”‚       β”œβ”€β”€ File Selection Area
β”‚       β”œβ”€β”€ Category Dropdown
β”‚       β”œβ”€β”€ File Preview
β”‚       β”œβ”€β”€ Upload Progress
β”‚       └── Upload Button

Features:

  • Hybrid upload processing (client + cloud function)
  • File type validation (PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX)
  • 15MB size limit
  • Real-time upload progress
  • Category assignment

πŸ› οΈ Development Guidelines

Code Organization Principles

Feature-Based Structure

lib/features/{feature_name}/
β”œβ”€β”€ bloc/                  # BLoC for complex business logic
β”œβ”€β”€ models/                # Feature-specific models
β”œβ”€β”€ providers/             # Riverpod providers for simple state
β”œβ”€β”€ repositories/          # Data access layer
└── notifiers/             # StateNotifiers for mutable state

State Management Decision Tree

Simple State (UI, Settings) β†’ Riverpod
β”œβ”€β”€ Provider (immutable data)
β”œβ”€β”€ StateProvider (simple mutable state)
β”œβ”€β”€ FutureProvider (async data)
└── StreamProvider (reactive data)

Complex Business Logic β†’ BLoC
β”œβ”€β”€ Authentication flows
β”œβ”€β”€ File operations
β”œβ”€β”€ User management
└── Data synchronization

Naming Conventions

Riverpod Providers

// Pattern: {feature}{Type}Provider
final authStateProvider = StreamProvider<User?>(...);
final currentUserProvider = Provider<UserModel?>(...);
final settingsNotifierProvider = StateNotifierProvider<SettingsNotifier, SettingsState>(...);

BLoC Components

// Pattern: {Feature}Bloc, {Feature}Event, {Feature}State
class AuthBloc extends Bloc<AuthEvent, AuthState> { ... }
class AuthEvent { ... }
class AuthState { ... }

Repository Pattern

// Pattern: {Feature}Repository (abstract), {Feature}RepositoryImpl
abstract class DocumentRepository { ... }
class DocumentRepositoryImpl extends BaseRepository implements DocumentRepository { ... }

Error Handling Strategy

Centralized Error Handling

// Base classes provide consistent error handling
abstract class BaseNotifier<T> extends StateNotifier<T> {
  void handleError(Object error) {
    // Centralized error logging and user notification
  }
}

abstract class BaseBloc<Event, State> extends Bloc<Event, State> {
  void handleError(Object error, StackTrace stackTrace) {
    // Centralized error handling for BLoCs
  }
}

Error Recovery Patterns

  • Circuit Breaker: Prevent cascading failures
  • Retry Logic: Automatic retry with exponential backoff
  • Fallback States: Graceful degradation
  • User Feedback: Clear error messages and recovery actions

Performance Optimization

Memory Management

// Automatic disposal of resources
class MemoryManagementService {
  static void initialize() {
    // Memory monitoring and cleanup
  }
}

Network Optimization

// Optimized network service with caching
class OptimizedNetworkService {
  static void initialize() {
    // Request deduplication and caching
  }
}

ANR Prevention

// Application Not Responding prevention
class ANRPrevention {
  static Future<T?> executeWithTimeout<T>(
    Future<T> operation, {
    Duration timeout = const Duration(seconds: 10),
  }) async {
    // Timeout handling to prevent ANR
  }
}

πŸ§ͺ Testing Strategy

Testing Architecture

Unit Tests (Riverpod Providers)

// Test Riverpod providers
void main() {
  group('AuthProviders', () {
    test('currentUserProvider returns null when not authenticated', () {
      final container = ProviderContainer();
      final user = container.read(currentUserProvider);
      expect(user, isNull);
    });
  });
}

BLoC Tests

// Test BLoC using bloc_test package
void main() {
  group('AuthBloc', () {
    blocTest<AuthBloc, AuthState>(
      'emits [loading, authenticated] when login succeeds',
      build: () => AuthBloc(),
      act: (bloc) => bloc.add(Login(email: 'test@example.com', password: 'password')),
      expect: () => [
        AuthState.loading(),
        AuthState.authenticated(user: mockUser),
      ],
    );
  });
}

Integration Tests

// Test complete workflows
void main() {
  group('Document Upload Flow', () {
    testWidgets('uploads document successfully', (tester) async {
      // Test complete upload workflow
    });
  });
}

Performance Tests

// Performance benchmarking
void main() {
  group('Performance Tests', () {
    test('startup time is under 3 seconds', () async {
      final stopwatch = Stopwatch()..start();
      await initializeApp();
      stopwatch.stop();
      expect(stopwatch.elapsedMilliseconds, lessThan(3000));
    });
  });
}

Test Execution

# Run all tests
flutter test

# Run specific test file
flutter test test/unit/auth_test.dart

# Run with coverage
flutter test --coverage
genhtml coverage/lcov.info -o coverage/html

# Run integration tests
flutter drive --target=test_driver/app.dart

Performance Targets

  • Startup Time: < 3 seconds
  • Memory Usage: < 100MB baseline
  • Widget Rebuilds: < 5ms per rebuild
  • API Response: < 500ms average
  • Database Queries: < 20ms average

πŸš€ Deployment

Build Instructions

Development Build

flutter run --debug

Production Build

Android APK
flutter build apk --release
Android App Bundle
flutter build appbundle --release
iOS (macOS required)
flutter build ios --release

Build Configuration

  • Minimum SDK: Android 21 (Android 5.0)
  • Target SDK: Android 34
  • iOS Deployment Target: 12.0

Environment Configuration

Development Environment

# pubspec.yaml
environment:
  sdk: ">=3.0.0 <4.0.0"
  flutter: ">=3.8.0"

Production Deployment

  1. Firebase Project Setup

    • Production Firebase project
    • Security rules deployment
    • Cloud Functions deployment
    • Performance monitoring
  2. App Store Deployment

    • Code signing certificates
    • App Store Connect configuration
    • Release notes and metadata
  3. Google Play Deployment

    • Play Console setup
    • App signing by Google Play
    • Release tracks (internal, alpha, beta, production)

πŸ“‹ Dependencies

Core Dependencies

dependencies:
  # Flutter & Dart
  flutter:
    sdk: flutter

  # Firebase
  firebase_core: ^2.24.2
  firebase_auth: ^4.15.3
  cloud_firestore: ^4.13.6
  firebase_storage: ^11.5.6
  cloud_functions: ^4.6.6

  # State Management
  flutter_riverpod: ^2.4.9
  flutter_bloc: ^8.1.3
  equatable: ^2.0.5
  freezed_annotation: ^2.4.1

  # Local Storage
  shared_preferences: ^2.2.2

  # UI & Design
  google_fonts: ^6.1.0
  flutter_svg: ^2.0.9
  cached_network_image: ^3.3.0
  shimmer: ^3.0.0
  flutter_spinkit: ^5.2.0

  # File Handling
  file_selector: ^1.0.3
  image_picker: ^1.0.4
  path_provider: ^2.1.1
  permission_handler: ^11.1.0
  dio: ^5.3.3

  # Utilities
  intl: ^0.18.1
  uuid: ^4.2.1

Development Dependencies

dev_dependencies:
  flutter_test:
    sdk: flutter

  # Code Generation
  build_runner: ^2.4.7
  freezed: ^2.4.6
  json_annotation: ^4.8.1
  json_serializable: ^6.7.1

  # Testing
  bloc_test: ^9.1.5
  mocktail: ^1.0.1

  # Linting
  flutter_lints: ^3.0.1

πŸ”’ Security Features

Authentication & Authorization

  • Firebase Authentication: SCRYPT hashing with secure token management
  • Role-Based Access Control: Admin vs user permissions with granular controls
  • Session Management: Secure session handling with automatic timeout
  • Multi-Factor Authentication: Ready for MFA implementation

Data Security

  • File Type Validation: Strict file type enforcement (PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX)
  • Size Restrictions: 15MB file size limit with server-side validation
  • Content Scanning: File content validation through Cloud Functions
  • Secure Storage Paths: Organized storage with user isolation

Monitoring & Auditing

  • Activity Logging: Comprehensive audit trails for all user actions
  • Security Monitoring: Real-time security event tracking
  • Error Logging: Centralized error tracking and monitoring
  • Performance Monitoring: Application performance and health monitoring

πŸš€ Performance Optimizations

Memory Management

  • Automatic Disposal: Resource cleanup and memory management
  • Lazy Loading: On-demand provider initialization
  • Image Caching: Efficient image loading and caching
  • Memory Monitoring: Real-time memory usage tracking

Network Optimization

  • Request Deduplication: Prevent duplicate network requests
  • Caching Strategy: Intelligent caching for frequently accessed data
  • Offline Support: Graceful offline handling
  • Circuit Breaker: Prevent cascading failures

UI Performance

  • Widget Optimization: Efficient widget rebuilding
  • Skeleton Loading: Smooth loading states
  • Infinite Scroll: Optimized list rendering
  • ANR Prevention: Application Not Responding prevention

🀝 Contributing

Development Workflow

  1. Fork the repository
  2. Create a feature branch from develop
    git checkout -b feature/your-feature-name
  3. Follow coding standards
    • Use provided linting rules
    • Follow naming conventions
    • Add appropriate tests
  4. Commit with conventional commits
    git commit -m "feat: add user management functionality"
  5. Submit a pull request to develop branch

Code Review Process

  • All PRs require review from maintainers
  • Automated tests must pass
  • Code coverage should not decrease
  • Documentation updates required for new features

Issue Reporting

  • Use provided issue templates
  • Include reproduction steps
  • Provide environment details
  • Add relevant labels

πŸ“„ License

This project is licensed under the BAPELTAN License - see the LICENSE file for details.

πŸ“ž Support

Getting Help

  • Documentation: Check this README and inline code documentation
  • Issues: Create an issue in the repository for bugs or feature requests
  • Discussions: Use GitHub Discussions for questions and community support

Contact Information

  • Development Team: Contact through repository issues
  • Admin Support: web.hanif61@gmail.com (for password reset requests)

Resources


πŸ“Š Project Status

Version: 1.0.0 Last Updated: January 2025 Flutter Version: 3.8.0+ Dart Version: 3.0.0+ Firebase SDK: Latest stable

Architecture Status

  • βœ… Riverpod + BLoC Hybrid: Fully implemented
  • βœ… Repository Pattern: Complete
  • βœ… Clean Architecture: Established
  • βœ… Object-Oriented Design: Applied throughout

Feature Completion

  • βœ… Authentication: Complete with role-based access
  • βœ… Document Management: Full CRUD operations
  • βœ… Category System: Complete with permissions
  • βœ… User Management: Admin functionality complete
  • βœ… Activity Tracking: Comprehensive logging
  • βœ… File Upload/Download: Hybrid processing implemented
  • βœ… Recycle Bin: Soft delete with recovery
  • βœ… Responsive Design: Mobile-first approach

Developed with ❀️ using Flutter & Firebase © 2025 BAPELTAN - Document Management System

About

project pengembangan aplikasi management document BPP

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages