The Chaos of Paper Slips
If you visit a neighborhood motorcycle repair shop in Indonesia, you will usually find paper slips tucked under windshield wipers or piled on a wooden desk. Mechanics grab spark plugs, brake pads, and oil bottles off shelves, scribble what they used on a greasy notepad, and hand it to a cashier an hour later.
Half the time, those scribbles get misread, inventory counts drift, and the shop owner discovers missing stock at the end of the month without knowing where it went.
For our Object-Oriented Programming (PBO) capstone at Telkom University, my 5-person team set out to replace that paper chaos. We built BengkelApp, a web system in Java 21 and Spring Boot 3.4.0 that ties customer vehicle check-in, mechanic work queues, and inventory deductions into a single transactional loop.
Customer Arrives with Motorcycle
│
▼
Admin Check-In & Service Order
(Plate number, complaint, assigned mechanic)
│
▼
The Workshop Dilemma
(Mechanics need to log used parts,
but cannot touch billing or inventory totals)
│
▼
Spring Security Role-Based Routing
├── /admin/** -> Customer intake & stock replenishment
└── /mechanic/** -> Active repair queue & part consumption
│
▼
Transactional Inventory Deduction
(@Transactional service method updates MySQL)
│
▼
Final Customer Invoice & Audit Log
The Operational Bottleneck
When we mapped out how a real workshop operates, we noticed two conflicting needs:
- The front desk admin needs to register vehicles quickly, assign jobs to available mechanics, and generate billing invoices.
- Mechanics on the workshop floor need to see their assigned repairs and log parts as they install them, but they should never have access to change retail prices, alter financial reports, or edit customer records.
In our first conceptual draft, we thought about giving all staff a shared interface with basic password protection.
Naive Architecture (Single Shared Portal):
Any User -> Login -> Read/Write Everything -> MySQL
That idea failed basic security requirements. If a mechanic could edit inventory quantities directly, there would be no audit trail linking a deducted spark plug to an actual customer invoice. Anyone could wipe out discrepancies by manually resetting stock counts.
How do we let mechanics log parts from the repair bay while strictly isolating financial control to the front desk?
Enforcing Role Boundaries with Spring Security
To resolve this, we configured Spring Security around two distinct user roles: ADMIN and MEKANIK.
Instead of relying on client-side menu hiding, permissions are enforced at the URL and method levels:
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(auth -> auth
.requestMatchers("/css/**", "/js/**", "/images/**").permitAll()
.requestMatchers("/admin/**").hasRole("ADMIN")
.requestMatchers("/mechanic/**").hasRole("MEKANIK")
.anyRequest().authenticated()
)
.formLogin(form -> form
.loginPage("/login")
.defaultSuccessUrl("/dashboard", true)
.permitAll()
)
.logout(logout -> logout
.logoutSuccessUrl("/login?logout")
.permitAll()
);
return http.build();
}
}
When an admin logs in, they see vehicle registration, customer profiles, and stock replenishment forms. When a mechanic logs in, the controller redirects them directly to /mechanic/queue, displaying only their active repair tickets.
Atomic Inventory Deductions with Spring Data JPA
The most sensitive operation in the application happens when a repair finishes. A mechanic selects the parts used, such as two liters of motor oil and a drive belt.
If the database writes the service record but fails halfway through deducting inventory stock, the shop ends up with phantom inventory:
Service Transaction Recorded
↓
Deduct 2x Motor Oil (Success)
↓
Deduct 1x Drive Belt (Network timeout / DB error)
↓
Inconsistent State: Invoice lists belt, but inventory never decremented!
To prevent partial updates, we wrapped the service execution in a transactional boundary:
@Service
@RequiredArgsConstructor
public class ServiceOrderServiceImpl implements ServiceOrderService {
private final ServiceOrderRepository orderRepository;
private final SparePartRepository partRepository;
private final TransactionRepository transactionRepository;
@Transactional
public void completeService(Long orderId, List<PartUsageDto> partsUsed) {
ServiceOrder order = orderRepository.findById(orderId)
.orElseThrow(() -> new EntityNotFoundException("Order not found"));
double partsTotal = 0.0;
for (PartUsageDto usage : partsUsed) {
SparePart part = partRepository.findById(usage.getPartId())
.orElseThrow(() -> new EntityNotFoundException("Part not found"));
if (part.getStockQuantity() < usage.getQuantity()) {
throw new InsufficientStockException("Insufficient stock for: " + part.getName());
}
part.setStockQuantity(part.getStockQuantity() - usage.getQuantity());
partRepository.save(part);
partsTotal += part.getUnitPrice() * usage.getQuantity();
}
order.setStatus(OrderStatus.COMPLETED);
orderRepository.save(order);
ServiceTransaction transaction = ServiceTransaction.builder()
.serviceOrder(order)
.partsCost(partsTotal)
.laborCost(order.getLaborCost())
.totalCost(partsTotal + order.getLaborCost())
.completedAt(LocalDateTime.now())
.build();
transactionRepository.save(transaction);
}
}
The @Transactional annotation guarantees that if stock validation fails or the connection drops, every deduction rolls back automatically, keeping the MySQL bengkeljawa database consistent.
Server-Side UI with Thymeleaf
Rather than introducing a separate JavaScript frontend and managing API tokens, we chose server-rendered Thymeleaf templates.
For a local workshop desktop that runs on a counter PC or tablet, server rendering has real advantages:
- No client-side build pipeline or API version drift.
- Session cookies handle authentication naturally without token refresh flows.
- Form submissions are validated on the server using Jakarta Validation annotations (
@NotNull,@Min,@Size), rejecting bad input before it hits the database.
Browser Form Submit
│
▼
Controller Validation (@Valid DTO)
│
├── Fails: Re-render form with field error messages
└── Passes: Invoke transactional service method
│
▼
Redirect to Transaction Overview (Flash attribute confirmation)
What I Learned
Building BengkelApp showed our team why object-oriented design and transactional boundaries matter in practical software.
When we started, building a repair tracking app seemed like basic CRUD. But handling the reality of workshop operations, where physical parts move off shelves while mechanics work on engines, forced us to think carefully about state consistency.
Separating concerns through MVC, isolating permissions with Spring Security, and wrapping database mutations in atomic transactions made the difference between a brittle school assignment and an application that could actually run a workshop without corrupting inventory records.