Skip to content

Repository files navigation

Dynamic Chat App - Project Structure

Overview

This Flutter project has been restructured to follow a professional, scalable architecture pattern. The new structure separates concerns, improves maintainability, and makes the codebase more organized.

New Directory Structure

lib/
├── core/                           # Core application components
│   ├── config/                     # Configuration files
│   │   ├── firebase_options.dart   # Firebase configuration
│   │   └── OneSignalAppCredentials.dart # OneSignal configuration
│   ├── theme/                      # App theming
│   │   └── theme.dart              # App theme configuration
│   ├── constants/                  # App constants (future use)
│   └── utils/                      # Utility functions (future use)
├── features/                       # Feature-based modules
│   ├── auth/                       # Authentication feature
│   │   ├── auth_gate.dart          # Authentication gate
│   │   ├── login_screen.dart       # Login screen
│   │   ├── signup_screen.dart      # Signup screen
│   │   ├── phone_auth_screen.dart  # Phone authentication
│   │   └── otp_screen.dart         # OTP verification
│   ├── chat/                       # Chat feature
│   │   ├── home_screen.dart        # Main chat list
│   │   ├── chat_screen.dart        # Individual chat
│   │   └── add_contact_screen.dart # Add new contact
│   ├── group/                      # Group chat feature
│   │   ├── create_group_screen.dart # Create new group
│   │   ├── group_info_screen.dart  # Group information
│   │   └── add_members_screen.dart # Add group members
│   └── profile/                    # User profile feature
│       └── profile_screen.dart     # User profile management
├── shared/                         # Shared components across features
│   ├── models/                     # Data models
│   │   ├── user_profile.dart       # User profile model
│   │   ├── message.dart            # Message model
│   │   └── group_profile.dart      # Group profile model
│   ├── services/                   # Business logic services
│   │   ├── auth_service.dart       # Authentication service
│   │   ├── chat_service.dart       # Chat functionality service
│   │   ├── storage_service.dart    # File storage service
│   │   ├── notification_service.dart # Push notification service
│   │   └── presence_service.dart   # User presence service
│   └── widgets/                    # Reusable UI components
│       ├── chat_bubble.dart        # Chat message bubble
│       ├── custom_textfield.dart   # Custom text input field
│       └── audio_player_bubble.dart # Audio message player
└── main.dart                       # App entry point

Architecture Benefits

1. Feature-Based Organization

  • Each feature (auth, chat, group, profile) is self-contained
  • Easy to locate and modify feature-specific code
  • Clear separation of concerns

2. Shared Components

  • Models, services, and widgets are shared across features
  • Reduces code duplication
  • Centralized business logic

3. Core Components

  • Configuration files are centralized
  • Theme and constants are easily accessible
  • Future utility functions can be added

4. Scalability

  • Easy to add new features
  • Clear structure for new developers
  • Maintainable as the project grows

Import Paths

Before (Old Structure)

import 'package:dynamichatapp/screens/login_screen.dart';
import 'package:dynamichatapp/services/auth_service.dart';
import 'package:dynamichatapp/models/user_profile.dart';
import 'package:dynamichatapp/widgets/custom_textfield.dart';

After (New Structure)

import 'package:dynamichatapp/features/auth/login_screen.dart';
import 'package:dynamichatapp/shared/services/auth_service.dart';
import 'package:dynamichatapp/shared/models/user_profile.dart';
import 'package:dynamichatapp/shared/widgets/custom_textfield.dart';

Key Changes Made

  1. Moved Configuration Files

    • OneSignalAppCredentials.dartcore/config/
    • firebase_options.dartcore/config/
  2. Organized Features

    • Auth screens → features/auth/
    • Chat screens → features/chat/
    • Group screens → features/group/
    • Profile screen → features/profile/
  3. Centralized Shared Components

    • Models → shared/models/
    • Services → shared/services/
    • Widgets → shared/widgets/
  4. Updated All Import Statements

    • All files now use the new import paths
    • No functionality was changed, only organization

Best Practices Followed

  1. Single Responsibility Principle

    • Each directory has a specific purpose
    • Files are organized by their function
  2. Dependency Management

    • Clear import paths
    • Reduced circular dependencies
  3. Scalability

    • Easy to add new features
    • Clear structure for team collaboration
  4. Maintainability

    • Logical file organization
    • Easy to locate and modify code

Future Enhancements

  1. Add Constants Directory

    • App-wide constants
    • API endpoints
    • Error messages
  2. Add Utils Directory

    • Helper functions
    • Extensions
    • Common utilities
  3. Feature-Specific Services

    • Move feature-specific logic to feature directories
    • Keep shared services in shared directory
  4. State Management

    • Add providers/bloc directories per feature
    • Centralized state management

Migration Notes

  • All existing functionality remains unchanged
  • Only file organization has been improved
  • Import statements have been updated throughout the codebase
  • No breaking changes to the application logic

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages