A modern, full-stack real-time messaging application built with Jetpack Compose and Spring Boot
Features β’ Tech Stack β’ Quick Setup β’ Documentation β’ Screenshots
- About
- Features
- Tech Stack
- Architecture
- Quick Setup
- Detailed Setup
- Usage
- API Documentation
- Troubleshooting
- Contributing
- License
Samvad (ΰ€Έΰ€ΰ€΅ΰ€Ύΰ€¦ - meaning "conversation" in Hindi) is a modern, full-stack real-time messaging application that enables users to communicate seamlessly through instant messaging. Built with cutting-edge technologies, it features a beautiful Material Design 3 UI on Android and a robust Spring Boot backend with WebSocket support for real-time communication.
- π Real-time messaging using WebSockets
- π Secure authentication with OTP and JWT tokens
- π± Modern Android UI built with Jetpack Compose
- ποΈ Clean Architecture following MVVM pattern
- π RESTful APIs for all backend operations
- πΎ PostgreSQL database for data persistence
- π¨ Material Design 3 UI components
- π§ Dependency Injection with Hilt/Dagger
- Phone number-based registration
- OTP verification (console-based for development)
- JWT token-based authentication
- Automatic token refresh
- Secure session management
- Real-time one-to-one messaging
- WebSocket-based instant delivery
- Message history persistence
- Read receipts support
- Typing indicators (ready to implement)
- Online/offline status tracking
- User profile creation and updates
- Contact search functionality
- User presence detection
- Profile picture support (ready to implement)
- Modern Material Design 3 interface
- Dark/Light theme support
- Smooth animations and transitions
- Intuitive navigation
- Responsive layouts
- Bottom navigation bar
| Technology | Description |
|---|---|
| Kotlin | Primary programming language |
| Jetpack Compose | Modern declarative UI framework |
| Material Design 3 | UI components and design system |
| MVVM Architecture | Clean architecture pattern |
| Hilt/Dagger | Dependency injection |
| Retrofit | HTTP client for REST APIs |
| OkHttp | WebSocket and HTTP client |
| Kotlin Coroutines | Asynchronous programming |
| Flow | Reactive data streams |
| Room | Local database (optional) |
| Coil | Image loading library |
| Navigation Compose | Navigation component |
| Technology | Description |
|---|---|
| Java 17 | Programming language |
| Spring Boot 3.2.0 | Backend framework |
| Spring Security | Authentication & authorization |
| Spring Data JPA | Data persistence |
| Spring WebSocket | Real-time communication |
| PostgreSQL | Relational database |
| JWT (jjwt) | Token-based authentication |
| Lombok | Boilerplate code reduction |
| Maven | Dependency management |
app/
βββ data/
β βββ local/ # Room database, SharedPreferences
β βββ remote/ # API services, WebSocket
β βββ repository/ # Repository implementations
βββ domain/
β βββ model/ # Domain models
β βββ repository/ # Repository interfaces
β βββ usecase/ # Business logic
βββ presentation/
β βββ auth/ # Login, OTP screens
β βββ chat/ # Chat list, conversation
β βββ profile/ # User profile screens
β βββ common/ # Shared UI components
βββ di/ # Dependency injection modules
backend/
βββ config/ # Configuration classes
βββ controller/ # REST API endpoints
βββ dto/ # Data transfer objects
βββ entity/ # JPA entities
βββ repository/ # Database repositories
βββ service/ # Business logic
βββ security/ # JWT, authentication
βββ websocket/ # WebSocket handlers
[Android App] <--REST API--> [Spring Boot Backend] <---> [PostgreSQL DB]
| |
β--------WebSocket-------------β
- Java 17 or higher
- Android Studio (latest version)
- PostgreSQL 14+ installed and running
- Git for version control
- Android SDK 24+ (for app)
-
Clone the repository
git clone https://github.com/yourusername/samvad.git cd samvad -
Setup PostgreSQL Database
# Create database and user psql -U postgres CREATE DATABASE samvad_db; CREATE USER samvad_user WITH PASSWORD 'samvad_password'; GRANT ALL PRIVILEGES ON DATABASE samvad_db TO samvad_user; \q
-
Configure Backend
cd backend/src/main/resources # Copy and edit application.properties # Update database credentials if needed
-
Start Backend Server
cd backend mvn clean install java -jar target/samvad-backend-1.0.0.jarOr use the batch file:
start-backend.bat
-
Open Android Project
# Open project in Android Studio # Wait for Gradle sync to complete # Run the app on emulator or device
-
Start Testing
- Register with a phone number (e.g.,
+919876543210) - Check backend console for OTP
- Enter OTP and start chatting!
- Register with a phone number (e.g.,
π For detailed setup instructions, see: FINAL_INSTALLATION_GUIDE.md
Create backend/src/main/resources/application.properties:
# Server Configuration
server.port=8080
# Database Configuration
spring.datasource.url=jdbc:postgresql://localhost:5432/samvad_db
spring.datasource.username=samvad_user
spring.datasource.password=samvad_password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
# JWT Configuration
jwt.secret=your-secret-key-here-make-it-long-and-secure
jwt.expiration=86400000
# Twilio Configuration (Optional)
twilio.account.sid=your_account_sid
twilio.auth.token=your_auth_token
twilio.phone.number=your_twilio_numbercd backend
mvn clean install
java -jar target/samvad-backend-1.0.0.jarThe server will start on http://localhost:8080
Edit app/build.gradle.kts:
buildConfigField("String", "BASE_URL", "\"http://10.0.2.2:8080/\"")- For Emulator: Use
http://10.0.2.2:8080/ - For Real Device: Use
http://YOUR_PC_IP:8080/
- Open project in Android Studio
- Wait for Gradle sync
- Build β Make Project
- Run on emulator or device
-
Register/Login
- Enter phone number
- Get OTP from backend console logs
- Verify OTP to login
-
Find Contacts
- Use search functionality
- Enter phone number of other user
- Start conversation
-
Send Messages
- Type message in input field
- Press send button
- Messages delivered in real-time via WebSocket
Option 1: Multiple Emulators
- Start 2 Android emulators
- Install app on both
- Register with different phone numbers
- Chat between them
Option 2: Emulator + Real Device
- Change BASE_URL to your PC's IP
- Install on both devices
- Register with different phone numbers
- Test real-time messaging
π For detailed usage guide, see: HOW_TO_START_CHATTING.md
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/send-otp |
Send OTP to phone number |
| POST | /api/auth/verify-otp |
Verify OTP and get JWT token |
| POST | /api/auth/refresh |
Refresh JWT token |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users |
Get all users |
| GET | /api/users/{userId} |
Get user profile |
| PUT | /api/users/{userId} |
Update user profile |
| GET | /api/users/phone/{phoneNumber} |
Find user by phone |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/messages |
Send a message |
| GET | /api/messages/chat/{userId} |
Get chat history |
| GET | /api/messages/user/{userId} |
Get all messages for user |
| PUT | /api/messages/{messageId}/read |
Mark message as read |
| Endpoint | Description |
|---|---|
/ws |
WebSocket connection for real-time messaging |
Example: Connect to WebSocket
val client = OkHttpClient()
val request = Request.Builder()
.url("ws://10.0.2.2:8080/ws")
.addHeader("Authorization", "Bearer $jwtToken")
.build()
val webSocket = client.newWebSocket(request, webSocketListener)Problem: Kotlin Symbol Processing fails during build
Solutions:
- Clean and rebuild project
- Invalidate caches and restart Android Studio
- Check Hilt/Dagger annotations are correct
- Ensure all dependencies are properly configured
# Clean project
./gradlew clean
# Rebuild
./gradlew buildπ See: KSP_ERROR_FIX_SUMMARY.md
Problem: App cannot connect to backend
Solutions:
- Verify backend is running:
netstat -ano | findstr :8080 - Check BASE_URL in
app/build.gradle.kts - For emulator, use
http://10.0.2.2:8080/ - For real device, use PC's IP address
- Disable firewall or allow port 8080
Problem: Real-time messages not working
Solutions:
- Check WebSocket endpoint:
ws://10.0.2.2:8080/ws - Verify JWT token is being sent
- Check backend logs for WebSocket connections
- Ensure Spring WebSocket is configured correctly
Problem: Backend cannot connect to PostgreSQL
Solutions:
- Verify PostgreSQL is running
- Check database credentials in
application.properties - Ensure database
samvad_dbexists - Test connection:
psql -U samvad_user -d samvad_db
π See: POSTGRESQL_SETUP.md
Problem: Cannot get OTP for login
Solution:
- OTP is printed in backend console logs (Twilio not configured)
- Look for:
OTP for +919876543210: 123456 - Copy the 6-digit code and enter in app
This project includes comprehensive documentation:
| Document | Description |
|---|---|
| FINAL_INSTALLATION_GUIDE.md | Complete installation guide |
| HOW_TO_START_CHATTING.md | Guide to start using the app |
| POSTGRESQL_SETUP.md | PostgreSQL database setup |
| POSTGRESQL_QUICK_GUIDE.md | Quick PostgreSQL reference |
| KSP_ERROR_FIX_SUMMARY.md | KSP build error solutions |
| CHAT_FIX_SUMMARY.md | Chat functionality fixes |
| TESTING_GUIDE.md | Testing procedures |
| START_TESTING_NOW.md | Quick testing guide |
Samvad/
βββ app/ # Android application
β βββ src/main/
β β βββ java/com/example/samvad/
β β β βββ data/ # Data layer
β β β βββ domain/ # Domain layer
β β β βββ presentation/ # UI layer
β β β βββ di/ # Dependency injection
β β βββ res/ # Resources
β βββ build.gradle.kts
βββ backend/ # Spring Boot backend
β βββ src/main/
β β βββ java/com/example/samvad/
β β β βββ config/
β β β βββ controller/
β β β βββ entity/
β β β βββ repository/
β β β βββ service/
β β β βββ security/
β β βββ resources/
β βββ pom.xml
βββ gradle/ # Gradle wrapper
βββ docs/ # Documentation
βββ README.md
# Debug build
./gradlew assembleDebug
# Release build
./gradlew assembleRelease
# Install on connected device
./gradlew installDebugcd backend
# Clean and compile
mvn clean compile
# Run tests
mvn test
# Package JAR
mvn package
# Skip tests
mvn package -DskipTests# Unit tests
./gradlew test
# Instrumentation tests
./gradlew connectedAndroidTestcd backend
mvn test- JWT tokens are used for authentication
- Passwords/OTPs are never logged in production
- WebSocket connections are authenticated
- Database credentials should be externalized
- Use HTTPS in production
- Implement proper input validation
- Enable SQL injection protection (JPA)
- Use environment variables for secrets
- Group messaging support
- Voice/video calling
- File sharing (images, documents)
- Push notifications (FCM)
- End-to-end encryption
- Message reactions and replies
- User stories/status
- Advanced search and filters
- Message backup and restore
- Multi-device support
- Desktop application (Electron)
- Web application (React/Vue)
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Kotlin coding conventions
- Use meaningful variable and function names
- Write unit tests for new features
- Update documentation as needed
- Follow Material Design guidelines for UI
This project is licensed under the MIT License - see the LICENSE file for details.
- Your Name - Initial work - GitHub Profile
- Android Jetpack team for amazing tools
- Spring Boot community for excellent documentation
- Material Design team for design guidelines
- All open-source contributors
If you encounter any issues or have questions:
- Check the documentation
- Review troubleshooting guide
- Search existing GitHub Issues
- Create a new issue with detailed information
π§ Active Development - This project is under active development. Features are being added regularly.
Made with β€οΈ by the Samvad Team
β Star this repo if you find it helpful!