A peer-to-peer file sharing application built with Spring Boot that enables secure file sharing between users through rooms with real-time notifications.
- Room-based File Sharing: Create or join rooms to share files with specific groups
- Secure Authentication: JWT-based authentication with OTP verification via Twilio
- File Upload/Download: Upload files to AWS S3 with chunked upload support
- Real-time Notifications: WebSocket-based real-time updates for file operations
- File Access Control: Offer/accept/reject mechanism for file sharing
- Multi-device Support: Device-based login system for seamless access
- Peer Management: Register and manage peers within rooms
- Backend: Spring Boot 4.0.2, Java 17
- Database: PostgreSQL with JPA/Hibernate
- Cache: Redis
- File Storage: AWS S3
- Authentication: JWT with Twilio OTP
- Real-time: WebSocket
- Message Queue: Apache Kafka
- Build Tool: Gradle
- Java 17+
- PostgreSQL
- Redis
- AWS S3 bucket
- Twilio account (for OTP)
-
Clone the repository
git clone <repository-url> cd OpShare
-
Set up environment variables
export AWS_ACCESS_KEY_ID=your_aws_access_key export AWS_SECRET_ACCESS_KEY=your_aws_secret_key export JWT_SECRET=your_jwt_secret_key export TWILIO_ACCOUNT_SID=your_twilio_account_sid export TWILIO_AUTH_TOKEN=your_twilio_auth_token export TWILIO_VERIFY_SERVICE_SID=your_twilio_verify_service_sid
-
Configure database
- Create a PostgreSQL database named
postgres - Update
application.propertieswith your database credentials
- Create a PostgreSQL database named
-
Start Redis server
redis-server
-
Build and run the application
./gradlew bootRun
The application will start on http://localhost:8080
POST /auth/send-otp- Send OTP for phone verificationPOST /auth/verify-otp- Verify OTP and register userPOST /auth/login- Login with credentialsPOST /auth/device-login- Device-based login
POST /rooms- Create a new roomPOST /rooms/{roomId}/join- Join a roomPOST /rooms/{roomId}/leave- Leave a roomGET /rooms/{roomId}/peers- Get room peers
POST /files/upload/{roomId}- Upload file to roomPOST /files/offer- Offer file to peerPOST /files/{fileId}/accept- Accept file offerPOST /files/{fileId}/reject- Reject file offerGET /files/{fileId}/download- Get download URLGET /files/room/{roomId}- Get files in roomGET /files/pending-offers- Get pending file offersDELETE /files/{fileId}- Delete file
POST /chunked-upload/init- Initialize chunked uploadPOST /chunked-upload/chunk- Upload file chunkPOST /chunked-upload/complete- Complete chunked upload
POST /peers/register- Register peerPUT /peers/{peerId}- Update peer infoGET /peers- Get all peers
Key configuration properties in application.properties:
# Database
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=1234
# Redis
spring.data.redis.host=localhost
spring.data.redis.port=6379
# AWS S3
aws.s3.bucket-name=opshare-files
aws.s3.region=ap-south-1
aws.s3.presigned-url-expiration-minutes=260
# JWT
jwt.expiration-hours=24The application supports real-time communication through WebSocket:
- File upload progress
- Room events (join/leave)
- File offer notifications
- Peer status updates
src/main/java/com/example/OpShare/
├── config/ # Configuration classes
├── controller/ # REST controllers
├── dto/ # Data transfer objects
├── entity/ # JPA entities
├── repository/ # Data repositories
├── service/ # Business logic
└── exception/ # Exception handlers
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License.