Skip to content

Latest commit

ย 

History

History
297 lines (255 loc) ยท 8.51 KB

File metadata and controls

297 lines (255 loc) ยท 8.51 KB

BlogApp - Android Blogging Platform

A modern Android blogging platform built with Jetpack Compose, Firebase, and MVVM architecture.

๐Ÿ“‹ Project Structure

app/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main/
โ”‚   โ”‚   โ”œโ”€โ”€ java/com/blogapp/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ BlogApplication.kt
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ di/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ AppModule.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ FirebaseModule.kt
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ data/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ model/
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ User.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ BlogPost.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Like.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Favorite.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ repository/
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ AuthRepository.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ BlogRepository.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ UserRepository.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ remote/
โ”‚   โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ FirebaseService.kt
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ MainActivity.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ navigation/
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ NavGraph.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ theme/
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Color.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Theme.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Type.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ screens/
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth/
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ LoginScreen.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ SignUpScreen.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ AuthViewModel.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ home/
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ HomeScreen.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ HomeViewModel.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ create/
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ CreatePostScreen.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ CreatePostViewModel.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ detail/
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ PostDetailScreen.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ PostDetailViewModel.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ profile/
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ProfileScreen.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ProfileViewModel.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ favorites/
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ FavoritesScreen.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ FavoritesViewModel.kt
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ BlogPostCard.kt
โ”‚   โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ MarkdownEditor.kt
โ”‚   โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ LoadingIndicator.kt
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ util/
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ Constants.kt
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ Resource.kt
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ MarkdownRenderer.kt
โ”‚   โ”‚   โ””โ”€โ”€ res/
โ”‚   โ”‚       โ”œโ”€โ”€ values/
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ strings.xml
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ themes.xml
โ”‚   โ”‚       โ””โ”€โ”€ drawable/
โ”‚   โ””โ”€โ”€ build.gradle.kts
โ”œโ”€โ”€ build.gradle.kts
โ””โ”€โ”€ google-services.json

๐Ÿš€ Features Implemented

Core Features

โœ… User Authentication (Firebase Auth)

  • Email/password sign-up
  • Email/password login
  • Password reset
  • Session persistence

โœ… Blog Post Management

  • Create posts with title, content, images
  • Edit existing posts
  • Delete posts
  • Markdown support for rich text
  • Draft saving
  • Publish/unpublish functionality

โœ… Blog Feed & Discovery

  • Recent posts display
  • Category filtering
  • Search functionality
  • Pull-to-refresh
  • Post previews

โœ… Blog Interaction

  • View full posts
  • Like/unlike posts
  • Favorite/unfavorite posts
  • View liked/favorited posts
  • Like count display

โœ… Data Management

  • Firestore integration
  • Real-time updates
  • Offline support

โœ… Architecture

  • MVVM pattern
  • Jetpack Compose UI
  • Hilt dependency injection

Bonus Features

๐ŸŽ Comment System ๐ŸŽ Push Notifications ๐ŸŽ Dark Mode ๐ŸŽ Share Functionality ๐ŸŽ Reading Time Estimate

๐Ÿ›  Technology Stack

  • Language: Kotlin
  • UI Framework: Jetpack Compose
  • Architecture: MVVM
  • Dependency Injection: Hilt
  • Authentication: Firebase Auth
  • Database: Cloud Firestore
  • Storage: Firebase Storage
  • Markdown: Markwon
  • Image Loading: Coil
  • Async: Coroutines & Flow

๐Ÿ“ฆ Dependencies

// Firebase
implementation(platform("com.google.firebase:firebase-bom:32.7.0"))
implementation("com.google.firebase:firebase-auth-ktx")
implementation("com.google.firebase:firebase-firestore-ktx")
implementation("com.google.firebase:firebase-storage-ktx")

// Jetpack Compose
implementation("androidx.compose.ui:ui:1.5.4")
implementation("androidx.compose.material3:material3:1.1.2")
implementation("androidx.navigation:navigation-compose:2.7.5")

// Hilt
implementation("com.google.dagger:hilt-android:2.48")
kapt("com.google.dagger:hilt-compiler:2.48")
implementation("androidx.hilt:hilt-navigation-compose:1.1.0")

// Markdown
implementation("io.noties.markwon:core:4.6.2")
implementation("io.noties.markwon:editor:4.6.2")

// Coil for image loading
implementation("io.coil-kt:coil-compose:2.5.0")

๐Ÿ”ง Setup Instructions

1. Prerequisites

  • Android Studio Hedgehog or later
  • JDK 17 or later
  • Android SDK 24+

2. Firebase Setup

  1. Create a Firebase project at Firebase Console
  2. Add an Android app to your Firebase project
  3. Download google-services.json and place it in app/ directory
  4. Enable Email/Password authentication in Firebase Console
  5. Create a Firestore database
  6. Set up Firebase Storage

3. Firestore Security Rules

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{userId} {
      allow read: if request.auth != null;
      allow write: if request.auth.uid == userId;
    }
    
    match /posts/{postId} {
      allow read: if resource.data.isPublished == true || request.auth.uid == resource.data.authorId;
      allow create: if request.auth != null;
      allow update, delete: if request.auth.uid == resource.data.authorId;
    }
    
    match /likes/{likeId} {
      allow read: if request.auth != null;
      allow create, delete: if request.auth.uid == request.resource.data.userId;
    }
    
    match /favorites/{favoriteId} {
      allow read: if request.auth != null;
      allow create, delete: if request.auth.uid == request.resource.data.userId;
    }
  }
}

4. Build & Run

# Clone the repository
git clone https://github.com/yourusername/blogapp.git

# Open in Android Studio
# Sync Gradle files
# Run on emulator or device

๐Ÿ“ฑ App Screenshots

Authentication Flow

  • Login Screen
  • Sign Up Screen
  • Password Reset

Main Features

  • Home Feed with blog posts
  • Create/Edit Post Screen
  • Post Detail View
  • User Profile
  • Favorites Collection

๐Ÿ— Architecture Overview

MVVM Pattern

View (Composables) โ† ViewModel โ† Repository โ† Data Source (Firebase)

Data Flow

  1. User interacts with UI (View)
  2. View calls ViewModel methods
  3. ViewModel calls Repository methods
  4. Repository interacts with Firebase
  5. Data flows back through LiveData/StateFlow
  6. UI updates automatically

๐Ÿ“ Data Models

User

data class User(
    val userId: String = "",
    val email: String = "",
    val displayName: String = "",
    val profileImageUrl: String = "",
    val createdAt: Timestamp = Timestamp.now(),
    val updatedAt: Timestamp = Timestamp.now()
)

BlogPost

data class BlogPost(
    val postId: String = "",
    val authorId: String = "",
    val authorName: String = "",
    val title: String = "",
    val content: String = "",
    val excerpt: String = "",
    val imageUrl: String = "",
    val categories: List<String> = emptyList(),
    val tags: List<String> = emptyList(),
    val likeCount: Int = 0,
    val isPublished: Boolean = false,
    val createdAt: Timestamp = Timestamp.now(),
    val updatedAt: Timestamp = Timestamp.now()
)

๐Ÿ› Known Issues

  • Image upload may take time on slow connections
  • Markdown preview updates with slight delay
  • Search is case-sensitive

๐Ÿ”ฎ Future Enhancements

  • Offline mode with sync
  • Rich media embeds (YouTube, Twitter)
  • Multi-language support
  • Advanced analytics
  • Social sharing improvements

๐Ÿ“„ License

MIT License

๐Ÿ‘ฅ Contributors

Your Name - GitHub

๐Ÿ“ž Support

For issues and questions, please open an issue on GitHub.