A Java-based REST API for managing travel rewards, built with Jakarta EE (JAX-RS) and JPA. This API provides complete CRUD operations for managing travel reward programs.
- Jakarta EE (JAX-RS) for REST endpoints
- JPA (Java Persistence API) for database persistence
- MariaDB as the database
- Gson for JSON serialization/deserialization
- CORS enabled for cross-origin requests
- Install XAMPP if not already installed
- Start Apache and MySQL services in XAMPP Control Panel
- Access phpMyAdmin at http://localhost/phpmyadmin
- Create a new database named
travelexperts
- Import the SQL file from
src/main/resources/database/travelexperts.sql
- Install MariaDB Server from the official website
- Create a new database named
travelexperts
- Import using command line:
mysql -u root -p travelexperts < src/main/resources/database/travelexperts.sql
Note: This project uses default local development credentials. In a production environment, credentials would be properly secured using environment variables or secure configuration management.
- GET
/api/rewards
- Returns a list of all rewards in JSON format
- GET
/api/rewards/get/{rewardId}
- Returns a single reward by ID
- POST
/api/rewards/post
- Creates a new reward
- Requires JSON body with reward details
- PUT
/api/rewards/put
- Updates an existing reward
- Requires JSON body with updated reward details
- DELETE
/api/rewards/delete/{rewardId}
- Deletes a reward by ID
{
"rwdName": "Gold Member",
"rwdDesc": "Special rewards for gold members"
}
- Clone the repository
- Set up the database using one of the options above
- Configure database connection in
persistence.xml
if needed- Default configuration uses local development settings
- For production, credentials should be externalized
- Build and run the project using your preferred IDE
This project demonstrates API development in a local environment. In a production setting:
- Database credentials would be managed through environment variables
- CORS settings would be more restrictive
- Additional security measures like authentication would be implemented
This API includes CORS configuration to allow cross-origin requests, making it suitable for use with separate frontend applications (Web and Android clients).
- Web Client Repository - Web frontend application
- Android Client Repository - Mobile client application