AirBnB_clone

A command line Interface for an AirBnb clone

⬇️Go straight to bottom

HBNB - Command Line Interface

THe HBNB console is the first step in an attempt to clone the known AirBnb site. The console is a commmand line interface that enables the user manage models, i.e perform crate, read, update, delete,.. operations on the models. “model” in a OOP project is the representation of an object/instance.




Navigate


——— CONCEPT ——–

The console ⚡

pictorial representaion of the role of the console what part the console plays

Storage 💾

Persistency is really important for a web application. It means: every time your program is executed, it starts with all objects previously created from another execution. Without persistency, all the work done in a previous execution won’t be saved and will be gone.

In this project, you will manipulate 2 types of storage: file and database. For the moment, you will focus on file.

Why separate “storage management” from “model”? It’s to make your models modular and independent. With this architecture, you can easily replace your storage system without re-coding everything everywhere.

You will always use class attributes for any object. Why not instance attributes? For 3 reasons:


Data-diagram 🧮

pictorial representation of model relationship


——— TECHNICAL ——–

Files and Directories 📂

How to setup locally 🏁

I assume you’re working on a linux machine, Arch Linux preferably 🙂

To get a copy of the repo and test on you machine please follow the steps below

How does the whole thing work?? ⚙

This is divided into two aspects, namely:

How can I store my instances? ⚙

That’s a good question. So let’s take a look at this code:

class Student():
    def __init__(self, name):
        self.name = name

students = []
s = Student("John")
students.append(s)

Here, I’m creating a student and store it in a list. But after this program execution, my Student instance doesn’t exist anymore.

class Student():
    def __init__(self, name):
        self.name = name

students = reload() # recreate the list of Student objects from a file
s = Student("John")
students.append(s)
save(students) # save all Student objects to a file

Nice!

But how does it works?

First, let’s look at save(students):

The best solution is to convert this list of Student objects to a JSON representation.

Why JSON? Because it’s a standard representation of object. It allows us to share this data with other developers, be human readable, but mainly to be understood by another language/program.

Example:

Here’s what it looks like:

pictorial representation of the functionality of interacting with models

How does the console work? ⚙

There’s another good question!

Here are some of the console commands and what they do:

Here’s an illustration:

pictorial representation of the functionality of the console



Bugs 🦠

No bugs at the moment, but if you notice any, please raise an issue.

Author 🐱‍🏍

License and Contribution 👨‍👩

Free to use, operating under MIT license policy

For contribution please see contribution guildlines

⬆️Go to the top