A lightweight store application with authentication, role-based access control, and a simple product ordering system.
- ✅ 3 User Roles: Admin, Manager, Customer
- ✅ Authentication System: Secure login with password hashing
- ✅ SQLite Database: Lightweight SQL database
- ✅ Product Store: Browse and order products
- ✅ Admin Dashboard: Manage users, products, and orders
- ✅ Manager Dashboard: View inventory and orders
- ✅ Test API: REST API endpoints for integration testing
chmod +x setup.sh
./setup.shThen start the app:
source venv/bin/activate
python app.pysetup.batThen start the app:
venv\Scripts\activate.bat
python app.py1. Create Virtual Environment (Recommended)
Linux/Mac:
python3 -m venv venv
source venv/bin/activateWindows:
python -m venv venv
venv\Scripts\activate.bat2. Install Dependencies
pip install -r requirements.txt3. Initialize Database
python init_db.pyThis will create the SQLite database with sample data.
4. Run the Application
python app.pyThe app will be available at: http://localhost:5000
- Admin: username:
admin, password:admin123 - Manager: username:
manager, password:manager123 - Customer: username:
customer, password:customer123
- Browse products
- Place orders
- View product details
- All Customer permissions
- View inventory dashboard
- View all orders
- All Manager permissions
- View user management
- Access admin dashboard
- View complete system stats
The application includes REST API endpoints for testing:
GET /api/test/health- Health checkGET /api/test/products- Get all productsGET /api/test/users- Get all users (without passwords)GET /api/test/orders- Get all orders
Run the test service:
pip install requests
python test_service.pyOr use curl:
# Health check
curl http://localhost:5000/api/test/health
# Get products
curl http://localhost:5000/api/test/products
# Get users
curl http://localhost:5000/api/test/users
# Get orders
curl http://localhost:5000/api/test/orders.
├── app.py # Main Flask application
├── init_db.py # Database initialization script
├── test_service.py # API integration tests
├── requirements.txt # Python dependencies
├── store.db # SQLite database (created after init)
└── templates/ # HTML templates
├── login.html
├── store.html
├── admin.html
└── manager.html
- id, username, password (hashed), role, email
- id, name, description, price, stock
- id, user_id, product_id, quantity, total_price, order_date
This is a simple demo application. For production use:
- Change the Flask secret key
- Use environment variables for sensitive data
- Implement proper password requirements
- Add HTTPS
- Add CSRF protection
- Implement rate limiting