SwiftShift is a web application built with Flask for managing movers, customers, and admin roles. The system allows users to sign up, log in, and access various functionalities based on their roles (Customer, Mover, Admin). Admins can manage users and movers, while customers can hire movers for their needs.
- Project Overview
- Technologies Used
- Setup & Installation
- Configuration
- Database Setup
- API Endpoints
- Seeding Data
- Running the App
- Testing
- License
SwiftShift provides a platform for managing the entire mover system, including users (customers), movers, and admins. The app supports role-based access, allowing customers to book movers, movers to provide services, and admins to manage the system.
- User Registration & Login: Customers can sign up, log in, and manage their accounts.
- Mover Profile: Movers can list their services, hourly rates, and experience.
- Admin Access: Admins can manage users, movers, and perform administrative tasks.
- JWT Authentication: Secure user login and registration with JWT tokens.
- Flask: Python web framework used to build the backend.
- Flask-SQLAlchemy: ORM for database management.
- Flask-JWT-Extended: For secure authentication using JWT.
- SQLite: Lightweight relational database used for development and production.
- Flask-Migrate: Database migration tool to handle schema changes.
- Werkzeug: For secure password handling.
git clone https://github.com/rushionsdomain/SwiftShift.git
cd SwiftShiftpython3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activatepip install -r requirements.txtThe application is configured via a Config class located in app/config.py. Some important settings to check or modify:
- SQLALCHEMY_DATABASE_URI: Defines the location of your SQLite database (default is
sqlite:///movers.db). - JWT_SECRET_KEY: A secret key used to sign and verify JWT tokens (you should change it to a secure string in production).
The project uses SQLite as the database and Flask-SQLAlchemy for ORM. You need to initialize the database and apply migrations.
-
Set the
FLASK_APPenvironment variable:export FLASK_APP=app.app:create_app # On Windows: set FLASK_APP=app.app:create_app
-
Initialize the migrations folder:
flask db init
-
Generate the migration scripts:
flask db migrate -m "Initial migration" -
Apply the migrations:
flask db upgrade
This will create the movers.db file and set up your database schema.
You can seed the database with initial user data using the seeds.py script. The seed data includes sample users, movers, and admins.
python3 app/seeds.pyThis will populate the database with sample data, which can be useful for development and testing.
-
Endpoint:
POST /auth/signup -
Request Body:
{ "email": "user@example.com", "name": "John Doe", "password": "password123", "role": "customer" } -
Response:
- Success:
{ "message": "User created successfully" } - Failure:
{ "message": "Email already exists" }
- Success:
-
Endpoint:
POST /auth/login -
Request Body:
{ "email": "user@example.com", "password": "password123" } -
Response:
- Success:
{ "access_token": "your_jwt_token_here" } - Failure:
{ "message": "Invalid credentials" }
- Success:
Once the database is set up, you can run the Flask app locally.
-
Set the
FLASK_APPenvironment variable:export FLASK_APP=app.app:create_app # On Windows: set FLASK_APP=app.app:create_app
-
Run the app:
flask run
The app will be available at http://localhost:5000.
To run tests, you should have test cases created under the tests/ directory. You can run the tests using pytest:
pytestThis project is licensed under the MIT License - see the LICENSE file for details.
SwiftShift is a robust system for managing movers, customers, and admins, with secure authentication and role-based access control. It uses Flask to build the backend and SQLite as the database, and it's easy to set up with just a few simple commands.