Node.js/Express backend API for Smart Shop mobile application.
- Node.js 20+ installed
- MySQL installed (XAMPP or standalone MySQL)
- MySQL database created
npm installCreate a .env file in the backend directory (copy from .env.example):
cp .env.example .envEdit .env with your configuration:
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=root
DB_NAME=smartshop
PORT=3000
JWT_SECRET=your-secret-key-here- Open MySQL (via XAMPP or MySQL command line)
- Create the database:
CREATE DATABASE smartshop;Or use phpMyAdmin:
- Open XAMPP → Start MySQL
- Open phpMyAdmin (http://localhost/phpmyadmin)
- Click "New" → Database name:
smartshop→ Create
npm startOr use the start script:
node start.jsThe server will:
- Initialize the database schema
- Seed initial products
- Start the API server on port 3000
Open your browser or use curl:
curl http://localhost:3000/healthYou should see: {"status":"ok","message":"Smart Shop API is running"}
Base URL: http://localhost:3000/api
/auth/*- Authentication endpoints/products/*- Product catalog/orders/*- Order management/shopping-lists/*- Shopping lists/payments/*- Payment processing/profile/*- User profile
The server auto-initializes the database schema on startup. If you need to reinitialize:
npm run init-db