https://github.com/nickssilver/airbnb_clone
A copy of the AirBnB website to cover all fundamental concepts of the higher level programming track
https://github.com/nickssilver/airbnb_clone
airbnb group-project oop oops-in-python
Last synced: 5 months ago
JSON representation
A copy of the AirBnB website to cover all fundamental concepts of the higher level programming track
- Host: GitHub
- URL: https://github.com/nickssilver/airbnb_clone
- Owner: nickssilver
- Created: 2022-11-25T21:46:04.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-28T06:13:06.000Z (about 3 years ago)
- Last Synced: 2025-06-15T15:18:03.642Z (6 months ago)
- Topics: airbnb, group-project, oop, oops-in-python
- Language: Python
- Homepage:
- Size: 321 KB
- Stars: 1
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Authors: AUTHORS
Awesome Lists containing this project
README
# AirBnB clone - The console

## Description
This team project is part of the ALX School Full-Stack Software Engineer program.
It's the first step towards building a first full web application: an AirBnB clone.
This first step consists of a custom command-line interface for data management, and the base classes for the storage of this data. Console commands allow the user to create, update, and destroy objects, as well as manage file storage. Using a system of JSON serialization/deserialization, storage is persistent between sessions.
## 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
- **Mary Kiige** ~ [mkiige77@gmail.com](https://github.com/Mkiige) :
- **Nick Gitobu** - [silvernicks9@gmail.com](https://github.com/nickssilver) ~ [@pronic_tech](https://twitter.com/pronic_tech):