A modern real-time chat application built with Flutter and Firebase, featuring a clean architecture, robust authentication, and real-time messaging capabilities.
Novatech Chat is a full-featured chat application that demonstrates modern Flutter development practices and architectural patterns. The app includes:
- Real-time messaging with Firebase Firestore
- Authentication with both Google Sign-in and Email/Password
- User presence system (online/offline status)
- Clean and modern UI using shadcn_ui
- Form validation using Formz
- Comprehensive test coverage
The project follows Clean Architecture principles, separated into distinct layers:
lib/
βββ app/ # App initialization and configuration
βββ authentication/ # Authentication feature
β βββ bloc/ # Authentication business logic
β βββ view/ # Authentication UI components
β βββ models/ # Authentication-related models
βββ core/ # Core functionality and shared code
β βββ data/
β β βββ datasource/ # Remote data sources
β β βββ repository/ # Repository implementations
β βββ domain/
β βββ models/ # Domain entities
β βββ usecase/ # Business logic use cases
βββ chats/ # Chat feature
β βββ bloc/
β βββ view/
β βββ models/
βββ register/ # User registration feature
βββ bloc/
βββ view/
βββ models/
βββββββββββββββββββ ββββββββββββββββ ββββββββββββββββββ
β UI Layer β β BLoC Layer β β Repository β
β (Flutter Views)ββββββΆβ(Business ββββββΆβ Layer β
β β β Logic) β β β
βββββββββββββββββββ ββββββββββββββββ ββββββββββββββββββ
β
βΌ
ββββββββββββββββββ
β Data Sources β
β (Firebase) β
ββββββββββββββββββ
- BLoC Pattern: Chosen for its clear separation of concerns and excellent testability
- Formz: Used for form validation to maintain consistent validation logic across the app
- Dual authentication methods (Google & Email/Password) for flexibility
- Firebase Auth for secure user management
- User profiles stored in Firestore to maintain additional user data
- Firebase Firestore for real-time messages and user presence
- Optimistic UI updates for better user experience
- Batch operations for efficient database access
- Comprehensive unit tests for business logic
- Integration tests for critical user flows
- Mock repositories for isolated testing
To run the app with Firebase Emulator Suite:
-
Install Firebase CLI:
npm install -g firebase-tools
-
Login to Firebase:
firebase login
-
Initialize Firebase project:
firebase init emulators
-
Start the emulators with data persistence:
firebase emulators:start --import=./firebase-data --export-on-exit=./firebase-data
This will:
- Start Authentication and Firestore emulators
- Import existing data from ./firebase-data (if it exists)
- Export data to ./firebase-data when stopping
The emulators will run on these default ports:
- Authentication: 9099
- Firestore: 8080
- UI: 4000
You can configure these in firebase.json
:
{
"emulators": {
"auth": {
"port": 9099
},
"firestore": {
"port": 8080
},
"ui": {
"port": 4000
}
}
}
This project contains 3 flavors:
- development (uses emulators)
- staging
- production
To run the desired flavor:
# Development (with emulators)
flutter run --flavor development --target lib/main_development.dart
# Staging
flutter run --flavor staging --target lib/main_staging.dart
# Production
flutter run --flavor production --target lib/main_production.dart
Run all tests with coverage:
flutter test --coverage --test-randomize-ordering-seed random
View coverage report:
genhtml coverage/lcov.info -o coverage/
This project is licensed under the MIT License - see the LICENSE file for details.