Production e-commerce store setup script with RBAC
Production e-commerce store setup script with RBAC — an experiment shown in the showcase…
Lifecycle
Video
Production e-commerce store setup script with RBAC — an experiment shown in the showcase reel.
Details
Prompt
Act as a Senior Software Architect and DevOps Engineer. I need to build a lightweight, production-ready e-commerce store with Role-Based Access Control (RBAC) across 3 distinct roles (Customer, Staff, Admin). Each featuring their own isolated login and registration workflows. Environment: I am deploying and running this project inside a GitHub Codespace. Tech Stack: Node.js (Express), express-session, HTML5, Vanilla JavaScript (Fetch API + LocalStorage), and standard SQLite3 (using the official 'sqlite3' package). Please provide a SINGLE, fully comprehensive bash script (setup.sh) that I can execute in my Codespaces terminal to completely generate the directory structure and write the full production code into every single file. Do not use placeholders, shorthand comments, or "add logic here". Write out every line of code completely. The script must generate this exact architecture: 1. package.json (Configured with express, express-session, sqlite3, and dotenv dependencies) 2. config/config.js (System configurations, roles, Stripe/Paystack API key loaders based on a 'test' or 'live' environment flag) 3. database/db.js (Initializes the standard sqlite3 database connection, exports a db instance, and includes promise wrappers for db.all, db.get, and db.run to handle async/await operations cleanly) 4. database/schema.sql & seed.sql (SQL files creating users, products, orders, order_items table, and seeding the db with 'admin' and sample products) 5. public/ (Contains HTML layout files for storefront home, customer dashboard, staff dashboard, and admin dashboard. Each must include specific CSS/JS styles and files) 6. src/middleware/auth.js (Custom Express middleware blocking unauthorized routes using session data. requireCustomer, requireStaff, requireAdmin) 7. src/payments/ (Implementation files for Stripe/Paystack. service.js handles the API calls, stripeWrapper.js/paystackWrapper.js handles the specific platform logic) 8. src/controllers/ (Auth/Controller.js handling registration/login logic for all 3 roles, orderController.js for order management, and adminController is allowing admins to create staff accounts and query/await database operations) 9. src/app.js (The master Express server file mapping static routes, API endpoints, handling JSON body parsing, and managing session cookies securely. Bind the server to host '0.0.0.0' so Codespaces can successfully forward the port to the browser) At the very end of the bash script, include automated logic to run npm install, execute a script to initialize the store.db file from the SQL schema/seed files, and echo a clear message on how to start the server. Wrap the contents of every single file within 'cat << 'EOF' > path/to/file' statements inside the shell script.