Design and Implementation of a Taxi Management System with Spring Boot and Vue.js
Technical Framework
Backend: Spring Boot
Spring Boot is an open-source framework designed for rapid development of Spring-based applications. It embraces the principle of convention over configuration, offering a set of default settings that allow developers to concentrate on business logic rather than configuration files. The framework automates much of the configuration, reducing the need for manual XML or annotation setup. It integrates with build tools like Maven or Gradle to manage dependencies and provides plugins to simplify the build process. Developers can use Spring Initializr to generate a foundational project structure and select required dependencies.
Frontend: Vue.js
Vue.js is engineered for simplicity and ease of learning, providing an intuitive API for building interactive user interfaces. It features a powerful data-binding system; directives like v-model enable two-way binding between the view and data model. Changes in data automatically update the view, and vice versa, minimizing manual DOM manipulation. Vue components offer lifecycle hooks, allowing developers to execute custom logic at various stages such as creation, mounting, updating, and destruction.
Feasibility Analysis
Feasibility analysis is essential for project development, assessing whether the system can adress the limitations of traditional manual methods and improve operational efficiency. For a taxi management system, this analysis evaluates technical, economic, and operational viability.
- Technical Feasibility: Utilizing mature Java and Spring Boot technologies ensures the system's development is technically sound.
- Economic Feasibility: The analysis weighs development costs against the long-term benefits of automated management, such as reduced labor and improved efficiency.
- Operational Feasibility: The system is designed with a focus on user-friendly interfaces and practical functionality for administrators and drivers.
System Testing
System testing aims to identify defects by evaluating the software from multiple perspectives. Functional testing is conducted to find and rectify issues, ensuring the system meets specified requirements and provides a reliable user experience.
Purpose of System Testing
Testing is a critical phase that serves as the final checkpoint for system quality and reliability. It simulates various user scenarios to uncover potential problems before deployment, there by enhancing the overall user experience. The goal is to verify that the system aligns with its requirements and to identify any discrepancies.
Functional Testing Examples
Modules are tested using methods like click events, input validation (boundary values, required fields), and black-box testing based on predefined test cases.
Login Function Test:
| Input Data | Expected Result | Actual Result | Analysis |
|---|---|---|---|
| Correct username, password, and captcha | Successful login | Login successful | As expected |
| Correct username, wrong password, correct captcha | Password error | "Password error" message displayed | As expected |
| Correct username, correct password, wrong captcha | Captcha error | "Captcha error" message displayed | As expected |
| Empty username, correct password, correct captcha | Username required | "Please enter username" prompt | As expected |
| Correct username, empty password, correct captcha | Password error | "Password error" message displayed | As expected |
User Management Test: This tests CRUD operations (Create, Read, Update, Delete).
| Input Data | Expected Result | Actual Result | Analysis |
|---|---|---|---|
| Submit complete user info | User added successfully, appears in list | User appears in list | As expected |
| Modify user information | Edit successful, info updated | Information updated | As expected |
| Select user for deletion | System prompts for confirmation, then deletes | User removed after confirmation | As expected |
| Add user with empty username | Validation error for required field | "Username cannot be empty" prompt | As expected |
| Add user with duplicate username | Addition fails due to uniquenesss constraint | "Username already exists" error | As expected |
Database Schema Design
| Column Name | Data Type | Length | Constraints |
|---|---|---|---|
| id | int | 11 | PRIMARY KEY |
| addtime | timestamp | - | DEFAULT CURRENT_TIMESTAMP |
| order_number | varchar | 64 | DEFAULT NULL |
| taxi_id | varchar | 64 | DEFAULT NULL |
| driver_name | varchar | 12 | DEFAULT NULL |
| fare_notes | varchar | 64 | DEFAULT NULL |
| fare_amount | varchar | 64 | DEFAULT NULL |
| trip_date | varchar | 64 | DEFAULT NULL |
| username | varchar | 64 | DEFAULT NULL |
| phone | varchar | 64 | DEFAULT NULL |
Code Implementation
Common Service Controller
@RestController
@RequestMapping("/api/common")
public class UtilityController {
@Autowired
private SystemConfigService configService;
private static AipFace faceClient = null;
private static String mapApiKey = null;
@GetMapping("/geocode")
public ResponseEntity<Map<String, String>> getLocation(@RequestParam String longitude,
@RequestParam String latitude) {
if (mapApiKey == null) {
SystemConfig config = configService.findByKey("map_api_key");
if (config == null) {
return ResponseEntity.badRequest().body(Map.of("error", "API key not configured"));
}
mapApiKey = config.getValue();
}
Map<String, String> locationData = LocationUtil.resolveCoordinates(mapApiKey, longitude, latitude);
return ResponseEntity.ok(locationData);
}
@PostMapping("/face/verify")
public ResponseEntity<?> compareFaces(@RequestParam String image1,
@RequestParam String image2) {
if (faceClient == null) {
SystemConfig apiKeyConfig = configService.findByKey("face_api_key");
SystemConfig secretConfig = configService.findByKey("face_secret_key");
if (apiKeyConfig == null || secretConfig == null) {
return ResponseEntity.badRequest().body("Face recognition API credentials missing");
}
String accessToken = AuthUtil.getAccessToken(apiKeyConfig.getValue(), secretConfig.getValue());
faceClient = new AipFace(null, apiKeyConfig.getValue(), secretConfig.getValue());
faceClient.setConnectionTimeoutInMillis(2000);
faceClient.setSocketTimeoutInMillis(60000);
}
try {
File imgFile1 = new File(ResourceUtils.getFile("classpath:static/upload").getAbsolutePath() + "/" + image1);
File imgFile2 = new File(ResourceUtils.getFile("classpath:static/upload").getAbsolutePath() + "/" + image2);
String encodedImg1 = Base64.getEncoder().encodeToString(Files.readAllBytes(imgFile1.toPath()));
String encodedImg2 = Base64.getEncoder().encodeToString(Files.readAllBytes(imgFile2.toPath()));
MatchRequest request1 = new MatchRequest(encodedImg1, "BASE64");
MatchRequest request2 = new MatchRequest(encodedImg2, "BASE64");
ArrayList<MatchRequest> requests = new ArrayList<>();
requests.add(request1);
requests.add(request2);
JSONObject result = faceClient.match(requests);
return ResponseEntity.ok(result.get("result"));
} catch (IOException e) {
return ResponseEntity.internalServerError().body("Image file processing error");
}
}
}
Database Initialization Script
CREATE TABLE `driver` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation Time',
`driver_code` VARCHAR(200) NOT NULL COMMENT 'Driver ID',
`password_hash` VARCHAR(200) NOT NULL COMMENT 'Password Hash',
`full_name` VARCHAR(200) DEFAULT NULL COMMENT 'Full Name',
`gender` VARCHAR(200) DEFAULT NULL COMMENT 'Gender',
`profile_pic` VARCHAR(200) DEFAULT NULL COMMENT 'Profile Picture',
`mobile` VARCHAR(200) DEFAULT NULL COMMENT 'Mobile Number',
`license_number` VARCHAR(200) DEFAULT NULL COMMENT 'License Number',
PRIMARY KEY (`id`),
UNIQUE KEY `driver_code_unique` (`driver_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Driver Information';
CREATE TABLE `feedback` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation Time',
`author_id` BIGINT NOT NULL COMMENT 'Author User ID',
`author_name` VARCHAR(200) DEFAULT NULL COMMENT 'Author Name',
`content` LONGTEXT NOT NULL COMMENT 'Feedback Content',
`admin_reply` LONGTEXT COMMENT 'Administrator Reply',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='User Feedback';
CREATE TABLE `auth_token` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',
`user_id` BIGINT NOT NULL COMMENT 'User ID',
`username` VARCHAR(100) NOT NULL COMMENT 'Username',
`user_type` VARCHAR(100) DEFAULT NULL COMMENT 'User Type',
`role` VARCHAR(100) DEFAULT NULL COMMENT 'Role',
`token` VARCHAR(200) NOT NULL COMMENT 'Authentication Token',
`issued_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Token Issue Time',
`expires_at` TIMESTAMP NOT NULL COMMENT 'Token Expiration Time',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Authentication Tokens';