A comprehensive Spring Boot application for managing accommodation bookings with Stripe payment integration and Telegram notifications.
- 🏠 Accommodation Management - CRUD operations for managing rental properties
- 👥 User Management - Registration, authentication with JWT tokens, role-based access
- 📅 Booking System - Create, update, and manage accommodation bookings
- 💳 Stripe Integration - Secure payment processing through Stripe
- 📱 Telegram Notifications - Real-time notifications for bookings, payments, and system events
- 🔒 Security - JWT authentication, role-based authorization (Customer, Manager, Admin)
- 📊 Database - PostgreSQL with Liquibase migrations
- 📝 API Documentation - Swagger/OpenAPI integration
- Java 17
- Spring Boot 3.5.7
- Spring Security
- Spring Data JPA
- PostgreSQL
- Liquibase
- Stripe API
- Telegram Bots API
- JWT (JJWT)
- MapStruct
- Lombok
- Maven
- JDK 17+
- PostgreSQL 12+
- Maven 3.8+
- Stripe Account (test mode)
- Telegram Bot Token
git clone <repository-url>
cd booking-appCREATE DATABASE booking_app_db;- Open Telegram and search for @BotFather
- Send
/newbotcommand and follow instructions - Save the bot token
- Send
/startto your bot to get your Chat ID - Use the Chat ID in your
.envfile
- Create account at stripe.com
- Get your test API key from Dashboard > Developers > API keys
- Use the test secret key (starts with
sk_test_)
Copy .env.sample to .env and fill in your values:
cp .env.sample .envEdit .env:
# Database
DB_URL=jdbc:postgresql://localhost:5432/booking_app_db
DB_USERNAME=your_username
DB_PASSWORD=your_password
# JWT
JWT_SECRET=your_very_long_secret_key_at_least_256_bits
JWT_EXPIRATION=86400000
# Stripe
STRIPE_API_KEY=sk_test_your_stripe_key
# Telegram
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_BOT_USERNAME=your_bot_username
TELEGRAM_CHAT_ID=your_chat_id
# Application
APP_BASE_URL=http://localhost:8080./mvnw clean install
./mvnw spring-boot:runThe application will start on http://localhost:8080
Once the application is running, access Swagger UI at:
http://localhost:8080/swagger-ui/index.html
POST /api/auth/register- Register new userPOST /api/auth/login- Login and get JWT token
GET /api/users/me- Get current user profilePUT /api/users/me- Update user profilePUT /api/users/{id}/role- Update user role (Admin only)
POST /api/accommodations- Create accommodation (Admin only)GET /api/accommodations- List all accommodations (Public)GET /api/accommodations/{id}- Get accommodation details (Public)PUT /api/accommodations/{id}- Update accommodation (Admin only)DELETE /api/accommodations/{id}- Delete accommodation (Admin only)
POST /api/bookings- Create new bookingGET /api/bookings/my- Get my bookingsGET /api/bookings- Get all bookings with filters (Manager/Admin)GET /api/bookings/{id}- Get booking detailsPUT /api/bookings/{id}- Update bookingDELETE /api/bookings/{id}- Cancel booking
POST /api/payments- Create Stripe payment sessionGET /api/payments- Get payments listGET /api/payments/success- Handle successful payment (Stripe callback)GET /api/payments/cancel- Handle cancelled payment (Stripe callback)POST /api/payments/renew- Renew expired payment session
GET /api/health- Check application health
-
CUSTOMER (default)
- Create and manage own bookings
- View own payments
- Update profile
-
MANAGER
- All customer permissions
- View all bookings and payments
- Filter by user
-
ADMIN
- All manager permissions
- Manage accommodations (CRUD)
- Update user roles
- Schedule: Every day at 9:00 AM
- Action: Marks expired bookings as EXPIRED and releases accommodation availability
- Notification: Sends daily report to Telegram
- Schedule: Every minute
- Action: Marks expired payment sessions as EXPIRED
- Note: Stripe sessions expire after 24 hours
The application sends Telegram notifications for:
- New booking created
- Booking cancelled
- New accommodation added
- Accommodation released (after booking expiration)
- Payment session created
- Successful payment
- Daily expired bookings report
-
Bookings
- Cannot book in the past
- Check-out must be after check-in
- No overlapping bookings for same accommodation
- User cannot have pending bookings without payment
- Can only cancel future bookings
-
Payments
- One payment per booking
- Session expires after 24 hours
- Can renew expired sessions
- Booking confirmed only after successful payment
-
Accommodations
- Cannot delete with active bookings
- Availability automatically managed
- Only admins can modify
Run tests:
./mvnw testThe project uses Checkstyle for code quality:
./mvnw checkstyle:checkGitHub Actions workflow runs on every push and PR:
- Builds the project
- Runs tests
- Checks code style
Build and run with Docker:
docker-compose up -dFor production deployment, ensure these variables are set:
- Use strong JWT secret (256+ bits)
- Use production Stripe keys
- Set proper database credentials
- Configure correct base URL
- Secure Telegram bot token
- JWT tokens stored client-side
- Passwords hashed with BCrypt
- Role-based access control
- Soft delete for sensitive data
- API rate limiting recommended for production
./mvnw liquibase:clearCheckSums- Verify PostgreSQL is running
- Check database credentials in
.env - Ensure database exists
- Verify bot token is correct
- Check chat ID matches your conversation
- Ensure bot has permission to send messages
- Use test mode credentials
- Check Stripe dashboard for session details
- Verify webhook URLs if configured
This project is licensed under the MIT License.