- Python
- Django
- Redis
- PostgreSQL
- JWT
- qrcode
- opencv
-
Clone the application using GitHub
-
pip install pipenv
-
pipenv install
-
pipenv shell
-
add
.env
file-
Example env variables
SECRET_KEY= HOST= PORT= POSTGRES_USER= POSTGRES_PASSWORD= TWO_FACTOR_API_KEY=
-
-
Connect to your PostgreSQL and Redis server
-
python manage.py makemigrations
-
python manage.py migrate
-
python manage.py runserver
- Signup
- POST: /api/user/send_otp/
- Enter the Phone number, password, etc in the body
- Validate the User data
- Send OTP to the phone using 2-factor APIs and store user_data & session_id in the Redis cache temporarily till OTP verification
- POST: /api/user/verify_otp/
- Enter phone and otp
- validate OTP
- Create User in database
- POST: /api/user/send_otp/
- Authenticate
- POST: /api/authenticate/
- Enter phone and password
- Get Access and refresh token
- Use it for every other APIs for authentication
- POST: /api/authenticate/
- Station
- POST: /api/station/create/
- Create station using name and location
- Check If User is Admin
- Create station in database
- GET: /api/station/vehicles?station_id=<station_id>
- Get all vehicles in this station
- POST: /api/station/create/
- Vehicle
- POST: /api/vehicle/create/
- Send request using company, model, status, etc.
- Create vehicle in database
- Generate QR code for the vehicle using vehicle_id
- Package Used:
qrcode
- Package Used:
- Store QR code in static folder
- In real-world, print the QR code and paste it on Vehicles
- POST: /api/vehicle/create/
- Booking
- User will visit the store for booking
- In real-world will scan the QR code of vehicle and enter booking details
- Here I have used the following steps for booking
- On frontend, a QR code scanner will be implemented using OpenCV library.
- It will send the scanned QR code path or url to server
- Server will decode the Vehicle_id from QR code
- And then that vehicle will be booked till mentioned date
- mark the vehicle as
in_use
- POST: /api/booking/book_vehicle/
- Send qr_code_path and end_date to server
- booking will be confirmed by server with booking id
- GET: /api/booking/return_vehicle?booking_id=<booking_id>
- send booking_id to server
- server will accept the vehicle and mark the vehicle
available