Air-BnB

AirBnB Clone

: Places Search with JSON Web Tokens Login.

Description

Project attempts to clone the the AirBnB application and website, including the database, storage, RESTful API, Web Framework, and Front End with jQuery & JavaScript Rendering. Currently the application is designed to run with 2 storage engine models:

$ BTCPBNB_MYSQL_USER=btcpbnb_dev BTCPBNB_MYSQL_PWD=btcpbnb_dev_pwd \
BTCPBNB_MYSQL_HOST=localhost BTCPBNB_MYSQL_DB=btcpbnb_dev_db BTCPBNB_TYPE_STORAGE=db \
[COMMAND HERE (example: python3 -m main_app.app)]

Environment

Configuration Files

The /config/ directory contains configuration files for nginx and the Upstart scripts. The nginx configuration file is for the configuration file in the path: /etc/nginx/sites-available/default. The enabled site is a sym link to that configuration file. The upstart script should be saved in the path: /etc/init/[FILE_NAME.conf]. To begin this service, execute:

$ sudo start airbnb.conf

This script’s main task is to execute the following gunicorn command:

$ gunicorn --bind 127.0.0.1:8001 wsgi.wsgi_airbnb:app.app

The gunicorn command starts an instance of a Flask Application.


Web Server Gateway Interface (WSGI)

All integration with gunicorn occurs with Upstart .conf files. The python code for the WSGI is listed in the /wsgi/ directory. These python files run the designated Flask Application.

Setup

This project comes with various setup scripts to support automation, especially during maintanence or to scale the entire project. The following files are the setupfiles along with a brief explanation:

Testing

unittest

This project uses python library, unittest to run tests on all python files. All unittests are in the ./tests directory with the command:

$ BTCPBNB_MYSQL_USER=btcpbnb_test BTCPBNB_MYSQL_PWD=btcpbnb_test_pwd \
BTCPBNB_MYSQL_HOST=localhost BTCPBNB_MYSQL_DB=btcpbnb_test_db BTCPBNB_TYPE_STORAGE=db \
python3 -m unittest discover -v ./tests/

All Tests

The bash script init_test.sh executes all these tests for both File Storage & DataBase Engine Models:

$ ./dev/init_test.sh

CLI Interactive Tests

File Storage Engine Model

$ ./console.py

To execute the CLI using the Database Storage Engine Model:

$ BTCPBNB_MYSQL_USER=btcpbnb_test BTCPBNB_MYSQL_PWD=btcpbnb_test_pwd \
BTCPBNB_MYSQL_HOST=localhost BTCPBNB_MYSQL_DB=btcpbnb_test_db BTCPBNB_TYPE_STORAGE=db \
./console.py

For a detailed description of all tests, run these commands in the CLI:

(btcpbnb) help help
List available commands with "help" or detailed help with "help cmd".
(btcpbnb) help

Documented commands (type help <topic>):
========================================
Amenity    City  Place   State  airbnb  create   help  show
BaseModel  EOF   Review  User   all     destroy  quit  update

(btcpbnb) help User
class method with .function() syntax
        Usage: User.<command>(<id>)
(btcpbnb) help create
create: create [ARG] [PARAM 1] [PARAM 2] ...
        ARG = Class Name
        PARAM = <key name>=<value>
                value syntax: "<value>"
        SYNOPSIS: Creates a new instance of the Class from given input ARG
                  and PARAMS. Key in PARAM = an instance attribute.
        EXAMPLE: create City name="Chicago"
                 City.create(name="Chicago")

Continuous Integration Tests

Uses Travis-CI to run all tests on all commits to the github repo

Authors

License

MIT License