Skip to content

About

An ecommerce website dedicated to selling sparkles!

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

✨ Glitter Gallery

CI

🔗 Live site

An e-commerce storefront for hand-mixed, ethically sourced glitter. 🦄

Built with Next.js, Prisma, and PostgreSQL.


🛠️ Local Development Setup

Prerequisites

1. Clone the repo

git clone https://github.com/ldennington/glitter-gallery.git

2. Start a local PostgreSQL database

docker run --name glitter-gallery-server \
  -e POSTGRES_USER=glitter \
  -e POSTGRES_PASSWORD=<any-password-you-choose> \
  -e POSTGRES_DB=glitter-gallery-db \
  -p 5432:5432 \
  -d postgres:16

2. Configure environment variables

Create a .env file in the project root:

# PostgreSQL (must match Docker settings above)
DATABASE_URL="postgresql://glitter:<your-chosen-password>@localhost:5432/glitter-gallery-db"

⚠️ Never commit secrets. The .env file is already in .gitignore.

3. Install dependencies

npm install

4. Set up and seed the database

npm run prisma:generate   # Generate the Prisma client
npm run db:push           # Push the schema to your database
npm run db:seed           # Seed with sample glitter products and promo codes

5. Run the app

npm run dev

Open http://localhost:3000 to see the site.


🎟️ Promo Codes

Shoppers can apply a promo code on the cart or checkout page. Codes are stored in the PromoCode table and support:

  • A percent or fixed (dollar) discount
  • An optional minimum order subtotal
  • An optional expiry date and maximum number of redemptions
  • An active flag to turn a code off without deleting it

The discount is previewed in the browser, but POST /api/orders re-prices the cart and re-validates the code before saving the order. Redemptions are counted when an order is placed.

The seed script adds these sample codes:

Code Discount
SPARKLE10 10% off any order
GLITTER5 $5 off orders of $25 or more
SHINEBRIGHT25 25% off orders of $50 or more (first 100 orders)

ℹ️ The CD workflow runs the seed on every deploy, so these codes are also available in production. Re-seeding updates each code's settings but keeps its redemption count.


🧪 Linting & Building

The cart and applied promo are saved in browser session storage for the current tab, so page reloads do not lose them. Placing an order clears both.

npm test        # Unit and cart regression tests
npm run lint    # ESLint
npm run build   # Production build

🚀 Deployment

The CD workflow deploys main to Azure App Service and runs Prisma migrations against Azure Database for PostgreSQL. It authenticates with OIDC and reads these secrets (repository- or production environment-level):

Secret Required Description
AZURE_CLIENT_ID ✅ Client ID of the identity with a federated credential for this repo
AZURE_TENANT_ID ✅ Microsoft Entra tenant ID
AZURE_SUBSCRIPTION_ID ✅ Subscription containing the resources
AZURE_APP_NAME ✅ App Service (web app) name
DATABASE_URL ✅ PostgreSQL connection string (?sslmode=require)
AZURE_RESOURCE_GROUP Recommended Resource group of the web app (and PostgreSQL server)
AZURE_POSTGRES_SERVER_NAME Optional If set, the runner's IP is temporarily allowed through the PostgreSQL firewall while migrations run

About

An ecommerce website dedicated to selling sparkles!

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages