Skip to content

About

E-commerce experiment with guest checkout and abandoned cart email recovery. React, Express, Prisma, Resend.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Antigravity E-Commerce Experiment: A full-stack store with guest checkout and abandoned cart emails

Antigravity E-Commerce Experiment

A full-stack store with guest checkout and abandoned cart emails

An e-commerce experiment named Antigravity: a React storefront, an Express and Prisma backend, guest checkout and cron-driven abandoned cart emails sent with Resend.


Built by Studio1

More examples  ·  studio1hq.com


Overview

A full-stack e-commerce experiment built under the name Antigravity. It has a React storefront with guest checkout and an Express backend that emails shoppers who leave items in their cart. A cron job finds abandoned carts and sends an HTML reminder through Resend.

It is useful as a worked example of the abandoned-cart flow, from cart API to scheduled email.

Features

  • Guest checkout: no account is needed to buy.
  • Abandoned cart recovery: a cron job runs every 15 minutes and emails shoppers with product images, quantities, prices, the cart total and a link back to checkout.
  • Cart API: create or get a cart, add items, set the cart email and check out.
  • Connection resilience: retry with exponential backoff (3 attempts), 10-second request timeouts and a connection status banner in the UI.
  • Logging and health checks: request logging, cart and email operation logs, and GET /health with database status.
  • Email fallback: falls back to Ethereal for emails when Resend is not configured.
  • Tests: a test script for email sending and curl examples for the cart API.

Tech stack

Layer Tool
Frontend React, TypeScript, Vite, Tailwind CSS
UI shadcn/ui, React Router, Sonner
Backend Node.js with Express
Database Prisma with SQLite
Email Resend
Scheduling node-cron

Getting started

Prerequisites

  • Node.js 18 or later and npm
  • A Resend API key

Installation

git clone https://github.com/Studio1HQ/Antigravity-experiment.git
cd Antigravity-experiment
npm install
cd backend && npm install
cd ../frontend && npm install
cd ../backend
cp .env.example .env
npx prisma generate
npx prisma db push

Environment variables

Edit backend/.env.

Variable Description
DATABASE_URL Prisma database URL. Use file:./dev.db for SQLite in development.
RESEND_API_KEY Resend API key from resend.com/api-keys. Verify your domain in Resend for production.
PORT Optional backend port, 4000 by default.

Run

Start both servers from the project root with the root script:

npm run dev

Or run them separately:

cd backend && npm run dev
cd frontend && npm run dev

Test email sending and the cart API:

cd backend
node src/test-email.js your-email@example.com

curl -X POST http://localhost:4000/api/cart -H "Content-Type: application/json" -d '{}'
curl -X POST http://localhost:4000/api/cart/items -H "Content-Type: application/json" \
  -d '{"cartId":"YOUR_CART_ID","productId":"1","quantity":1,"price":299.99}'

How it works

  1. The user browses products and adds to the cart (POST /api/cart/items).
  2. The user enters an email (POST /api/cart/email).
  3. If they leave, the cart stays active.
  4. The cron job in backend/src/services/cronService.js runs every 15 minutes (*/15 * * * *), finds abandoned carts and sends the email.
  5. The email links back to checkout, and the purchase completes with POST /api/cart/checkout.
Endpoint Purpose
POST /api/cart Create or get a cart
POST /api/cart/items Add an item
POST /api/cart/email Update the cart email
POST /api/cart/checkout Complete checkout
GET / API status
GET /health Health check with database status

To change the schedule, edit cronService.js. To change the email template or colors, edit sendAbandonedCartEmail in backend/src/services/resendService.js. To add products, edit frontend/src/data/products.ts and backend/src/data/products.js.

frontend/   React storefront (components, CartContext, pages, config.ts)
backend/    Express API (controllers, routes, services, Prisma schema)

The backend also includes services/tensorlake.js and a receipt controller. Both are mock stubs that log events and return sample items. They do not call a live API.

For production, use PostgreSQL or MySQL, set DATABASE_URL, run npx prisma migrate deploy, deploy the backend to a Node host, build the frontend with npm run build for static hosting and set API_BASE_URL in frontend/src/config.ts.

Resources



Studio1

Built by Studio1, the technical content and DevRel partner for devtool teams.
Browse more open-source examples at github.com/Studio1HQ.

Website Book a call X LinkedIn

studio1hq.com · Technical content, docs, video and DevRel for devtools

About

E-commerce experiment with guest checkout and abandoned cart email recovery. React, Express, Prisma, Resend.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages