An open API service indexing awesome lists of open source software.

https://github.com/G1Joshi/Booking-App

Full-Stack Dart Application using Flutter and Dart-Frog
https://github.com/G1Joshi/Booking-App

backend dart dart-frog flutter frontend full-stack postgres

Last synced: 4 months ago
JSON representation

Full-Stack Dart Application using Flutter and Dart-Frog

Awesome Lists containing this project

README

          

# ๐Ÿจ Booking App

[![Web App](https://github.com/G1Joshi/Booking-App/actions/workflows/main.yml/badge.svg)](https://github.com/G1Joshi/Booking-App/actions/workflows/main.yml)
[![Melos](https://img.shields.io/badge/maintained%20with-melos-f700ff)](https://melos.invertase.dev/)

A full-stack hotel booking application built with **Flutter** (Frontend) and **Dart Frog** (Backend) with **PostgreSQL** database. This application allows users to search for hotels, view details, make bookings, and leave reviews.

[![Flutter](https://img.shields.io/badge/Flutter-02569B?logo=flutter&logoColor=white)](https://flutter.dev)
[![Dart](https://img.shields.io/badge/Dart-0175C2?logo=dart&logoColor=white)](https://dart.dev)
[![Docker](https://img.shields.io/badge/Docker-2496ED?logo=docker&logoColor=white)](https://docs.docker.com/)
[![PostgreSQL](https://img.shields.io/badge/PostgreSQL-336791?logo=postgresql&logoColor=white)](https://www.postgresql.org)

---

## ๐Ÿ“‘ Table of Contents

- [Features](#-features)
- [Architecture](#-architecture)
- [Database Schema](#-database-schema-er-diagram)
- [Prerequisites](#-prerequisites)
- [Installation & Setup](#-installation--setup)
- [Initialize Workspace](#1-initialize-workspace)
- [Backend Setup](#2-backend-setup)
- [Running the Application](#-running-the-application)
- [Technologies Used](#-technologies-used)
- [Troubleshooting](#-troubleshooting)

---

## โœจ Features

### User Features

- ๐Ÿ” **Hotel Search** - Search hotels by location with radius-based filtering
- ๐Ÿจ **Hotel Listings** - Browse hotels with detailed information
- ๐Ÿ›๏ธ **Room Categories** - View different room types and availability
- ๐Ÿ“… **Booking System** - Book rooms with check-in/check-out dates
- โญ **Reviews & Ratings** - Read and write hotel reviews
- ๐ŸŽฏ **Advanced Filters** - Filter by star rating, property type, price, and more
- ๐Ÿ“ฑ **Multi-Platform** - Runs on iOS, Android, Web, and Windows

### Admin Features

- ๐Ÿ—๏ธ **Hotel Management** - Add, update, and delete hotels
- ๐Ÿ“Š **Data Seeding** - Generate fake data for testing (1000+ hotels)
- ๐Ÿ”‘ **API Secret Key** - Admin operations protected by secret key

---

## ๐Ÿ—๏ธ Architecture

This application follows a **3-tier architecture**:

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ PRESENTATION LAYER โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Flutter Frontend (BLoC Pattern) โ”‚ โ”‚
โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ Auth Page โ”‚ โ”‚ Hotel List โ”‚ โ”‚ Hotel Details โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ Auth Bloc โ”‚ โ”‚ Hotel Bloc โ”‚ โ”‚ Repositories โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ HTTP/REST API
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ APPLICATION LAYER โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Dart Frog Backend (RESTful API) โ”‚ โ”‚
โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ API Routes (v1) โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ /auth/signup /auth/signin /hotels /search โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ /hotels/:id/room /hotels/:id/review โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ /hotels/:id/room/:id/booking โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ Middleware Layer โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ Auth โ”‚ DB Connection โ”‚ Services โ”‚ Logging โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ Controllers & Services โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ AuthController HotelController BookingService โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ SQL Queries
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ DATA LAYER โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ PostgreSQL Database โ”‚ โ”‚
โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚ โ”‚ โ”‚Users โ”‚ โ”‚Hotels โ”‚ โ”‚Rooms โ”‚ โ”‚Bookings โ”‚ โ”‚Reviewsโ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚ โ”‚ โ”‚Address โ”‚ โ”‚Contact โ”‚ โ”‚Details โ”‚ โ”‚Localities โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ Triggers: Auto-update hotel ratings โ”‚ โ”‚
โ”‚ โ”‚ Functions: Distance calculation (geolocation) โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

### Frontend Architecture (Flutter BLoC)

```
apps/frontend/
โ”œโ”€โ”€ lib/
โ”‚ โ”œโ”€โ”€ app/
โ”‚ โ”‚ โ”œโ”€โ”€ / # Feature-based organization
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ bloc/ # State management (BLoC)
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ view/ # UI components & pages
โ”‚ โ”œโ”€โ”€ data/
โ”‚ โ”‚ โ”œโ”€โ”€ client/ # HTTP clients (e.g., Dio)
โ”‚ โ”‚ โ”œโ”€โ”€ model/ # Data models
โ”‚ โ”‚ โ””โ”€โ”€ repository/ # Data repositories
โ”‚ โ”œโ”€โ”€ config/ # App configuration (routes, theme)
โ”‚ โ””โ”€โ”€ l10n/ # Internationalization
```

### Backend Architecture (Dart Frog)

```
apps/backend/
โ”œโ”€โ”€ routes/
โ”‚ โ”œโ”€โ”€ api/v1/
โ”‚ โ”‚ โ”œโ”€โ”€ / # Resource endpoints
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ index.dart # GET / POST
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ [id].dart # Dynamic routes
โ”‚ โ””โ”€โ”€ index.dart # Root endpoint
โ”œโ”€โ”€ lib/
โ”‚ โ”œโ”€โ”€ controller/ # Request handlers & validation
โ”‚ โ”œโ”€โ”€ service/ # Business logic
โ”‚ โ”œโ”€โ”€ middleware/ # Auth, logging, injection
โ”‚ โ”œโ”€โ”€ models/ # Re-exports from shared packages
โ”‚ โ””โ”€โ”€ database/
โ”‚ โ”œโ”€โ”€ extensions/ # *Db classes (HotelDb, UserDb, etc.)
โ”‚ โ””โ”€โ”€ tables.dart # Table name constants
```

### Shared Packages

```
packages/
โ”œโ”€โ”€ models/ # booking_models: Shared DTOs (Hotel, User, Booking, etc.)
โ”‚ โ””โ”€โ”€ lib/src/ # common model files
โ””โ”€โ”€ utils/ # booking_utils: Shared utilities & API constants
โ””โ”€โ”€ lib/src/
โ”œโ”€โ”€ endpoints.dart # API endpoint constants
โ””โ”€โ”€ rating_utils.dart
```

---

## ๐Ÿ—„๏ธ Database Schema (ER Diagram)

```mermaid
erDiagram
users ||--o{ bookings : makes
users ||--o{ reviews : writes
hotels ||--o{ rooms : contains
hotels ||--o{ reviews : receives
hotels ||--|| address : has
hotels ||--|| contact : has
hotels ||--|| details : has
rooms ||--o{ bookings : has

users {
varchar id PK
varchar name
varchar email
varchar password
varchar access_token
varchar profile_image
bigint phone
date date_of_birth
varchar city
varchar state
varchar country
bigint pincode
}

hotels {
integer id PK
varchar name
text description
varchar property_type
varchar chain
integer star
real rating
integer rooms_starting_price
varchar cover_image
}

address {
serial id PK
varchar street
varchar city
varchar state
varchar country
bigint pincode
real latitude
real longitude
integer hotel_id FK
}

contact {
serial id PK
bigint phone
varchar email
varchar website
integer hotel_id FK
}

details {
serial id PK
text[] amenities
text[] rules
text[] preferences
text[] hotel_images
integer hotel_id FK
}

rooms {
serial id PK
varchar category
text description
integer price
integer count
integer capacity
text[] amenities
text[] room_images
integer hotel_id FK
}

bookings {
serial id PK
varchar status
date booking_date
date checkin
date checkout
integer rooms
integer guests
integer room_id FK
varchar user_id FK
}

reviews {
serial id PK
real rating
text review
text[] guest_images
integer hotel_id FK
varchar user_id FK
}

localities {
serial id PK
text name
real latitude
real longitude
}
```

### Key Relationships

- **Users** can make multiple **Bookings** and write multiple **Reviews**
- **Hotels** have one **Address**, one **Contact**, and one **Details** record
- **Hotels** contain multiple **Rooms** and receive multiple **Reviews**
- **Rooms** can have multiple **Bookings**
- **Localities** are used for geolocation-based search

### Database Functions & Triggers

- **`distance()`** - Calculates distance between two coordinates (geolocation search)
- **`update_hotel_rating()`** - Automatically updates hotel rating when a review is added

---

## ๐Ÿ“‹ Prerequisites

Before you begin, ensure you have the following installed:

- **Flutter SDK**: >= 3.35.0
- **Dart SDK**: >= 3.9.0 (comes with Flutter)
- **PostgreSQL**: >= 15.x
- **Docker & Docker Compose**: (Optional, for containerized setup)
- **Melos**: Install with `dart pub global activate melos`
- **Dart Frog CLI**: Install with `dart pub global activate dart_frog_cli`
- **Very Good CLI**: Install with `dart pub global activate very_good_cli`

### System Requirements

- **OS**: macOS, Linux, or Windows
- **RAM**: Minimum 8GB recommended
- **Storage**: 5GB free space

---

## ๐Ÿš€ Installation & Setup

### 1. Initialize Workspace

#### Step 1.1: Clone the Repository

```bash
git clone https://github.com/G1Joshi/Booking-App.git
cd Booking-App
```

#### Step 1.2: Bootstrap Workspace

This command installs dependencies for all packages and links them.

```bash
melos run install
```

### 2. Backend Setup

#### Step 2.1: Initialize Database Schema

To initialize the database, you first need to start the backend services (which includes the database container).

1. **Start Backend**: Follow the instructions in [Running the Application](#-running-the-application) to start the backend.
2. **Initialize Schema**: Once the backend is running, run the following SQL scripts in order:

```
apps/backend/queries/
โ”œโ”€โ”€ drop/
โ”œโ”€โ”€ tables/
โ”œโ”€โ”€ functions/
โ”œโ”€โ”€ triggers/
โ””โ”€โ”€ seed/
```

---

## ๐ŸŽฎ Running the Application

This project uses **Melos** to manage scripts. You can run the backend and frontend using the following commands from the root of the project.

### Start Backend Server

```bash
melos run run:backend
```

This command will:

1. Start the Docker containers (PostgreSQL).
2. Start the Dart Frog development server on port `8090`.

Server will start at: `http://localhost:8090`

### Start Frontend Application

```bash
melos run run:frontend
```

This command will run the frontend in Chrome (Web) with the development flavor.

---

## ๐Ÿ› ๏ธ Technologies Used

### Frontend

| Technology | Purpose |
| ----------------------------------------------------------------- | ------------------------------ |
| [Flutter](https://flutter.dev) | Cross-platform UI framework |
| [Dart](https://dart.dev) | Programming language |
| [flutter_bloc](https://pub.dev/packages/flutter_bloc) | State management (BLoC) |
| [Dio](https://pub.dev/packages/dio) | HTTP client for API calls |
| [shared_preferences](https://pub.dev/packages/shared_preferences) | Local storage for tokens |
| [flutter_rating_bar](https://pub.dev/packages/flutter_rating_bar) | Rating UI component |
| [shimmer](https://pub.dev/packages/shimmer) | Loading shimmer animations |
| [equatable](https://pub.dev/packages/equatable) | Value equality for BLoC |
| [intl](https://pub.dev/packages/intl) | Internationalization & formats |

### Backend

| Technology | Purpose |
| --------------------------------------------- | ----------------------------------- |
| [Dart Frog](https://dart-frog.dev) | Backend REST API framework |
| [Dart](https://dart.dev) | Programming language |
| [PostgreSQL](https://www.postgresql.org) | Relational database |
| [postgres](https://pub.dev/packages/postgres) | PostgreSQL driver for Dart |
| [uuid](https://pub.dev/packages/uuid) | UUID v4 for access token generation |

### DevOps

| Technology | Purpose |
| -------------------------------------------------- | ----------------------------- |
| [Docker](https://www.docker.com) | Containerization |
| [Docker Compose](https://docs.docker.com/compose/) | Multi-container orchestration |
| [Adminer](https://www.adminer.org) | Database management tool |
| [Melos](https://melos.invertase.dev) | Monorepo management |

---

## ๐Ÿงช Testing

### Backend Tests

```bash
melos run test:backend
```

### Frontend Tests

```bash
melos run test:frontend
```

### Shared Models Tests

```bash
melos run test:models
```

### Shared Utils Tests

```bash
melos run test:utils
```

---

## ๐Ÿ› Troubleshooting

### Backend Issues

**Issue: Database connection failed**

```
Solution:
1. Check if PostgreSQL is running: pg_isready
3. Ensure database exists: psql -l
```

### Frontend Issues

**Issue: Cannot connect to backend**

```
Solution:
1. Verify backend is running on localhost:8080
2. Check API_URL in lib/config/apis.dart
3. For physical devices, use network IP instead of localhost
```

---

## ๐Ÿ‘จโ€๐Ÿ’ป Author

**Jeevan Joshi** ([@G1Joshi](https://github.com/G1Joshi))

---

## ๐Ÿ™ Acknowledgments

- [Very Good Ventures](https://verygood.ventures) for Flutter best practices
- [Dart Frog Team](https://dart-frog.dev) for the amazing backend framework
- [Invertase](https://invertase.io) for `Melos` to manage monorepo
- [Flutter Community](https://flutter.dev/community) for continuous support

---

**Happy Coding! ๐Ÿš€**