Skip to content

StevieBlu/Banana-shop

Repository files navigation

Banana Shop + User Dashboard

Node.js / Express app with user registration, login, and a dashboard backed by MariaDB on MAMP.

Features

  • Register and log in (sessions + bcrypt password hashing)
  • Protected dashboard with summary stats and two sample data tables
  • Original banana shop demo at /shop.html
  • Checkout API unchanged (POST /checkout)

Tech stack

  • Node.js, Express
  • MariaDB (via MAMP) — managed with phpMyAdmin
  • mysql2, bcryptjs, express-session, dotenv

Prerequisites

  1. MAMP — start MySQL/MariaDB (Apache is not required for this app).
  2. Node.js — v18+ recommended.

Database setup (phpMyAdmin)

  1. Open phpMyAdmin from MAMP (often http://localhost:8888/phpMyAdmin or similar).
  2. Open the SQL tab.
  3. Paste the contents of sql/schema.sql and run it.

This creates the banana_dashboard database, users table, and two seeded tables: weekly_metrics and recent_activity.

Environment variables

  1. Copy .env.example to .env:

    copy .env.example .env
  2. Edit .env to match MAMP:

    Variable Typical MAMP value
    DB_HOST 127.0.0.1
    DB_PORT 8889 or 3306 — check MAMP → Preferences → Ports
    DB_USER root
    DB_PASSWORD root
    DB_NAME banana_dashboard
    SESSION_SECRET any long random string

Install and run

npm install
npm start

Open http://localhost:3000

  • Home — links to register, login, dashboard
  • Register — create an account, then go to the dashboard
  • Dashboard — requires login; shows stats from the seeded tables
  • Banana Shop — original demo at shop.html

API (for reference)

Method Path Auth
POST /api/auth/register
POST /api/auth/login
POST /api/auth/logout session
GET /api/auth/me session
GET /api/dashboard/stats session

Troubleshooting

  • ECONNREFUSED / access denied — wrong DB_PORT or password; confirm MySQL is running in MAMP.
  • Table doesn't exist — run sql/schema.sql again in phpMyAdmin.
  • Login works but dashboard empty / 500 — seed data missing; re-run the INSERT section of schema.sql or the full script on a fresh database.

Disclaimer

Demo project only. Do not use weak secrets or default passwords in production. For HTTPS deployments, set cookie.secure: true on the session middleware.

About

Minimal ecommerce checkout demo built with Node.js, Express, HTML/CSS, and JavaScript featuring quantity validation, fake payment flow, and success page redirect.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors