Python 2.7+, pip, Redis, postgreSQL
- Move to
<project-dir>
, create virual environment and then activate it as
$ cd <project-dir>
$ virtualenv .environment
$ source .environment/bin/activate
- Edit configuration under
config.py
. i.e. provide configuration/settings related to DBs(PostgreSQL, Redis) and other constants. And depending upon the environment(Development, Staging, Testing, Production) set environment variable as -
$ export APP_SETTINGS=config.DevelopmentConfig # For ```Development``` mode.
If you are using PyCharm then environment variables can be specified under
run configuration
.
- Add project to
PYTHONPATH
as
$ export PYTHONPATH="$PYTHONPATH:." # . corresponds to current directory(project-dir)
- Under
<project-dir>
install requirements/dependencies as
$ pip install -r requirements.txt
- Then run
taxi.py
as
$ python taxi.py
- Run postgreSQL migrations as -
$ python manage.py db init # Only once.
$ python manage.py db migrate # Every time, in order to generate new migration.
$ python manage.py db upgrade # Every time, when migration(s) needs to be applied.
Now you can access the application by visiting
{protocol}://{host}:{port}
. For localhost it ishttp://localhost:5000
.
There are three applications.
Customer app
,Driver app
andDashboard app
- It can be accessed via
{host}:{port}/customerapp
. - Customer can make any number of requests to ride. Customer needs to enter
customer_id
while making the request,customer_id
can be string/integer.
- It can be accessed via
{host}:{port}/driverapp?id=<driver_id>
. Whereid
is driver's id & it can be string/integer. - Driver app contains three tabs -
Waiting - Shows all the
waiting
request(s) that needs to be served. Driver can choose to serve any request from here.
Ongoing - Shows the
ongoing
request(s) that are being served currently by this driver(<driver_id>
).
Completed - Shows the
completed
request(s) that are served in the past by this driver(<driver_id>
).
- It can be accessed via
{host}:{port}/dashboard
. - It shows all the request(s) along with their status, driver_id, customer_id, picked_up time, request_creation_time, completion_time etc.
There will be only 5 drivers. It can be configured under
config.py
asDRIVER_THRESHOLD
.
All the drivers are available all the time but they can serve one request at a time.
A customer can make any number of rides.
A ride will automatically be completed in 5 minutes. It can be configured under
config.py
asRIDE_COMPLETION_DURATION_IN_SEC
.