This project is a Flutter-based e-commerce system that connects to a MySQL database via a Node.js backend.
📁 lib/ ← โค้ด Flutter
├── components/ ← UI component ต่าง ๆ
├── models/ ← Model class เช่น product, cart
├── pages/ ← หน้าจอทั้งหมด (login, home, cart, etc.)
├── services/ ← ฟังก์ชัน service เช่น cart, API call
├── firebase_options.dart (✅ ถ้าใช้ Firebase ให้เก็บไว้)
├── main.dart ← จุดเริ่มต้นแอป
📁 node-backend/ ← โค้ดฝั่ง backend Node.js + Express
├── server.js
├── Database/ ← ไฟล์ SQL สำหรับ import ฐานข้อมูล
│ ├── raknummallshop_customer.sql
│ ├── raknummallshop_products.sql
│ ├── raknummallshop_purchase_history.sql
│ └── raknummallshop_reviews.sql
📄 README.md
flutter pub get
cd node-backend
npm install- Command in VS Code Terminal:
start ms-settings:developers✅ Only required when running on an Emulator on Windows. Not necessary for a real Android device.
- Open MySQL Workbench or CLI and run the SQL commands below 👇
CREATE DATABASE RAKNUMMALLSHOP;
USE RAKNUMMALLSHOP;
-- table products
CREATE TABLE products (
productid VARCHAR(36) PRIMARY KEY,
price DOUBLE NOT NULL,
type_product VARCHAR(50) NOT NULL,
description_product TEXT NOT NULL,
imageURL TEXT
);
-- table customer
CREATE TABLE customer (
customerid VARCHAR(36) PRIMARY KEY,
fullname VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
phone VARCHAR(20),
postalCode VARCHAR(10),
idCard VARCHAR(20),
address TEXT
);
-- table reviews
CREATE TABLE reviews (
review_id INT AUTO_INCREMENT PRIMARY KEY,
product_id VARCHAR(36),
username VARCHAR(100),
comment TEXT,
rating INT,
date DATE
);
-- table purchase_history
CREATE TABLE purchase_history (
id INT AUTO_INCREMENT PRIMARY KEY,
customerid VARCHAR(255),
productid VARCHAR(255),
quantity INT,
status VARCHAR(50) DEFAULT 'paid'
);Import the .sql files or use the SQL from the Database/ folder, which contains the full dataset (all product types + real reviews):
-- Run these files in MySQL Workbench or CLI:
source raknummallshop_products.sql;
source raknummallshop_customer.sql;
source raknummallshop_purchase_history.sql;
source raknummallshop_reviews.sql;✅ Alternatively, you can copy the SQL commands from each file and paste them into MySQL Workbench.
DROP USER IF EXISTS 'flutter'@'localhost';
CREATE USER 'flutter'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON RAKNUMMALLSHOP.* TO 'flutter'@'localhost';
FLUSH PRIVILEGES;Important! There are two ways to run the app: connecting via an Emulator in VS Code, or running on a real mobile device. These methods use different URLs. In login.dart, sign_in.dart, api_service.dart, purchase_service.dart, and review_service.dart, two different base URLs are used:
-When running on an Emulator, use: http://10.0.2.2:3000/
***The default setting in the code is for the emulator.
flutter run -d emulator-5554Or run from the Android Emulator opened in Android Studio.
cd node-backend
node server.js- Firebase: The project has a basic Firebase setup only to demonstrate future connectivity.
- Firebase is not actively used in the current code.
- If you want to enable Firebase:
- Register a Firebase Project on the Firebase Console
- Add the
google-services.jsontoandroid/app/ - Configure
firebase_options.dartwithflutterfire configure - Add
await Firebase.initializeApp()atmain.dart