A Flutter application demonstrating Clean Architecture principles in a simple surveys app for developers. This project was developed primarily as a learning exercise for Test-Driven Development (TDD), Clean Architecture, and other software engineering best practices.
This application allows users to participate in surveys. It features authentication, survey listing, and result visualization. The primary focus is on implementing a robust architecture rather than complex features.
The project strictly follows Clean Architecture principles with clear separation of concerns:
-
Domain Layer: Contains enterprise business rules, entities, and use case interfaces
domain/entities: Core business objectsdomain/usecases: Business rules and use case definitionsdomain/helpers: Domain-specific helper functions
-
Data Layer: Implements domain use cases and contains repositories
data/usecases: Implementation of domain use casesdata/models: Data models that implement domain entitiesdata/cache: Local data storage logicdata/http: HTTP client implementations
-
Presentation Layer: Contains presenters/controllers and presentation logic
presentation: Handles UI logic and state management
-
UI Layer: Flutter widgets and pages
ui/pages: Application screensui/components: Reusable UI componentsui/mixins: UI behavior mixinsui/helpers: UI-specific helper functions
-
Main Layer: Composition root and factories
main/factories: Factory methods for dependency injection
-
Infra Layer: Implementation details of external interfaces
infra: External services implementations
-
Validation Layer: Input validation logic
validation: Form and input validation
This application was built using:
- Test-Driven Development (TDD): All features were developed following the Red-Green-Refactor cycle
- Clean Architecture: Strict separation of concerns with dependency rules
- SOLID Principles: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
- Design Patterns: Various design patterns are implemented throughout the codebase
- DRY (Don't Repeat Yourself): Code reuse and abstraction
- KISS (Keep It Simple, Stupid): Simplicity in design
- YAGNI (You Aren't Gonna Need It): Only implementing necessary features
- SoC (Separation of Concerns): Clear boundaries between components
- DDD (Domain-Driven Design): Focus on core domain logic
- BDD (Behavior-Driven Development): Requirements specified as behaviors
The app is built with Flutter and uses FVM (Flutter Version Management) for version control:
- Flutter version: 2.5.1 (originally developed on 1.20.4)
- Dart SDK: >=2.12.0 <3.0.0 (with null safety)
- Flutter SDK
- FVM (recommended for version management)
- An IDE (VS Code, Android Studio, etc.)
- Clone the repository
- Install dependencies:
flutter pub get - Run the app:
flutter run
flutter test
- State Management: Provider and GetX
- HTTP Client: http package
- Local Storage: flutter_secure_storage and localstorage
- UI Components: carousel_slider
- Testing: mockito, faker, and network_image_mock
The project follows a feature-based organization within the Clean Architecture layers. Requirements and specifications are documented in the requirements directory, including use cases, BDD specs, and checklists.
This project serves as a practical example of implementing Clean Architecture in Flutter. It's recommended to explore the codebase, tests, and requirements to understand how these principles are applied in practice.