Skip to content

Mohammed-seddik/Test-Store

Repository files navigation

Simple Store Application

A lightweight store application with authentication, role-based access control, and a simple product ordering system.

Features

  • 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

Quick Start

Option 1: Automated Setup (Linux/Mac)

chmod +x setup.sh
./setup.sh

Then start the app:

source venv/bin/activate
python app.py

Option 2: Automated Setup (Windows)

setup.bat

Then start the app:

venv\Scripts\activate.bat
python app.py

Option 3: Manual Setup

1. Create Virtual Environment (Recommended)

Linux/Mac:

python3 -m venv venv
source venv/bin/activate

Windows:

python -m venv venv
venv\Scripts\activate.bat

2. Install Dependencies

pip install -r requirements.txt

3. Initialize Database

python init_db.py

This will create the SQLite database with sample data.

4. Run the Application

python app.py

The app will be available at: http://localhost:5000

4. Login Credentials

  • Admin: username: admin, password: admin123
  • Manager: username: manager, password: manager123
  • Customer: username: customer, password: customer123

User Roles

Customer

  • Browse products
  • Place orders
  • View product details

Manager

  • All Customer permissions
  • View inventory dashboard
  • View all orders

Admin

  • All Manager permissions
  • View user management
  • Access admin dashboard
  • View complete system stats

API Endpoints (Test Service)

The application includes REST API endpoints for testing:

  • GET /api/test/health - Health check
  • GET /api/test/products - Get all products
  • GET /api/test/users - Get all users (without passwords)
  • GET /api/test/orders - Get all orders

Test the API

Run the test service:

pip install requests
python test_service.py

Or 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

Project Structure

.
├── 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

Database Schema

Users Table

  • id, username, password (hashed), role, email

Products Table

  • id, name, description, price, stock

Orders Table

  • id, user_id, product_id, quantity, total_price, order_date

Security Note

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages