A fully functional, high-performance Reddit clone built natively for Android. This project demonstrates modern Android development practices, real-time database synchronization, and complex state management.
- Robust Authentication: Secure email/password login and registration.
- Real-time Feed: Scrollable, dynamic feed of user-generated posts ordered by timestamp.
- Optimistic UI Voting System: Lightning-fast upvote/downvote interactions. The UI updates instantly while Firestore transactions sync in the background to prevent race conditions and duplicate votes.
- Media Uploads: Users can upload images with their posts. Includes background image compression (WebP) to minimize bandwidth and storage costs.
- Smart Throttling: Built-in debounce and cooldown logic to prevent database spamming during rapid user interactions.
- Seamless State Management: Handles Android lifecycle events smoothly, pausing the task in the background rather than destroying it when navigating away.
- Language: Kotlin
- UI: XML / ViewBinding
- Backend: Firebase (Authentication, Firestore, Storage)
- Image Loading: Glide
- Image Compression: Zelory Compressor
- Asynchronous Programming: Kotlin Coroutines & Lifecycle Scopes
| Login Screen | Feed Layout | Image Upload |
|---|---|---|
![]() |
![]() |
![]() |
To ensure mathematical accuracy when multiple users vote on a viral post simultaneously, this app uses Firebase Transactions. It stores individual votes in a subcollection (/posts/{postId}/votes/{userId}) rather than just incrementing a single integer, preventing duplicate voting and race conditions.
To provide a zero-latency experience, UI elements (like the Reddit Orange upvote arrow) update instantly upon clicking. A 10-second local lockout prevents users from spamming the database, while background coroutines handle the server synchronization.
To run this project locally, you will need to connect it to your own Firebase project.
- Clone the repository:
git clone https://github.com/SujalSinghNegi/reddit.git
- Open the project in Android Studio.
- Go to the Firebase Console and create a new project.
- Add an Android app to the Firebase project and download the
google-services.jsonfile. - Place the
google-services.jsonfile into theapp/directory of this project. - Enable Authentication (Email/Password), Firestore, and Storage in your Firebase console.
- Sync the Gradle files and run the app on an emulator or physical device.
For the app to function correctly, ensure your Firestore rules are set up to handle the shallow subcollections:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Allows public read, authenticated create, and author-only delete
match /posts/{postId} {
allow read: if true;
allow create, update: if request.auth != null;
allow delete: if request.auth != null && request.auth.uid == resource.data.authorId;
}
// Secures individual user votes
match /posts/{postId}/votes/{voteUserId} {
allow read: if true;
allow write: if request.auth != null && request.auth.uid == voteUserId;
}
}
}

