|
| 1 | +# Hostel Management System |
| 2 | + |
| 3 | +This project has been converted from a project management system to a comprehensive hostel management system. The system allows admins and super admins to manage hostels, while users can browse, filter, and review hostels. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +### 🏨 Hostel Management |
| 8 | +- **Add Hostels**: Only admins and super admins can add new hostels |
| 9 | +- **Hostel Information**: Complete hostel details including name, description, location (Google Maps link), contact info, and pricing |
| 10 | +- **Image Management**: Support for multiple hostel images with primary image designation |
| 11 | +- **Image Slider & Fullscreen View**: Hostel images are displayed in a modern Swiper slider. Click any image to view it fullscreen in a high-quality modal/lightbox. |
| 12 | +- **Categories & Filtering**: Dynamic categorization system for amenities, room types, location types, price ranges, and atmosphere |
| 13 | + |
| 14 | +### ⭐ Ratings & Reviews |
| 15 | +- **Rating System**: 5-star rating system with categories (overall, cleanliness, location, value, atmosphere) |
| 16 | +- **Comments**: User reviews with verification system |
| 17 | +- **Average Ratings**: Automatic calculation and display of average ratings |
| 18 | + |
| 19 | +### 🔍 Search & Filtering |
| 20 | +- **Advanced Filtering**: Filter by amenities, room types, location types, price ranges, and atmosphere |
| 21 | +- **Tab Categories**: |
| 22 | + - All Hostels |
| 23 | + - Latest (added in last month) |
| 24 | + - Top Rated (4+ stars) |
| 25 | + - Budget Friendly (under $50) |
| 26 | + - This Week (added in last week) |
| 27 | + - Oldest (chronological order) |
| 28 | + |
| 29 | +### 👥 User Management |
| 30 | +- **Admin System**: Firebase-based authentication with admin and super admin roles |
| 31 | +- **Role-based Access**: Only authorized users can add/edit hostels |
| 32 | +- **User Reviews**: Any authenticated user can rate and review hostels |
| 33 | + |
| 34 | +## Image Storage with Cloudinary |
| 35 | + |
| 36 | +Hostel images are now uploaded and stored using [Cloudinary](https://cloudinary.com/). The backend handles image uploads and stores the returned Cloudinary URLs in the database. **Firebase Storage is no longer used for images.** |
| 37 | + |
| 38 | +### Cloudinary Features |
| 39 | +- **High-Quality Images**: Images are displayed using Cloudinary's `q_auto:best` transformation for optimal quality. |
| 40 | +- **Image Slider**: All hostel images are shown in a Swiper slider, supporting multiple images per hostel. |
| 41 | +- **Fullscreen Modal/Lightbox**: Click any image to view it fullscreen in a modal for a better viewing experience. |
| 42 | +- **Responsive Design**: The slider and modal are fully responsive and accessible. |
| 43 | +- **Custom Transformations**: You can customize Cloudinary transformations (e.g., resizing, cropping, quality) by editing the image URL or backend logic. |
| 44 | + |
| 45 | +### Cloudinary Setup |
| 46 | +1. **Create a Cloudinary account** at https://cloudinary.com/ (free tier is sufficient). |
| 47 | +2. **Get your credentials** from the Cloudinary dashboard: |
| 48 | + - Cloud name |
| 49 | + - API Key |
| 50 | + - API Secret |
| 51 | +3. **Add these to your `.env.local` file:** |
| 52 | + ```env |
| 53 | + CLOUDINARY_CLOUD_NAME=your_cloud_name |
| 54 | + CLOUDINARY_API_KEY=your_api_key |
| 55 | + CLOUDINARY_API_SECRET=your_api_secret |
| 56 | + ``` |
| 57 | +4. **Install the Cloudinary SDK:** |
| 58 | + ```bash |
| 59 | + npm install cloudinary |
| 60 | + ``` |
| 61 | +5. **No further setup is needed.** The backend API will handle all uploads and return the Cloudinary image URLs for use in the app. |
| 62 | + |
| 63 | +## UI Improvements |
| 64 | +- **Single Card Per Row**: Hostel cards are now displayed one per row for better readability. |
| 65 | +- **Modern Card/Grid Design**: The UI uses a clean, modern design with responsive layouts. |
| 66 | +- **Accessible Image Viewing**: All images are accessible and can be viewed fullscreen for better detail. |
| 67 | + |
| 68 | +## Database Schema |
| 69 | + |
| 70 | +### Core Tables |
| 71 | +- **hostels**: Main hostel information |
| 72 | +- **hostel_images**: Image management with primary image support (stores Cloudinary URLs) |
| 73 | +- **ratings**: User ratings with multiple categories |
| 74 | +- **comments**: User reviews and feedback |
| 75 | +- **categories**: Dynamic category system |
| 76 | +- **category_option_values**: Options for each category |
| 77 | +- **hostel_options**: Many-to-many relationship between hostels and category options |
| 78 | + |
| 79 | +### Key Features |
| 80 | +- **Soft Delete**: Hostels are marked as inactive rather than deleted |
| 81 | +- **Image Management**: Support for multiple images per hostel |
| 82 | +- **Rating Categories**: Detailed rating system with multiple aspects |
| 83 | +- **Flexible Categories**: Dynamic category system that can be easily extended |
| 84 | + |
| 85 | +## API Endpoints |
| 86 | + |
| 87 | +### Hostels |
| 88 | +- `GET /api/hostels` - Fetch all active hostels with ratings and images |
| 89 | +- `POST /api/hostels` - Create new hostel (admin only) |
| 90 | +- `PUT /api/hostels` - Update hostel (admin only) |
| 91 | +- `DELETE /api/hostels` - Soft delete hostel (admin only) |
| 92 | + |
| 93 | +### Ratings |
| 94 | +- `GET /api/ratings?hostelId=X` - Get ratings for a hostel |
| 95 | +- `POST /api/ratings` - Add new rating |
| 96 | +- `PUT /api/ratings` - Update rating |
| 97 | +- `DELETE /api/ratings?ratingId=X` - Delete rating |
| 98 | + |
| 99 | +### Comments |
| 100 | +- `GET /api/comments?hostelId=X` - Get comments for a hostel |
| 101 | +- `POST /api/comments` - Add new comment |
| 102 | +- `PUT /api/comments` - Update comment |
| 103 | +- `DELETE /api/comments?commentId=X` - Delete comment |
| 104 | + |
| 105 | +### Images |
| 106 | +- `GET /api/hostel-images?hostelId=X` - Get images for a hostel |
| 107 | +- `POST /api/hostel-images` - Add new image |
| 108 | +- `PUT /api/hostel-images` - Update image |
| 109 | +- `DELETE /api/hostel-images?imageId=X` - Delete image |
| 110 | + |
| 111 | +## Setup Instructions |
| 112 | + |
| 113 | +### 1. Database Setup |
| 114 | +```bash |
| 115 | +# Run migrations |
| 116 | +npm run db:migrate |
| 117 | + |
| 118 | +# Seed categories |
| 119 | +npx tsx drizzle/seed-hostel-categories.ts |
| 120 | + |
| 121 | +# Seed sample hostels (optional) |
| 122 | +npx tsx drizzle/seed-hostels.ts |
| 123 | +``` |
| 124 | + |
| 125 | +### 2. Environment Variables |
| 126 | +Ensure your `.env` file includes: |
| 127 | +- Database connection string |
| 128 | +- Firebase configuration |
| 129 | +- Any other required environment variables |
| 130 | + |
| 131 | +### 3. Admin Setup |
| 132 | +1. Set up Firebase authentication |
| 133 | +2. Add admin users through the admin interface |
| 134 | +3. Configure admin roles (admin/superadmin) |
| 135 | + |
| 136 | +## Category System |
| 137 | + |
| 138 | +The system uses a flexible category system with the following default categories: |
| 139 | + |
| 140 | +### Amenities |
| 141 | +- Free WiFi, Kitchen, Laundry, Common Room, Garden/Terrace, Bar, Breakfast Included, Air Conditioning, Heating, Luggage Storage, 24/7 Reception, Security Lockers, Bicycle Rental, Tour Desk, BBQ Area |
| 142 | + |
| 143 | +### Room Types |
| 144 | +- Dormitory, Private Room, Double Room, Twin Room, Single Room, Family Room, Female Only Dorm, Male Only Dorm, Mixed Dorm |
| 145 | + |
| 146 | +### Location Types |
| 147 | +- City Center, Near Train Station, Near Airport, Beachfront, Mountain View, Rural Area, University District, Shopping District, Historic District, Business District |
| 148 | + |
| 149 | +### Price Ranges |
| 150 | +- Budget ($10-25), Economy ($25-50), Mid-range ($50-100), Premium ($100-200), Luxury ($200+) |
| 151 | + |
| 152 | +### Atmosphere |
| 153 | +- Party/Social, Quiet/Relaxed, Family Friendly, Backpacker, Digital Nomad, Student, Eco-friendly, Boutique, Traditional |
| 154 | + |
| 155 | +## Usage |
| 156 | + |
| 157 | +### For Admins |
| 158 | +1. **Add Hostels**: Use the "Add Hostel" button (FAB) to create new hostels |
| 159 | +2. **Manage Categories**: Add/edit categories and options through the admin interface |
| 160 | +3. **Moderate Reviews**: Approve/verify user comments and ratings |
| 161 | +4. **Update Information**: Edit hostel details, images, and contact information |
| 162 | + |
| 163 | +### For Users |
| 164 | +1. **Browse Hostels**: View all hostels with filtering options |
| 165 | +2. **Search & Filter**: Use the filter panel to find specific hostels |
| 166 | +3. **View Details**: Click on hostel cards to see full information |
| 167 | +4. **Rate & Review**: Leave ratings and comments for hostels you've visited |
| 168 | +5. **View on Map**: Click "View on Map" to see hostel location on Google Maps |
| 169 | + |
| 170 | +## Technical Stack |
| 171 | + |
| 172 | +- **Frontend**: Next.js 14, React, TypeScript, Tailwind CSS |
| 173 | +- **Backend**: Next.js API Routes |
| 174 | +- **Database**: PostgreSQL with Drizzle ORM |
| 175 | +- **Authentication**: Firebase Auth |
| 176 | +- **Deployment**: Vercel (recommended) |
| 177 | + |
| 178 | +## Contributing |
| 179 | + |
| 180 | +1. Fork the repository |
| 181 | +2. Create a feature branch |
| 182 | +3. Make your changes |
| 183 | +4. Add tests if applicable |
| 184 | +5. Submit a pull request |
| 185 | + |
| 186 | +## License |
| 187 | + |
| 188 | +This project is licensed under the MIT License. |
| 189 | + |
| 190 | +## Support |
| 191 | + |
| 192 | +For support or questions, please open an issue in the repository or contact the development team. |
0 commit comments