Table of Contents
A distributed application to manage a car rental agency with multiple branches nationwide.
- Java SE Development Kit 17: Of course you need to have Java installed to run a Java application. I used Java 17, but I think it works fine with other versions as well.
- IntelliJ IDEA: It is undoubtedly the top-choice IDE for software developers. It makes Java and Kotlin development a more productive and enjoyable experience.
- Swagger 3: an open source project used to generate the REST API documents for RESTful web services. It provides a user interface to access our RESTful web services via the web browser.
- Microsoft SQL Server 2022: a relational database management system developed by Microsoft. As a database server, it is a software product with the primary function of storing and retrieving data as requested by other software applications - which may run either on the same computer or on another computer across a network (including the Internet).
- SQL Server Management Studio: SSMS is an integrated environment for managing any SQL infrastructure, from SQL Server to Azure SQL Database. SSMS provides tools to configure, monitor, and administer instances of SQL Server and databases. Use SSMS to deploy, monitor, and upgrade the data-tier components used by your applications and build queries and scripts.
- Radmin VPN: a free and easy-to-use software product to create virtual local networks. The program allows users to securely connect computers, located behind firewalls.
You can install this application by cloning this repository into your current working directory:
git clone https://github.com/theEmperorofDaiViet/car-rental.git
- /car-rental-headquarters - the application installed at the headquarters of the car rental agency.
- /car-rental-branch - the application installed at each branch.
All SQL script files are located in /src/main/resources/database of both headquarters and branch application.
Create a network by Radmin VPN. Make sure that all computers at the headquarters and at each branch are online and joined this network.
Add inbound rules for the SQL Server ports to allow access, or simply turn off the firewall if you don't mind.
Run the SQL Server 2022 installer and create an instance of SQL Server for the headquarters and each branch:
- Use the Developer Edition.
- Select the Database Engine Services and SQL Server Replication feature.
- Use Mixed Mode for Authentication Mode and specify the password for the sa account.
Open SQL Server Configuration Manager. Select SQL Server Network Configuration: enable TCP/IP and specify IP address (in the VPN created before) & SQL Server port of each computer.
Open SQL Server Management Studio.
Create the database at the headquarters using this script. You can generate some dummy data using python and sql scripts under the /data directory.
Then, distribute the database to each branch by Database Replication & Fragmentation:
- Create a folder named 📂REPLDATA as the snapshot folder. Share the folder to Everyone and set the permission level to Read/Write.
- Configure the Distributor using the wizard in SSMS or SQL script.
- Create a Merge Publication using the wizard in SSMS or SQL script.
- Create a Subscription for each branch using the wizard in SSMS or SQL script.
Don't forget to turn on the SQL Server Agent service.
Open the headquarters database, create stored procedures and triggers using SQL scripts under the /stored procedures and /triggers directory.
Open each branch database, create stored procedures and triggers using SQL scripts under the /stored procedures and /triggers directory.
Open the application.properties file in /src/main/resources of both headquarters and branch application and change the property values about the datasource to fit your own settings.
Run the application in the IDE, or open a terminal in the root of the application and type the following command:
mvnw spring-boot:run
It runs on port 8080 by default. Visit http://localhost:8080/api-docs for the api-docs and http://localhost:8080/swagger-ui/index.html for the Swagger UI to visualize and interact with the API.
- Distributed Database over a VPN:
- Database Replication & Fragmentation
- Stored Procedures & Triggers
- API:
- Basic CRUD operations
- Calling Stored Procedures from Spring Data JPA Repositories
Example: calling stored procedures from the headquarters application
Result:
You can contact me via: