Local Development Setup
Relevant source files
The following files were used as context for generating this wiki page:
The Local Development Setup for the SafeDispatch HQ Administration API provides the necessary environment to manage employees, departments, and assignments in a secure, RESTful manner. This project is built using the Spring Boot framework and is designed to run locally with HTTPS and role-based access control.
The system relies on a Gradle-based build system and includes automated data initialization to facilitate immediate testing and development. The local server is configured to run on a specific port and requires Basic Authentication for all secured endpoints.
Sources: ApiApplication.java, api-spec.yaml:1-12, SecurityConfig.java
Prerequisites and Environment
The application requires a Java Development Kit (JDK) to be installed. The environment variable JAVA_HOME must be set correctly to point to the Java installation directory.
Build Tooling
The project uses Gradle. For Windows environments, a gradlew.bat script is provided to handle the build process. This script checks for a valid Java installation and uses the Gradle Wrapper to execute tasks.
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
Sources: gradlew.bat:43-50
Application Startup Flow
The application is a standard Spring Boot application. Upon execution of the ApiApplication class, the Spring context is initialized, and the embedded server starts.
The application initializes with default security settings and pre-populated user data.
Sources: ApiApplication.java, DataLoader.java, api-spec.yaml:11
Network and Security Configuration
The local development server is configured to run over HTTPS to ensure secure communication.
| Parameter | Value | Description |
|---|---|---|
| URL | https://localhost:8443 | Local server endpoint |
| Authentication | Basic Auth | Required for all API requests |
| Protocol | HTTPS | Secured communication |
Sources: api-spec.yaml:10-14, SecurityConfig.java:49
Security Roles
Access to API endpoints is restricted based on roles defined in SecurityConfig.
- GET requests: Accessible by
MANAGERandHRroles. - POST/PUT/DELETE requests: Restricted to the
HRrole only.
Sources: SecurityConfig.java:43-47
Data Initialization
To assist in local development, the DataLoader component automatically creates two administrative users if the database is empty.
Default Development Users
| Username | Password | Role |
|---|---|---|
| hr | hr123 | HR |
| manager | manager123 | MANAGER |
Sources: DataLoader.java:15-30
Development Operations
Common operations for setting up and maintaining the repository are managed through Git commands.
| Task | Command |
|---|---|
| Initialize Remote | git remote add origin [URL] |
| Push to Main | git push -uf origin main |
| Build (Windows) | gradlew.bat build |
Sources: README.md:18-21, gradlew.bat
Summary
The local development setup for Part1_API ensures a secure, pre-configured environment. By leveraging Gradle and Spring Boot's automatic data loading, developers can start the server at https://localhost:8443 and authenticate using the default hr or manager credentials to interact with the Employee, Department, and Assignment endpoints.