https://github.com/tsohledev/airbnb_clone
Alx project to re-create AirBnB
https://github.com/tsohledev/airbnb_clone
Last synced: over 1 year ago
JSON representation
Alx project to re-create AirBnB
- Host: GitHub
- URL: https://github.com/tsohledev/airbnb_clone
- Owner: tsohleDev
- License: mit
- Created: 2023-02-13T03:15:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-16T02:29:42.000Z (over 2 years ago)
- Last Synced: 2025-01-21T04:32:19.834Z (over 1 year ago)
- Language: Python
- Size: 85.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# AirBnB clone
## Description
This team project is part of the Alx accelerator program.
This first step consists of a custom command-line interface for data management, and the base classes for the storage of this data.
## Usage
The console works both in interactive mode and non-interactive mode, much like a Unix shell.
It prints a prompt **(hbnb)** and waits for the user for input.
Command | Example
------- | -------
Run the console | ```./console.py```
Quit the console | ```(hbnb) quit```
Display the help for a command | ```(hbnb) help ```
Create an object (prints its id)| ```(hbnb) create ```
Show an object | ```(hbnb) show ``` or ```(hbnb) .show()```
Destroy an object | ```(hbnb) destroy ``` or ```(hbnb) .destroy()```
Show all objects, or all instances of a class | ```(hbnb) all``` or ```(hbnb) all ```
Update an attribute of an object | ```(hbnb) update ""``` or ```(hbnb) .update(, , "")```
Non-interactive mode example
```bash
$ echo "help" | ./console.py
(hbnb)
Documented commands (type help ):
========================================
EOF all count create destroy help quit show update
```
## Models
The folder [models](./models/) contains all the classes used in this project.
File | Description | Attributes
---- | ----------- | ----------
[base_model.py](./models/base_model.py) | BaseModel class for all the other classes | id, created_at, updated_at
[user.py](./models/user.py) | User class for future user information | email, password, first_name, last_name
[amenity.py](./models/amenity.py) | Amenity class for future amenity information | name
[city.py](./models/city.py) | City class for future location information | state_id, name
[state.py](./models/state.py) | State class for future location information | name
[place.py](./models/place.py) | Place class for future accomodation information | city_id, user_id, name, description, number_rooms, number_bathrooms, max_guest, price_by_night, latitude, longitude, amenity_ids
[review.py](./models/review.py) | Review class for future user/host review information | place_id, user_id, text
## File storage
The folder [engine](./models/engine/) manages the serialization and deserialization of all the data, following a JSON format.
A FileStorage class is defined in [file_storage.py](./models/engine/file_storage.py) with methods to follow this flow:
``` -> to_dict() -> -> JSON dump -> -> FILE -> -> JSON load -> -> ```
The [__init__.py](./models/__init__.py) file contains the instantiation of the FileStorage class called **storage**, followed by a call to the method reload() on that instance.
This allows the storage to be reloaded automatically at initialization, which recovers the serialized data.
## Tests
All the code is tested with the **unittest** module.
The test for the classes are in the [test_models](./tests/test_models/) folder.
## Authors
- [Tsohle Mokhemisi](https://github.com/tsohledev)
~ [LinkedIn](https://www.linkedin.com/in/tsohle)
~ [Twitter](https://twitter.com/Realtsohle)