The project involves creating a tourist accommodation search and booking application using Node.js and Express. The application lists all apartments in the database and allows admin users to create, delete, and modify apartments, while regular users can view apartment details and make bookings.
- Menu with options for both administrators and clients.
- Elements aligned horizontally.
- Background color changes on hover.
- Form to add a new apartment with the following fields:
- Title: Eye-catching title for the apartment.
- Description: Brief overview of the apartment.
- Rules: Usage guidelines for the apartment.
- Rooms: Number of rooms.
- Beds: Number of beds in each room.
- Bathrooms: Number of bathrooms.
- Images: Maximum of 4 photos per apartment, with a text description indicating which part of the apartment the photo belongs to.
- Main Photo: One photo should be marked as the "main photo."
- Price per Night: Cost to rent the apartment.
- Max Guests: Maximum number of guests allowed.
- Square Meters: Usable area of the apartment.
- Services Available: Includes features like air conditioning, heating, TV, kitchen, and internet connectivity.
- Location: Includes province, city, and GPS coordinates.
- Validation of all fields upon submission, ensuring data integrity.
- Page displaying all available apartments with:
- Title (in uppercase).
- Price per night.
- Square meters.
- Main photo of the apartment.
- Services offered, represented by icons.
- Detailed view of each apartment when clicked, showing:
- Title
- Description
- Rules
- Number of rooms, beds, and bathrooms
- Images and descriptions
- Price and maximum guests
- Square meters
- Services available
- Clients can reserve an apartment for specific dates.
- If the apartment is available, the reservation is confirmed immediately.
- Reservations are stored in the database with relevant dates.
- Admin functionalities to modify or delete apartments.
- Search functionality based on guest capacity, price, city, and available dates.
- Clone the repository:
git clone https://github.com/your-username/tribook.git
- Navigate to the project directory:
cd tribook
- Install dependencies:
npm install
- Start the server:
npm start
- Open your browser and go to
http://localhost:3000
. - Use the menu to navigate between apartment listings and view the aparment details.
- Administrators can manage apartments while clients can reserve them.
express
: To create the server and handle routes.express-session
: For managing user sessions in Express app.ejs
: To generate dynamic HTML pages on the server side.morgan
: To log requests.mongoose
: To interact with MongoDB for data storage.w3.css
: For responsive design and layout.dotenv
: For environment variable management.connect-flash
: For setting and displaying temporary notifications to the user.nodemon
: To restart the server when file changes are detected, improving the development workflow.
This section provides an insight into the architecture of the project, focusing on the models, controllers, routes, and views used in the application.
The application utilizes Mongoose to define the data structure and interactions with MongoDB. Apartment model represents a collection in the database:
The controllers handle the business logic of the application. Key controllers include:
- Admin: Manages the CRUD operations for apartments, including creating, updating, and deleting listings.
- Auth: Handles user authentication and authorization, managing user sessions.
- Index: Renders the homepage, where it lists available apartments. It also handles filtering apartments based on user input and manages the reservation form.
The application uses Express Router to define the endpoints for the application. Key routes include:
Admin
GET /apartment/:idApartment/edit
GET /apartment/new-apartment
POST /apartment/new-apartment
Auth
GET /login
GET /logout
POST /login
Index
GET /
GET /apartment/:idApartment
GET /search
GET /apartment/:idApartment/new-booking
GET /about-us
GET /contact
POST /apartment/new-booking
The views are rendered using EJS, allowing dynamic content generation. The main views include:
- Home
- Apartment Details
- Login
- New Apartment
- New Booking
- Contact
- About us
The application is deployed and can be accessed at the following URL: Tribook
To gain access to administrative features (such as adding, editing, or deleting apartments), please contact me directly. I can provide you with the necessary environment variables for admin access.
Feel free to explore the demo versions of the application. You can see how to add, edit, and delete apartments without needing admin access. If you have any questions or need assistance, don’t hesitate to reach out!
- Demo Admin features: Add, Edit and Delete Apartment
- Demo Regular User features: View Apartments List, Filter and Made a Booking