A full-stack web application for managing medical products, orders, customers, and suppliers with an admin panel.
- β Admin Management - Secure authentication with role-based access
- β Category Management - Create, Read, Update, Delete (CRUD) categories
- β Product Management - Full CRUD operations for products with inventory tracking
- β Order Management - Complete order lifecycle management with status tracking
- β Customer Management - Maintain customer database with contact information
- β Supplier Management - Track suppliers and their details
- β Dashboard - Real-time statistics and analytics
- π¨ Modern, responsive UI built with React
- π₯ Vite for fast development and optimized builds
- π± Mobile-friendly design
- π Secure JWT-based authentication
- πΎ MySQL database with Sequelize ORM
- π RESTful API architecture
- π Comprehensive database schema with relationships
Before you begin, ensure you have the following installed:
- Node.js (v14 or higher)
- MySQL (v5.7 or higher)
- npm (comes with Node.js)
git clone <your-repo-url>
cd "SM web/SM web"npm installcd backend
npm install
cd ..Create a .env file in the backend directory with the following:
PORT=5000
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_mysql_password
DB_NAME=sm_web
JWT_SECRET=thisIsASuperSecretKey123!
FRONTEND_URL=http://localhost:3000
NODE_ENV=developmentImportant: Replace your_mysql_password with your actual MySQL password.
Run the database setup script to create the database, tables, and insert sample data:
cd backend
npm run db:setupThis will:
- Create the
sm_webdatabase - Create all necessary tables (Admins, Categories, Products, Orders, etc.)
- Insert sample data
- Create a default admin user (username:
admin, password:admin123)
You have two options to run the application:
npm run serverBackend will run on: http://localhost:5000
npm run devFrontend will run on: http://localhost:5173 (or the port Vite assigns)
# From the backend directory
npm run serverPOST /api/auth/login- Admin login
GET /api/categories- Get all categoriesGET /api/categories/:id- Get single categoryPOST /api/categories- Create categoryPUT /api/categories/:id- Update categoryDELETE /api/categories/:id- Delete category (soft delete)
GET /api/products- Get all products (with pagination & search)GET /api/products/:id- Get single productPOST /api/products- Create productPUT /api/products/:id- Update productDELETE /api/products/:id- Delete product (soft delete)
GET /api/orders- Get all ordersGET /api/orders/:id- Get single orderPOST /api/orders- Create orderPUT /api/orders/:id/status- Update order statusDELETE /api/orders/:id- Delete order
GET /api/customers- Get all customersGET /api/customers/:id- Get single customerPOST /api/customers- Create customerPUT /api/customers/:id- Update customerDELETE /api/customers/:id- Delete customer (soft delete)
GET /api/suppliers- Get all suppliersGET /api/suppliers/:id- Get single supplierPOST /api/suppliers- Create supplierPUT /api/suppliers/:id- Update supplierDELETE /api/suppliers/:id- Delete supplier (soft delete)
GET /api/dashboard/stats- Get dashboard statistics
The application uses the following database tables:
- Admins - Admin user credentials and roles
- Categories - Product categories
- Products - Product catalog with pricing and inventory
- Customers - Customer information
- Orders - Order summaries
- OrderItems - Individual items in orders
- Suppliers - Supplier information
- ActivityLogs - Audit trail of admin activities
After running the database setup, you can login with:
- Username:
admin - Password:
admin123
npm run dev- Start Vite development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run server- Run backend server from root
npm run server- Start backend with nodemon (auto-restart)npm run dev- Same as servernpm start- Start backend in production modenpm run db:setup- Setup database with schema and sample datanpm run data:import- Import seed datanpm run data:destroy- Destroy seed data
SM web/
βββ backend/
β βββ config/
β β βββ db.js # Database configuration
β βββ controllers/ # Route controllers
β β βββ authController.js
β β βββ categoryController.js
β β βββ productController.js
β β βββ orderController.js
β β βββ customerController.js
β β βββ supplierController.js
β βββ middleware/
β β βββ authMiddleware.js # JWT authentication
β βββ models/ # Sequelize models
β β βββ Admin.js
β β βββ Category.js
β β βββ Product.js
β β βββ Order.js
β β βββ Customer.js
β β βββ Supplier.js
β β βββ ActivityLog.js
β βββ routes/ # API routes
β βββ scripts/
β β βββ setupDatabase.js # Database setup script
β βββ .env # Environment variables
β βββ server.js # Express server
β βββ package.json
βββ database/
β βββ sm_web_database.sql # Complete database schema
βββ src/
β βββ components/ # React components
β βββ App.jsx
β βββ main.jsx
βββ index.html
βββ package.json
βββ vite.config.js
- Ensure MySQL is running
- Verify credentials in
.envfile - Check if the user has proper permissions
- Frontend: If port 5173 is busy, Vite will use the next available port
- Backend: Change
PORTin.envfile
# Reinstall dependencies
npm install
cd backend
npm install- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the ISC License.
For issues and questions, please open an issue on the repository or contact the development team.
Built with β€οΈ using React, Node.js, Express, and MySQL