An e-commerce storefront for hand-mixed, ethically sourced glitter. 🦄
Built with Next.js, Prisma, and PostgreSQL.
git clone https://github.com/ldennington/glitter-gallery.gitdocker 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:16Create 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.envfile is already in.gitignore.
npm installnpm 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 codesnpm run devOpen http://localhost:3000 to see the site.
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
activeflag 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.
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 buildThe 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 |