The AirBnB Clone project aims to replicate the functionality of the AirBnB application and website. This includes the implementation of a comprehensive ecosystem, covering the database, storage, RESTful API, web framework, and front end. The application supports two storage engine models:
-
File Storage Engine:
- Implementation:
/models/engine/file_storage.py
- Implementation:
-
Database Storage Engine:
- Implementation:
/models/engine/db_storage.py - Setup scripts:
setup_mysql_test.sqlandsetup_mysql_test.sql(for more details, see below)
- Implementation:
- Operating System: Ubuntu 14.04 LTS
- Language: Python 3.4.3
- Web Server: Nginx/1.4.6
- Application Server: Flask 0.12.2, Jinja2 2.9.6
- Web Server Gateway: Gunicorn (version 19.7.1)
- Database: MySQL Ver 14.14 Distrib 5.7.18
- Documentation: Swagger (flasgger==0.6.6)
- Style:
- Python: PEP 8 (v. 1.7.0)
- Web Static: W3C Validator
- Bash: ShellCheck 0.3.3
- Directory:
/config/ - Nginx Configuration:
- Path:
/etc/nginx/sites-available/default - Enabled site: Symbolic link to the configuration file
- Path:
- Upstart Script:
- Path:
/etc/init/[FILE_NAME.conf] - Service Start:
$ sudo start airbnb.conf - Gunicorn Command:
$ gunicorn --bind 127.0.0.1:8001 wsgi.wsgi:web_flask.app
- Path:
- All integration with Gunicorn is managed through Upstart
.conffiles. - Python code for WSGI is in the
/wsgi/directory, running designated Flask Applications.
The project includes various setup scripts for automation, maintenance, or scaling:
dev/setup.sql: Drops test and dev databases, then reinitializes the database.- Usage:
$ cat dev/setup.sql | mysql -uroot -p
- Usage:
setup_mysql_dev.sql: Initializes the dev database with MySQL for testing.- Usage:
$ cat setup_mysql_dev.sql | mysql -uroot -p
- Usage:
setup_mysql_test.sql: Initializes the test database with MySQL for testing.- Usage:
$ cat setup_mysql_test.sql | mysql -uroot -p
- Usage:
0-setup_web_static.sh: Sets up Nginx web server config file & the file structure.- Usage:
$ sudo ./0-setup_web_static.sh
- Usage:
3-deploy_web_static.py: Utilizes functions from1-pack_web_static.py&2-do_deploy_web_static.pyusing Fabric3 for creating a.tgzfile of all local web static files and deploying them.- Usage:
$ fab -f 3-deploy_web_static.py deploy -i ~/.ssh/holberton -u ubuntu
- Usage:
- Unittest:
- File Storage Engine Model:
$ python3 -m unittest discover -v ./tests/ - Database Storage Engine Model:
$ HBNB_MYSQL_USER=hbnb_test HBNB_MYSQL_PWD=hbnb_test_pwd \ HBNB_MYSQL_HOST=localhost HBNB_MYSQL_DB=hbnb_test_db HBNB_TYPE_STORAGE=db \ python3 -m unittest discover -v ./tests/
- File Storage Engine Model:
- All Tests:
- Bash script
init_test.shexecutes all tests for both File Storage & Database Engine Models.- Checks PEP8 style
- Runs all unittests
- Runs all W3C_validator tests
- Cleans up
__pycache__directories and the storage file,file.json - Usage:
$ ./dev/init_test.sh
- Bash script
- Utilizes the
cmdlibrary to run tests in an interactive command-line interface.- File Storage Engine Model:
$ ./console.py - Database Storage Engine Model:
$ HBNB_MYSQL_USER=hbnb_test HBNB_MYSQL_PWD=hbnb_test_pwd \ HBNB_MYSQL_HOST=localhost HBNB_MYSQL_DB=hbnb_test_db HBNB_TYPE_STORAGE=db \ ./console.py - Detailed description of all tests:
(hbnb) help help
- File Storage Engine Model:
