Skip to main content

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:
app/src/main/java/com/rtech/threadly/

Package Organization

Core Packages

Contains all Activity classes organized by feature:
activities/
├── HomeActivity.java
├── AddPostActivity.java
├── AddStoryActivity.java
├── PostActivity.java
├── UserProfileActivity.java
├── NotificationActivity.java
├── FollowerFollowingList.java
├── authActivities/
│   ├── loginActivities/
│   ├── registerActivities/
│   └── forgetPassword/
├── Messenger/
├── CustomFeedActivity/
└── settings/
Purpose: Activities serve as entry points and host fragments. HomeActivity is the main container for the bottom navigation.
UI fragments organized by feature area:
fragments/
├── homeFragment.java
├── ReelsFragment.java
├── AddPostMainFragment.java
├── PostAddCameraFragment.java
├── UploadPostFinalFragment.java
├── UsersListFragment.java
├── MessageUserListFragment.java
├── profileFragments/
│   ├── profileFragment.java
│   ├── EditProfileMainFragment.java
│   ├── EditNameFragment.java
│   ├── EditBioFragment.java
│   ├── UsernameEditFragment.java
│   ├── ChangeProfileImageSelector.java
│   ├── ChangeProfileCameraFragment.java
│   └── profileUploadFinalPreview.java
├── searchFragments/
│   ├── searchFragment.java
│   └── ResultChildFragments/
├── MessageFragments/
├── CustomPostFeed/
├── storiesFragment/
├── notification/
├── follower_following_fragments/
├── settingFragments/
└── common_ui_pages/
Purpose: Reusable UI components that make up the app’s screens. Each fragment handles a specific piece of UI functionality.
ViewModel classes for MVVM architecture:
viewmodels/
├── ProfileViewModel.java
├── MessagesViewModel.java
├── CommentsViewModel.java
├── SearchViewModel.java
├── StoriesViewModel.java
├── ExplorePostsViewModel.java
├── ImagePostsFeedViewModel.java
├── VideoPostsFeedViewModel.java
├── InteractionNotificationViewModel.java
├── MessageAbleUsersViewModel.java
├── SuggestUsersViewModel.java
└── UsersMessageHistoryProfileViewModel.java
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.
RecyclerView adapters for displaying lists:
adapters/
├── postsAdapters/
├── commentsAdapter/
├── storiesAdapters/
├── messanger/
│   └── helpers/
├── NotificationAdapters/
├── followersAdapters/
├── followRequestsAdapter/
├── SearchPage/
├── mediaExplorerAdapter/
└── mscs/
Purpose: Bind data to RecyclerView components for efficient list rendering. Each adapter is specialized for its content type.
Data model classes (POJOs):
models/
├── Profile_Model.java
├── Posts_Model.java
├── ExtendedPostModel.java
├── Preview_Post_model.java
├── Comment_Model.java
├── Story_Model.java
├── Notification_Model.java
└── ... (other model classes)
Purpose: Plain Java objects representing data structures used throughout the app.
API communication and network layer:
network_managers/
├── AndroidNetworkingLayer.java
├── AuthManager.java
├── PostsManager.java
├── ProfileManager.java
├── MessageManager.java
├── CommentsManager.java
├── LikeManager.java
├── FollowManager.java
├── OtpManager.java
├── FcmManager.java
├── PrivacyManager.java
└── ... (other managers)
Purpose: Handle all HTTP requests and API interactions. Each manager focuses on a specific domain (posts, auth, messages, etc.).Example:
public class PostsManager {
    SharedPreferences loginInfo;
    
    public PostsManager() {
        loginInfo = Core.getPreference();
    }
    
    private String getToken() {
        return loginInfo.getString(
            SharedPreferencesKeys.JWT_TOKEN, 
            "null"
        );
    }
    
    public void uploadImagePost(
        File imagefile, 
        String caption, 
        NetworkCallbackInterfaceWithProgressTracking callback
    ) {
        String url = ApiEndPoints.ADD_IMAGE_POST;
        AndroidNetworking.upload(url)
            .setPriority(Priority.HIGH)
            .addHeaders("Authorization", "Bearer " + getToken())
            .addMultipartFile("image", imagefile)
            .addMultipartParameter("caption", caption)
            .build()
            .setUploadProgressListener((bytesUploaded, totalBytes) -> {
                callback.progress(bytesUploaded, totalBytes);
            })
            .getAsJSONObject(new JSONObjectRequestListener() {
                @Override
                public void onResponse(JSONObject response) {
                    callback.onSuccess(response);
                }
                // ... error handling
            });
    }
}

Data Layer Packages

Local database implementation using Room:
RoomDb/
├── DataBase.java          # Room database instance
├── schemas/               # Entity classes
│   ├── MessageSchema.java
│   ├── HistorySchema.java
│   └── NotificationSchema.java
└── Dao/                   # Data Access Objects
    ├── operator.java      # Message DAO
    ├── HistoryOperator.java
    └── NotificationDao.java
Purpose: Provides offline caching and persistence for messages, conversation history, and notifications.See Database Architecture for detailed information.
Plain Old Java Objects for data transfer:
POJO/
├── ConvMessageCounter.java
└── ... (other data transfer objects)
Purpose: Simple data containers, often used for Room query results or data transfer between layers.

Supporting Packages

Callback interfaces for component communication:
interfaces/
├── NetworkCallBacks/
│   ├── NetworkCallbackInterfaceJsonObject.java
│   └── NetworkCallbackInterfaceWithJsonObjectDelivery.java
├── NetworkCallbackInterface.java
├── NetworkCallbackInterfaceWithProgressTracking.java
├── FragmentItemClickInterface.java
├── OnDestroyFragmentCallback.java
├── Post_fragmentSetCallback.java
├── StoryOpenCallback.java
├── StoriesBackAndForthInterface.java
├── Comments/
│   └── RecyclerView/
│       └── replyClick/
├── Messanger/
└── general_ui_callbacks/
Purpose: Define contracts for callbacks, click handlers, and inter-component communication.
Utility classes and helper functions:
utils/
├── ReUsableFunctions.java
├── ExoplayerUtil.java
└── ... (other utilities)
Purpose: Common functionality used across the app like date formatting, validation, media utilities, etc.
Application constants and enums:
constants/
├── ApiEndPoints.java
├── SharedPreferencesKeys.java
├── HomeActivityFragmentsIdEnum.java
└── ... (other constants)
Purpose: Centralize constant values, API endpoints, and configuration keys.
Core application components:
core/
└── Core.java              # Application-wide utilities
Purpose: Provides global access to application context, shared preferences, and other core services.
Real-time WebSocket communication:
SocketIo/
└── ... (Socket.IO client implementation)
Purpose: Manages WebSocket connections for real-time messaging features.
Background services:
services/
└── ... (Service classes for FCM, etc.)
Purpose: Handle background operations like push notifications and long-running tasks.
WorkManager background jobs:
workers/
└── ... (Worker classes for scheduled tasks)
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.java or FeatureFragment.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.java or 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.java or FeatureOperator.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:
  1. HomeActivity hosts the fragment container
  2. profileFragment displays the UI and observes data
  3. ProfileViewModel manages data and state
  4. ProfileManager handles API calls
  5. API Endpoint provides remote data
  6. Room Database provides offline data
  7. 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

MVVM Pattern

Learn how ViewModels fit into the architecture

Database

Explore the Room Database structure

Architecture Overview

Understand the complete system design

Build docs developers (and LLMs) love