Modern web dashboard for MySQL e-commerce databases with Role-Based Access Control, CRUD operations, database views, and real-time analytics.
Complete web-based interface for managing MySQL e-commerce databases with enterprise-grade security and intuitive operations.
Key Features:
- Role-Based Access Control - 6 user roles with specific permissions
- CRUD Operations - Create, Read, Update, Delete with smart forms
- Database Views - Access role-specific views with search and export
- Audit Trails - Track all changes with who, what, when
- Interactive Visualizations - Real-time charts powered by Plotly
- Security - SQL injection prevention, data masking, security logs
Perfect for: Database administrators, developers, business analysts, and students.
- Python 3.8+
- MySQL Server 8.0+
# 1. Clone/Download the project
git clone <repository-url>
cd new_database_project
# 2. Configure database connection
# Copy .env.example to .env and update with your credentials
cp .env.example .env
# Edit .env with your MySQL credentials
# 3. Install and run
pip install -r requirements.txt
streamlit run app.pyWindows users: Double-click run_dashboard.bat
Dashboard opens at: http://localhost:8501 π
Login with different roles to access role-specific features:
| Role | Username | Access |
|---|---|---|
| Administrator | admin_user |
Full access + audit trails + security logs |
| Sales Manager | sales_manager |
Customers, orders, sales view |
| Customer Service | customer_service |
Customer data, returns, service view |
| Warehouse Staff | warehouse_staff |
Products, inventory, suppliers |
| Marketing Team | marketing_team |
Analytics view, customer insights |
| Delivery Coordinator | delivery_coordinator |
Deliveries, active delivery view |
Features:
- Auto-generated smart forms (date pickers, dropdowns, number inputs)
- Primary key protection (auto-increment, read-only)
- CHECK constraint validation
- Foreign key awareness
- Confirmation dialogs for deletions
Access role-specific database views:
- Browse pre-filtered, pre-joined data
- Search and filter by any column
- View numeric statistics
- Export to CSV with timestamps
- Views include:
OrderSummaryView,CustomerServiceView,ReturnManagementView,MarketingAnalyticsView,ActiveDeliveryView
Quick Access Panel for:
customer_audit- Track customer changescard_audit- Monitor payment card updatesproduct_audit- Product modificationsorders_audit- Order changespayment_audit- Payment modificationssecurity_log- Security events and access attempts
Each log captures: User, action, old/new values, timestamp
8 Interactive Charts:
- Customer Age Distribution
- Customer Growth Over Time
- Customer Account Status
- Product Sales Analysis
- Product Stock Status
- Order Amount Distribution
- Order Status Overview
- Payment Status Breakdown
Features: Hover details, zoom, pan, download
mysql -u root -p
CREATE DATABASE ecommerce_db;
exit
# Import schema
mysql -u root -p ecommerce_db < normal_Schema_MySQL.sql
# Insert sample data (optional)
mysql -u root -p ecommerce_db < normal_insert.sql# Create user accounts
mysql -u root -p ecommerce_db < security/userAccountCreation.sql
# Grant privileges
mysql -u root -p ecommerce_db < security/GrantPrivilages.sql
# Create audit tables
mysql -u root -p ecommerce_db < security/AuditTrailTables.sql
# Enable triggers
mysql -u root -p ecommerce_db < security/Trigers.sql
# Create views
mysql -u root -p ecommerce_db < security/ViewAccessControl.sql
mysql -u root -p ecommerce_db < security/DataMaskingView.sql
mysql -u root -p ecommerce_db < security/SecurityLog.sqlUse the credentials you set in security/userAccountCreation.sql. Default usernames are:
Admin: admin_user
Sales: sales_manager
CS: customer_service
Warehouse: warehouse_staff
Marketing: marketing_team
Delivery: delivery_coordinator
Note: Change the default passwords in security/userAccountCreation.sql before running it in production!
- Select CRUD Operations mode
- Choose table from dropdown (or use Quick Access for audit tables)
- Select operation: Create, Read, Update, or Delete
- Complete the form/action
- Select View Data mode
- Choose a view from dropdown (only shows views you can access)
- Search/filter data
- Export to CSV if needed
- Select Visualizations mode
- Choose chart from dropdown (based on role permissions)
- Interact with charts (hover, zoom, download)
new_database_project/
βββ app.py # Main dashboard (1088 lines)
βββ requirements.txt # Dependencies
βββ run_dashboard.bat # Windows launcher
β
βββ π Documentation
β βββ README.md # This file
β βββ README_DASHBOARD.md # Dashboard-specific docs
β βββ VIEW_ACCESS_GUIDE.md # View data mode guide
β βββ AUDIT_TRAIL_GUIDE.md # Audit trails guide
β βββ Database_Security_Implementation_Report.md
β
βββ security/ # Security implementation
β βββ userAccountCreation.sql # User roles
β βββ GrantPrivilages.sql # Permissions
β βββ ViewAccessControl.sql # Role-specific views
β βββ AuditTrailTables.sql # Audit tables
β βββ Trigers.sql # Auto-audit triggers
β βββ DataMaskingView.sql # Sensitive data masking
β βββ SecurityLog.sql # Security event log
β
βββ UserRoleTests/ # Test scripts
β βββ *RoleTest.sql # SQL tests for each role
β
βββ normal_Schema_MySQL.sql # Database schema
βββ normal_insert.sql # Sample data
- All queries use parameterized statements (
:placeholderformat) - Password URL encoding for special characters
- Input validation on all forms
- 6 user roles with specific table/view permissions
- Operations restricted by role (create/read/update/delete)
- Visualizations filtered by role
- Automatic logging of all data modifications
- Captures: User, action (INSERT/UPDATE/DELETE), old/new values, timestamp
- Triggered automatically via MySQL triggers
- Credit cards:
****-****-****-1234 - Emails:
j***@example.com - Phone:
***-***-5678
- Failed login attempts
- Permission denials
- Suspicious activity
- Admin-only access
| Issue | Solution |
|---|---|
| Can't connect to MySQL | Check MySQL is running: services.msc (Windows) |
| Access denied | Verify credentials in .env file |
| Unknown database | Create database: CREATE DATABASE ecommerce_db; |
| No tables found | Import schema: mysql ... < normal_Schema_MySQL.sql |
| No views for role | The views are lowercase (e.g., activedeliveryview) |
| Audit tables not visible | Click dropdown and scroll to find *_audit tables |
| Foreign key constraint | Create parent record first (e.g., customer before order) |
Clear cache: Press C in browser or restart dashboard
streamlit>=1.28.0 # Web framework
pandas>=2.0.0 # Data manipulation
plotly>=5.17.0 # Visualizations
sqlalchemy>=2.0.0 # Database ORM
pymysql>=1.1.0 # MySQL driver
- Cached database connections (
@st.cache_resource) - SQLAlchemy connection pooling
- Parameterized queries for security
- Auto-schema detection
- Responsive wide layout
- β View Data Mode - Access role-specific database views with search/export
- β Audit Trail Access - Admin quick access panel for audit tables
- β Security Logs - Comprehensive security event tracking
- β Improved RBAC - Table and view permissions per role
- β View Names - Fixed lowercase view name handling
- β Documentation - Added VIEW_ACCESS_GUIDE.md and AUDIT_TRAIL_GUIDE.md
- View Access Guide: VIEW_ACCESS_GUIDE.md - How to use View Data mode
- Audit Trail Guide: AUDIT_TRAIL_GUIDE.md - Admin audit trail access
- Security Report: Database_Security_Implementation_Report.md
- Dashboard Details: README_DASHBOARD.md
Update the .env file:
MYSQL_HOST=your-host
MYSQL_PORT=3306
MYSQL_USER=your-username
MYSQL_PASSWORD=your-password
MYSQL_DATABASE=your-databaseDashboard auto-detects tables, columns, and generates forms!
Error messages include hints! Also check:
- Troubleshooting section above
- VIEW_ACCESS_GUIDE.md
- AUDIT_TRAIL_GUIDE.md
- Error logs in MySQL
Created for educational purposes. Free to use and modify.
π E-Commerce Database Management Dashboard v2.0
Built with β€οΈ using Streamlit, SQLAlchemy, and MySQL
Quick Start β’ Features β’ Setup β’ Documentation
Ready to manage your database? π
Run: run_dashboard.bat or streamlit run app.py
Login as: admin_user (with password from userAccountCreation.sql)