GastroMóvil’s ordering flow is built on a lightweight session-based cart that requires no database writes until the customer confirms their purchase. When the order is placed, the system geocodes the delivery address, persists every order line, notifies the restaurant over WebSocket, and then tracks the order through a strict state machine until the driver marks it delivered.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/lffiesco-svg/gastromovil/llms.txt
Use this file to discover all available pages before exploring further.
The Session Cart
TheCarrito class in carrito/cart.py stores everything in request.session under the key 'carrito'. Each entry in the session dictionary is keyed by the product’s primary key (as a string) and holds all the data needed to render the cart without additional database queries.
Cart Item Structure
Whenagregar() is called, a new entry is created (or incremented) with this shape:
Available Methods
| Method | Signature | Description |
|---|---|---|
agregar | agregar(producto, cantidad=1) | Add one or more units of a product |
limpiar | limpiar() | Clear the entire cart |
total | total() | Return the subtotal (sum of precio × cantidad for all items) as a float |
items | items() | Return an iterable of all cart item dictionaries |
restaurante_id | restaurante_id() | Return the restaurante_id of the first item in the cart |
The cart does not prevent a customer from adding products from different restaurants in the same session. At checkout, the
confirmar_pedido view groups items by restaurante_id and creates one Pedido per restaurant automatically.Cart Endpoints
Order Placement (POST /carrito/confirmar/)
The confirmation endpoint accepts a JSON body and performs several validation steps before persisting anything.
Required Payload
Supported Payment Methods
Barrio Validation
Thebarrio field must exactly match one of the ~50 recognised neighbourhoods of Garzón, Huila that are hardcoded in BARRIOS_GARZON:
Address Validation
Before geocoding, the view enforces three address rules:direccionmust be at least 5 characters.- It must contain at least one digit (e.g. a street number).
- It must contain at least one letter.
Address Geocoding
After validation passes, the view calls the Google Maps Geocoding API to resolve the full address into latitude/longitude coordinates. The resultinglat/lng values are saved to the Direccion model:
Delivery Fee
A flat delivery fee of 3,000 COP is added to every order total:The Pedido and DetallePedido Models
Order State Machine
An order moves through the following lifecycle. Only the restaurant can advance states frompendiente through enviado; a customer can cancel from pendiente or aceptado.
WebSocket Notifications
GastroMóvil uses Django Channels to push real-time notifications at two points in the order lifecycle.New Order → Notify Restaurant
When
confirmar_pedido persists the order, it immediately publishes a notificacion_pedido event to the restaurante_{id} channel group:State Change → Notify Customer
Every time the restaurant changes an order’s state via the panel API, a
cambio_estado event is published to the cliente_{id} group with a user-friendly message:PedidoConsumer (pedidos/consumers.py) implements the WebSocket handler. Clients connect using a generic group pattern:
tipo is either restaurante or cliente and sala_id is the corresponding entity’s primary key.
Order History and Detail
| URL | Description |
|---|---|
/mispedidos/ | Lists all orders placed by the logged-in customer, ordered by most recent date. |
/pedidos/<pk>/ | Shows a single order with its full DetallePedido breakdown and current status. |
pendiente or aceptado state. Once preparation begins (preparando), cancellation is no longer available.