hbnb is a web application that replicates the functionality of Airbnb, allowing users to manage and book various accommodations. This project is built using Flask and follows RESTful API principles.
- User registration and authentication
- Create, retrieve, update, and delete users
- Manage places, reviews, and amenities
- Input validation and error handling
- Well-documented API using Flask-RESTx
-
app/: Contains the core application code.
-
__init__.py: Initializes the application package. -
api/: Houses the API endpoints, organized by version (v1/).
- v1/: Contains version 1 of the API.
__init__.py: Initializes the v1 API module.- users.py: Manages user-related endpoints.
- places.py: Manages place-related endpoints.
- reviews.py: Manages review-related endpoints.
- amenities.py: Manages amenity-related endpoints.
- v1/: Contains version 1 of the API.
-
models/: Contains business logic classes for the application.
__init__.py: Initializes the models package.- user.py: Defines the User model.
- place.py: Defines the Place model.
- review.py: Defines the Review model.
- amenity.py: Defines the Amenity model.
-
services/: Implements the Facade pattern which manages the interaction between layers.
__init__.py: Initializes the services package.- facade.py: Contains business logic to interface between models and persistence layers.
-
persistence/: Implements an in-memory repository. This will later be replaced by a database-backed solution using SQLAlchemy.
__init__.py: Initializes the persistence package.- repository.py: Contains the repository implementation.
-
-
run.py: Entry point for running the Flask application.
-
config.py: Configures environment variables and application settings.
-
requirements.txt: Lists all Python packages needed for the project.
-
README.md: This file contains a brief overview of the project and instructions.
Relationships between the User, Place, Review and Amentiy classes reflect the connections between the real-world concepts represented by each entity.
- 👥🏘️ User and Place : A
Usercan create manyPlaces, but eachPlaceis associated with only oneUser. - 🏘️🗒️ Place and Review : A
Placecan have manyReviews, but eachReviewis associated with only onePlace. - 👥🗒️ User and Review : A
Usercan create manyReviews, but eachReviewis written by oneUser.
- 🏘️🚽 Place and Amenities : A
Placecan have manyAmenities, and anAmenitycan be associated with manyPlaces.
To install the necessary dependencies, run:
pip install -r requirements.txt
python run.py
POST /api/v1/users/- Register a new userGET /api/v1/users/- Retrieve a list of usersGET /api/v1/users/<user_id>- Get user details by IDPUT /api/v1/users/<user_id>- Update user details
POST /api/v1/places/- Create a new place
POST /api/v1/reviews/- Create a new review
POST /api/v1/amenities/- Create a new amenity
To run the tests, use the following command:
pytest filename
