Inside `Rathi5625/AI-Grocery-Delivery`: The Grocery Clone That Prices Carbon, Not Just Cart Total
A Spring Boot and React quick-commerce build where checkout, inventory, and delivery fees are familiar, but sustainability data is treated as core product state.
- This repo turns grocery checkout into dual accounting, where price and stock move alongside sustainability data.
- The product schema is the real thesis, because carbon footprint and freshness values survive from catalog to order.
- Checkout is not a button click here, it is a transactional pipeline that validates inventory, applies fees, and rolls up impact.
- The stack looks like a learning project, but the data flow is organized like a real commerce system.
The Grocery App That Also Keeps Score on Carbon
Most grocery clones chase the same three things: speed, convenience, and conversion. `Rathi5625/AI-Grocery-Delivery` does that too, but it adds a second ledger. Products carry sustainability metadata, orders preserve it, and checkout rolls it up into a `carbonSaved` metric alongside price, stock checks, and delivery fees.
What FreshAI Is, and Why It Exists
Its an AI based grocery delivery web application.
This is a personal portfolio project, not a large open-source commerce platform. That matters because it changes how you read the code. The goal is not market dominance. The goal is to show full-stack range, product thinking, and a willingness to make the data model do real work.
The Data Model Makes the Thesis Real
The interesting move is not a label in the UI. It is the schema. `Product` carries fields like `sustainability_score`, `carbon_footprint`, and `freshness_days`, which means the app can treat environmental cost as durable product state instead of a one-off calculation at the end.
@Entity
public class Product {
private String name;
private BigDecimal price;
private Integer stockQuantity;
private Double sustainabilityScore;
private Double carbonFootprint;
private Integer freshnessDays;
@PrePersist
public void generateSlug() {
this.slug = name.toLowerCase().replaceAll("[^a-z0-9]+", "-") + "-" + System.currentTimeMillis();
}
}
Checkout as a Transaction, Not a Button Click
`OrderService` is the center of gravity. It validates stock, calculates subtotal, applies a flat delivery fee of ₹49, waives it past a ₹500 threshold, and aggregates item-level carbon footprint into the order. That is a cleaner story than a cart total in a modal. It is a transaction that decides what can ship, what it costs, and what impact it carries forward.
public Order createOrder(Long userId, List<OrderItemRequest> items) {
validateStock(items);
BigDecimal subtotal = calculateSubtotal(items);
BigDecimal deliveryFee = subtotal.compareTo(new BigDecimal("500.00")) >= 0
? BigDecimal.ZERO
: new BigDecimal("49.00");
Double carbonSaved = calculateCarbonSaved(items);
Order order = new Order();
order.setSubtotal(subtotal);
order.setDeliveryFee(deliveryFee);
order.setCarbonSaved(carbonSaved);
return orderRepository.save(order);
}
This is where the project stops being a standard cart demo. A normal clone would stop at money movement and inventory checks. Here the order object also remembers that impact exists.
Cart Sync Is the Quietly Important Part
The cart logic is stateful, and that is a good sign. Instead of letting totals drift until checkout, the app uses a `recalculateTotal()` pattern so the cart stays aligned with its child items. That reduces the chance that the final invoice becomes the first moment the app discovers a mismatch.
public void recalculateTotal(Cart cart) {
BigDecimal total = cart.getItems().stream()
.map(item -> item.getPrice().multiply(BigDecimal.valueOf(item.getQuantity())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
cart.setTotalAmount(total);
}
That detail sounds small, but it shapes the whole experience. It means the app treats cart state as living data, not a bag of numbers to be recomputed only when the user clicks checkout.
Security Is Built Like a Real App
The auth layer is practical: JWT access and refresh tokens, email-based identity, and Spring Security wiring. It is not the main attraction, but it signals that this is more than a front-end mock with fake persistence. The project is trying to behave like software that could survive real users, even if it is still clearly an early-stage build.
| Token role | What it does | Why it matters |
|---|---|---|
| Access token | Carries user identity and roles | Keeps request authorization fast |
| Refresh token | Lets the session continue safely | Reduces repeated logins |
| Email identity | Uses email instead of username | Fits consumer commerce better |
The Stack Choice Signals the Intended Audience
The repo is a monorepo with a Spring Boot backend, a React frontend, Vite, vanilla CSS, MySQL, Maven, and npm. That combination says a lot. It is optimized for clarity and learning, not for framework fashion. You can read the flow without decoding a pile of abstraction layers.
| Dimension | FreshAI | Typical grocery clone | Mature commerce platform |
|---|---|---|---|
| Product focus | Impact-aware quick commerce | Speed and conversion | Scale, extensibility, and ops |
| Data model | Tracks carbon and freshness | Tracks price and stock | Usually richer but more complex |
| Checkout logic | Fees plus carbon rollup | Fees and inventory only | Deeply configurable workflows |
| Audience | Student project and portfolio | Demo or prototype | Production teams |
| Stack shape | Spring Boot and React monorepo | Varies widely | Usually enterprise-heavy |
How It Compares to Real Grocery Platforms
Against Instacart, Amazon Fresh, or Walmart Grocery, this repo is obviously smaller and less mature. That is not the point. Its value is in showing how a familiar commerce flow can be re-authored around a different principle: preserve impact data as carefully as you preserve price.
Against mature open-source commerce systems like WooCommerce or Reaction Commerce, it is much narrower. But it is also much easier to understand. It demonstrates one strong idea cleanly, which is often more useful than a sprawling feature list.
What This Repo Is Really Teaching
The lesson is not “build a grocery app.” The lesson is that product philosophy can be encoded in the schema, then protected through checkout, auth, cart state, and order creation. Once that happens, carbon is no longer a dashboard afterthought. It is part of the transaction.