It's an important skill, that cannot be learned in form of syntax, to figure out models for an App.
In this exercise I want you to think about and create, the model for a simple online shop.
OFC every shop needs a user/authentication system, besides the normal fields like name, email, password..
What extra fields would you need for this kind of shop? Which information is important to the shop-owner and the customer?
A shop would be boring without things to sell. What would you include in an Item model? Think about the things you see in online shops that you know.
When a customer picks items he adds them into a basket. Let's say this happens in the frontend... in the end the customer will place an order, so a list of items and amounts... Try to create a model for this, including all the important information that the shop-owner needs to process the order, and send out the package.
You may create extra models that i did not mention here, but this is not striclty required.
Try to get as far as you can. Try to use a structur that takes one file per model.
You dont have to create routes, but: it should not thow any errors.
- User (Customer)
- Owner
- Accounting / Finance
- Logistics
- Basket Case :D (User) User creates a list of items that he want to buy, reserve the items temporarily, so othe users can see a reduced amount of available items.
- Order is placed (User) User confirms a basket and says he want to buy the items in the basket. Item availability will be checked, items reserved, address, delivery and payment information stored with the order. (Continue shopping)
- Payment is confirmed (3rd party, Bank, PayPal, Accounting)
- Customer gets Invoice / Order Confirmation
- Order Processing / Confection (Logistics, Status: Preparing)
- Status: Shipping (Logistics)
- Status: Delivered (Logistics)
- (Optional) Process return delivery (Logistics)
- (Optional) Check condition of item (Logistics)
- (Optional) Put back into inventory (Logistics)
- (Optional) Wire refund (Accounting)
- Get customer feedback
Assume all CRUD routes for each model. Important: Think about who will be able to access those routes :D
- List users: Staff only ...
- List / Delete / Patch orders: Staff only ...
This cannot happen with order status != basket Responds with a Total (Costs + Shipping + VAT)
Reponds with an Invoice id, confirmation
Backend can check transactionId with payment provider and set payment status to paid.