AI has contributed to changing and increasing efficiency in my daily work
As a developer, building an orders processing service can sometimes feel overwhelming when you have a limited timeframe. However, with the power of AI-driven development tools like ChatGPT, you can significantly speed up the process by generating code, designing entities, and solving problems step by step. In this article, I’ll walk you through how I used ChatGPT to build a fully functional orders processing service in just 2 days, from gathering requirements to completion.
Honestly, there are many small threads and prompts for different small tasks that I can't summarize into a complete project, but overall... it helped me 70 - 80%. Additionally, here is some of the original code, after I reviewed it, it may have been modified by hand, so you may not find this function on github that I shared.
The first thing I did was list down the core features required for the service. Here are the primary functionalities I needed:
I asked ChatGPT to help me design the API structure for the requirements. Here’s an example of the first prompt I used:
Prompt:
Create API endpoints for a user registration system using Spring Boot, where users can register with their name, mobile number, and address.
Result: ChatGPT generated several endpoints:
For the order processing service, we needed entities for User, Franchise, Order, Queue, and OrderItem. I used ChatGPT to define these entities with the necessary fields.
Prompt:
Design the User entity for the system. The user can have a mobile number, address, and a role (like CUSTOMER).
Result: ChatGPT provided a simple User entity using JPA:
@Entity public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private UUID id; @Column(nullable = false, unique = true) private String username; @Column(nullable = false) private String password; private String mobileNumber; private String address; private UserRole role; // CUSTOMER, ADMIN }
I repeated this process for the Franchise, Order, and Queue entities.
Once the basic API and entities were set up, I moved on to implementing business logic for order placement. This was the critical part of the service since it needed to handle multiple items from the menu and manage queue positions.
Prompt:
Implement the logic for placing an order with multiple items, where each item is linked to a specific menu in the Franchise.
Result: ChatGPT guided me through designing an OrderService to handle this. Here’s part of the implementation:
public Order createOrder(UUID customerId, UUID franchiseId, Listitems) { Order order = new Order(); order.setCustomer(userRepository.findById(customerId).orElseThrow()); order.setFranchise(franchiseRepository.findById(franchiseId).orElseThrow()); List orderItems = items.stream() .map(itemDto -> new OrderItem(menuItemRepository.findById(itemDto.getMenuItemId()), itemDto.getQuantity())) .collect(Collectors.toList()); order.setItems(orderItems); order.setQueuePosition(findQueuePositionForFranchise(franchiseId)); return orderRepository.save(order); }
Next, I asked ChatGPT to help me design the logic for placing a customer in the queue and tracking their position.
Prompt:
How can I calculate the queue position and waiting time for an order in a coffee franchise system?
Result: ChatGPT suggested creating a QueueService that tracks orders and assigns them positions based on timestamps. I implemented it as follows:
public int findQueuePositionForFranchise(UUID franchiseId) { Listqueue = customerQueueRepository.findAllByFranchiseId(franchiseId); return queue.size() 1; }
It also provided guidance on estimating waiting times based on the average order processing time.
Finally, I implemented the logic for allowing customers to cancel their orders and exit the queue:
public void cancelOrder(UUID orderId) { Order order = orderRepository.findById(orderId).orElseThrow(); queueService.removeFromQueue(order.getQueue().getId(), order.getId()); orderRepository.delete(order); }
By the end of Day 2, I had a fully functional service that allowed customers to:
I have a few more steps to create the documentation, use liquidbase and have chatGPT generate sample data for easier testing.
Building an order processing system for a coffee shop in 2 days may sound daunting, but with AI assistance, it’s achievable. ChatGPT acted like a coding assistant, helping me transform abstract requirements into a working system quickly. While AI can provide a foundation, refining and customizing code is still an essential skill. This project taught me how to maximize the value of AI tools without losing control of the development process.
By following the steps I took, you can speed up your own projects and focus on higher-level problem-solving, leaving the routine code generation and guidance to AI.
Full source Github
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3