A Flutter application for managing donations, built with MVVM architecture and GraphQL for efficient data handling. This project follows best practices to ensure maintainability, scalability, and clean code.
- View donation statistics and analytics.
- Add new donations with categories.
- Dark mode support.
- Real-time data fetching from a GraphQL backend.
- Modular architecture using MVVM.
This project is structured following the Model-View-ViewModel (MVVM) pattern with Riverpod for state management and GraphQL for API interactions.
lib/
├── core/
│ ├── models/ # Data models (Charity, etc.)
│ ├── services/ # External services (GraphQL, API clients, etc.)
│ ├── theme/ # Theme and UI settings
│
├── providers/ # Global providers for state management
│
├── repositories/ # Business logic and data handling
│ ├── charity_repository.dart
│
├── viewmodels/ # ViewModels (Handles state & business logic)
│ ├── charity_stats_view_model.dart
│
├── views/ # Screens (Only UI logic)
│ ├── charity_list_view.dart
│
├── widgets/ # Reusable UI components
│ ├── add_donation_dialog.dart
│ ├── analytics_tab.dart
│ ├── donations_chart.dart
│ ├── impact_metric.dart
│ ├── metric_card.dart
│ ├── overview_tab.dart
│ ├── recent_donations_list.dart
│
├── main.dart # App entry point
- Flutter (Framework for cross-platform development)
- Dart (Programming language)
- Riverpod (State management)
- GraphQL (Backend API communication)
- fl_chart (For graphical data visualization)
- flutter_riverpod (Dependency injection and state management)
- Flutter installed (Download Flutter)
- Dart SDK installed
- A GraphQL backend (Ensure the API is running)
- Clone the repository
git clone https://github.com/your-username/charity-app.git
cd charity-app
- Install dependencies
flutter pub get
- Run the app
flutter run
- Defines data structures for donations and related objects.
- Handles API calls (GraphQLService).
- Bridges services and ViewModels, ensuring separation of concerns.
- Contains state management and business logic (MVVM layer).
- UI screens, consuming data from ViewModels.
- Reusable UI components like charts, lists, and cards.
The app communicates with a GraphQL backend via GraphQLService.
Example Query (Fetching donations):
const String query = '''
query {
donations {
id
donorName
category
amount
month
}
}
''';
Example Mutation (Adding a donation):
const String mutation = '''
mutation AddDonation(\$donorName: String!, \$category: String!, \$amount: Float!) {
addDonation(donorName: \$donorName, category: \$category, amount: \$amount) {
id
donorName
category
amount
month
}
}
''';
- Modular structure allows for easy feature expansion.
- GraphQL support ensures dynamic and efficient data fetching.
- MVVM + Riverpod improves maintainability and state management.
- Reusable widgets allow for easy UI modifications.
Want to contribute? Follow these steps:
- Fork the repository.
- Create a new branch (
feature/new-feature
). - Commit your changes.
- Push to your fork and submit a pull request!
Developed by José Ángel Prieto. Feel free to connect on GitHub! 🚀
This project is licensed under the MIT License. You are free to use, modify, and distribute this code.