Overview
Threadly follows a feature-based and layer-based hybrid package structure, organizing code by both functionality and architectural layer. This approach makes it easy to locate related code and maintain clear boundaries between different parts of the application.Root Package Structure
All Java source code is located under:Package Organization
Core Packages
activities
activities
Contains all Activity classes organized by feature:Purpose: Activities serve as entry points and host fragments. HomeActivity is the main container for the bottom navigation.
fragments
fragments
UI fragments organized by feature area:Purpose: Reusable UI components that make up the app’s screens. Each fragment handles a specific piece of UI functionality.
viewmodels
viewmodels
ViewModel classes for MVVM architecture:Purpose: Manage UI-related data and business logic. ViewModels survive configuration changes and expose LiveData to the UI layer.See MVVM Pattern for implementation details.
adapters
adapters
RecyclerView adapters for displaying lists:Purpose: Bind data to RecyclerView components for efficient list rendering. Each adapter is specialized for its content type.
models
models
Data model classes (POJOs):Purpose: Plain Java objects representing data structures used throughout the app.
network_managers
network_managers
API communication and network layer:Purpose: Handle all HTTP requests and API interactions. Each manager focuses on a specific domain (posts, auth, messages, etc.).Example:
Data Layer Packages
RoomDb
RoomDb
Local database implementation using Room:Purpose: Provides offline caching and persistence for messages, conversation history, and notifications.See Database Architecture for detailed information.
POJO
POJO
Plain Old Java Objects for data transfer:Purpose: Simple data containers, often used for Room query results or data transfer between layers.
Supporting Packages
interfaces
interfaces
Callback interfaces for component communication:Purpose: Define contracts for callbacks, click handlers, and inter-component communication.
utils
utils
Utility classes and helper functions:Purpose: Common functionality used across the app like date formatting, validation, media utilities, etc.
constants
constants
Application constants and enums:Purpose: Centralize constant values, API endpoints, and configuration keys.
core
core
Core application components:Purpose: Provides global access to application context, shared preferences, and other core services.
SocketIo
SocketIo
Real-time WebSocket communication:Purpose: Manages WebSocket connections for real-time messaging features.
services
services
Background services:Purpose: Handle background operations like push notifications and long-running tasks.
workers
workers
WorkManager background jobs:Purpose: Execute scheduled background tasks like data sync, cleanup, etc.
File Naming Conventions
Activities
- Format:
FeatureActivity.java - Examples:
HomeActivity.java,PostActivity.java,UserProfileActivity.java
Fragments
- Format:
featureFragment.javaorFeatureFragment.java - Examples:
homeFragment.java,ReelsFragment.java,searchFragment.java
ViewModels
- Format:
FeatureViewModel.java - Examples:
ProfileViewModel.java,MessagesViewModel.java
Managers
- Format:
FeatureManager.java - Examples:
PostsManager.java,AuthManager.java
Adapters
- Format:
FeatureAdapter.javaor organized in feature folders - Examples:
postsAdapters/,commentsAdapter/
Models
- Format:
Feature_Model.java - Examples:
Profile_Model.java,Posts_Model.java
Room Entities
- Format:
FeatureSchema.java - Examples:
MessageSchema.java,NotificationSchema.java
DAOs
- Format:
FeatureDao.javaorFeatureOperator.java - Examples:
operator.java,NotificationDao.java,HistoryOperator.java
Project Statistics
Based on the source code structure:ViewModels
12+ ViewModels
Network Managers
10+ API Managers
Database Entities
3 Room Entities
Activity Features
9+ Main Activities
Fragment Features
20+ Fragment Groups
Adapter Types
10+ Adapter Categories
Architecture Flow Example
Here’s how a typical feature flows through the structure:- HomeActivity hosts the fragment container
- profileFragment displays the UI and observes data
- ProfileViewModel manages data and state
- ProfileManager handles API calls
- API Endpoint provides remote data
- Room Database provides offline data
- Entities define database schema
Benefits of This Structure
Feature Isolation
Related code is grouped together, making features easy to locate and modify
Scalability
New features can be added without affecting existing code structure
Team Collaboration
Multiple developers can work on different packages simultaneously
Testability
Clear separation makes unit testing and mocking straightforward
Maintenance
Issues can be quickly traced to the appropriate package
Code Reusability
Utilities, interfaces, and models are shared across features
Related Documentation
MVVM Pattern
Learn how ViewModels fit into the architecture
Database
Explore the Room Database structure
Architecture Overview
Understand the complete system design