Hourbook - Work Hour Management System
This application is designed to help employers and employees track and manage work hours efficiently. It consists of a Java Spring Boot back-end that handles business logic, database interactions, and APIs, paired with a React front-end for a user-friendly interface. The system aims to streamline time tracking and reporting.
Actors: Employer
Description: Employers can review and approve work hours submitted by employees.
Preconditions:
- Employers are logged in. Postconditions:
- Work hours are marked as approved or rejected. Basic Flow:
- Employer navigates to the "Pending Work Hours" page.
- Reviews submitted hours by employees.
- Approves or rejects the submission with optional comments.
- System updates the status in the database.
Alternate Flows:
- Employers can filter by employee, date, or project for faster review.
Actors: Employee
Description: Employees can edit work hour entries that have not yet been approved.
Preconditions:
- Employees are logged in.
- The entry status is "Pending."
Postconditions:
- System updates the entry with the new details.
Basic Flow:
- Employee navigates to the "My Work Hours" page.
- Selects an entry with "Pending" status.
- Updates the relevant fields.
- Saves the changes.
- System validates and updates the entry in the database.
The application consists of a Spring Boot backend and a Vite-based frontend.
β Deployed and running at:
π https://hourbook-hourbook.2.rahtiapp.fi/
The backend provides the core REST API used by the application.
See π REST API Documentation for available endpoints and usage.
β Deployed and running at:
π https://hourbook-frontend-hourbook.2.rahtiapp.fi/
- Language: TypeScript
- Framework: React (with Vite)
- Key Libraries:
react-router-domβ Client-side routing@mui/materialβ Material UI component library@emotion/react,@emotion/styledβ Styling supportdate-fnsβ Date utility libraryreact-big-calendarβ Calendar and schedulingaxiosβ HTTP client for API requestsrechartsβ Data visualization library
- Build Tool: Vite
- Styling: CSS Modules and custom stylesheets (e.g.,
navbar.css,projects.css,calendar.css)
- Language: Java
- Framework: Spring Boot
- Key Frameworks/Libraries:
Spring Securityβ Authentication and authorization (with JWT support)Spring Data JPAβ ORM and database operationsSwagger/OpenAPIβ API documentationJUnitandMockitoβ Testing
- Database: PostgreSQL
The frontend is implemented using React with TypeScript and Vite for fast development. It provides a user-friendly interface for managing projects and tracking work hours.
-
src/components/: Reusable UI components.ManageProjectDialog.tsx: Dialog for managing project details.ProjectActions.tsx: Component for project-related actions (e.g., create, join).
pages/: Page-level components for routing.Projects.tsx: Displays a list of projects.ProjectDetails.tsx: Displays details of a specific project.
services/: API service classes for interacting with the backend.projectService.ts: Handles API calls related to projects.
styles/: CSS files for styling.projects.css: Styles for project-related pages.projectDetails.css: Styles for the project details page.calendar.css: Styles for calendar components.
-
public/- Static assets such as images and icons.
-
package.json- Defines project dependencies and scripts.
npm run dev: Starts the development server.npm run build: Builds the production-ready app.
- Defines project dependencies and scripts.
The backend is implemented using Java with the Spring Boot framework. It handles business logic, database interactions, and provides RESTful APIs for the frontend.
-
src/main/java/fi/haagahelia/backendcontrollers/: Contains REST controllers for handling HTTP requests.ProjectController.java: Manages project-related endpoints (e.g., create, update, delete projects).OrganizationRestController.java: Handles organization-related endpoints.
dto/: Data Transfer Objects for encapsulating data.HourSummaryDTO.java: DTO for summarizing hour data.
model/: Entity classes representing database tables.Project.java: Represents a project entity.ProjectMember.java: Represents a project member entity.ProjectRole.java: Enum for project roles (e.g., OWNER, EMPLOYEE).User.java: Represents a user entity.
repositories/: Interfaces for database operations.ProjectRepository.java: Handles CRUD operations for projects.ProjectMemberRepository.java: Handles operations for project members.
services/: Contains business logic.ProjectService.java: Core service for managing projects.HourSummaryService.java: Service for summarizing hour data.
BackendApplication.java: Main entry point for the Spring Boot application.
-
src/main/resourcesdb/migration/: Database migration scripts.V2__Add_Project_Roles.sql: Adds project roles to the database.
application.properties: Configuration for the Spring Boot application.
-
src/test/java/fi/haagahelia/backendProjectServiceTest.java: Unit tests for theProjectServiceclass.HourSummaryServiceTest.java: Unit tests for theHourSummaryServiceclass.
To run the project locally, follow the steps below for both frontend and backend.
Make sure you have the following installed on your system:
- Node.js (version 18 or higher)
- Java JDK 17
- Maven
- Git
cd frontend
npm install
npm run devAfter running, the frontend will be available at: π http://localhost:5173
cd backend
./mvnw package
./mvnw spring-boot:runOnce started, the backend will be available at: π http://localhost:8080
This application provides a RESTful API for managing:
usersrolespermissionsorganizationsentries
The API is fully documented and testable via Swagger.
- Swagger UI: http://localhost:8080/swagger-ui.html
- OpenAPI JSON: http://localhost:8080/v3/api-docs
Using Swagger UI, you can:
- Browse and test all endpoints interactively
- View input and output schemas
- Inspect validation rules and error responses
| Resource | GET (/{id}, list) | POST | PUT /{id} | DELETE /{id} |
|---|---|---|---|---|
/users |
β | β | β | β |
/roles |
β | β | β | β |
/permissions |
β | β | β | β |
/organizations |
β | β | β | β |
/entries |
β | β | β | β |
/projects |
β | β | β | β |
Ensure the following are available in your project setup before running the tests:
- JDK 17 or compatible version
- Maven or Gradle (for dependency management)
- JUnit 5
- Mockito
- Spring Boot Test dependencies
You can run the tests using:
Maven:
mvn testService class testing
This document provides an overview of the unit tests implemented for the ProjectService class in a Spring Boot backend application. These tests verify the correct behavior of core project-related operations such as creation, membership management, entry retrieval, and project updates/deletions.
backend\src\test\java\fi\haagahelia\backend\ProjectServiceTest.java
| Test Method | Description |
|---|---|
testCreateProject |
Verifies successful project creation and creator is saved as member. |
testJoinProjectByCodeSuccess |
Ensures a user can join a project using a valid code. |
testJoinProjectByCodeAlreadyMemberThrows |
Ensures exception is thrown if user is already a project member. |
testGetProjectByIdAsMember |
Verifies that a project can be fetched if the user is a member. |
testGetProjectByIdAsNonMemberThrows |
Ensures exception is thrown if a non-member tries to access the project. |
testGetProjectMembers |
Validates that all members of a project can be retrieved. |
testGetProjectEntries |
Confirms entries of a project can be retrieved by a project member. |
testRemoveMemberFromProjectAsCreator |
Verifies that the project creator can remove members. |
testRemoveMemberFromProjectAsNonCreatorThrows |
Ensures a non-creator cannot remove members from the project. |
testGetUserProjects |
Checks that all projects associated with a user are returned. |
testUpdateProjectSuccess |
Validates successful updating of project fields. |
testDeleteProjectSuccess |
Ensures a project can be deleted when it exists. |
testDeleteProjectNotFound |
Ensures deletion fails gracefully if project does not exist. |
This document provides an overview of the unit tests for the HourSummaryService class. These tests ensure the accuracy of time tracking and breakdown logic used in reporting hours by month, project, and total.
backend\src\test\java\fi\haagahelia\backend\HourSummaryServiceTest.java
| Test Method | Description |
|---|---|
testCalculateTotalHours_withValidEntries |
Verifies correct total hour calculation from multiple time entries. |
testCalculateMonthlyBreakdown_multipleEntriesAcrossMonths |
Checks that hours are correctly grouped and summed by month. |
testCalculateProjectBreakdown_multipleProjects |
Validates correct grouping and summing of hours by project. |
- Vilho Karhu https://github.com/kvilho
- Julius Luhtala https://github.com/juliusluhtala
- Nikolas Kataja https://github.com/bhi049
- Kasperi KuusanmΓ€ki https://github.com/kapseri
- Ville Kotilainen https://github.com/villekotilainen

