Skip to content

Commit 8d40668

Browse files
This is an hostel management system. currently it has the user features like filtering, rating, commenting and admin features like admin dashboard. adding, editting and removing of hostels, comments, ratings. reporting and blocking of new users (it is not complete, need to add notification settings). super admin can add admins. the hostel image uploading system is not working(need to set the firestore or something like that research is on going).
1 parent 86c9086 commit 8d40668

59 files changed

Lines changed: 6760 additions & 1562 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

HOSTEL_README.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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+
- **Categories & Filtering**: Dynamic categorization system for amenities, room types, location types, price ranges, and atmosphere
12+
13+
### ⭐ Ratings & Reviews
14+
- **Rating System**: 5-star rating system with categories (overall, cleanliness, location, value, atmosphere)
15+
- **Comments**: User reviews with verification system
16+
- **Average Ratings**: Automatic calculation and display of average ratings
17+
18+
### 🔍 Search & Filtering
19+
- **Advanced Filtering**: Filter by amenities, room types, location types, price ranges, and atmosphere
20+
- **Tab Categories**:
21+
- All Hostels
22+
- Latest (added in last month)
23+
- Top Rated (4+ stars)
24+
- Budget Friendly (under $50)
25+
- This Week (added in last week)
26+
- Oldest (chronological order)
27+
28+
### 👥 User Management
29+
- **Admin System**: Firebase-based authentication with admin and super admin roles
30+
- **Role-based Access**: Only authorized users can add/edit hostels
31+
- **User Reviews**: Any authenticated user can rate and review hostels
32+
33+
## Database Schema
34+
35+
### Core Tables
36+
- **hostels**: Main hostel information
37+
- **hostel_images**: Image management with primary image support
38+
- **ratings**: User ratings with multiple categories
39+
- **comments**: User reviews and feedback
40+
- **categories**: Dynamic category system
41+
- **category_option_values**: Options for each category
42+
- **hostel_options**: Many-to-many relationship between hostels and category options
43+
44+
### Key Features
45+
- **Soft Delete**: Hostels are marked as inactive rather than deleted
46+
- **Image Management**: Support for multiple images per hostel
47+
- **Rating Categories**: Detailed rating system with multiple aspects
48+
- **Flexible Categories**: Dynamic category system that can be easily extended
49+
50+
## API Endpoints
51+
52+
### Hostels
53+
- `GET /api/hostels` - Fetch all active hostels with ratings and images
54+
- `POST /api/hostels` - Create new hostel (admin only)
55+
- `PUT /api/hostels` - Update hostel (admin only)
56+
- `DELETE /api/hostels` - Soft delete hostel (admin only)
57+
58+
### Ratings
59+
- `GET /api/ratings?hostelId=X` - Get ratings for a hostel
60+
- `POST /api/ratings` - Add new rating
61+
- `PUT /api/ratings` - Update rating
62+
- `DELETE /api/ratings?ratingId=X` - Delete rating
63+
64+
### Comments
65+
- `GET /api/comments?hostelId=X` - Get comments for a hostel
66+
- `POST /api/comments` - Add new comment
67+
- `PUT /api/comments` - Update comment
68+
- `DELETE /api/comments?commentId=X` - Delete comment
69+
70+
### Images
71+
- `GET /api/hostel-images?hostelId=X` - Get images for a hostel
72+
- `POST /api/hostel-images` - Add new image
73+
- `PUT /api/hostel-images` - Update image
74+
- `DELETE /api/hostel-images?imageId=X` - Delete image
75+
76+
## Setup Instructions
77+
78+
### 1. Database Setup
79+
```bash
80+
# Run migrations
81+
npm run db:migrate
82+
83+
# Seed categories
84+
npx tsx drizzle/seed-hostel-categories.ts
85+
86+
# Seed sample hostels (optional)
87+
npx tsx drizzle/seed-hostels.ts
88+
```
89+
90+
### 2. Environment Variables
91+
Ensure your `.env` file includes:
92+
- Database connection string
93+
- Firebase configuration
94+
- Any other required environment variables
95+
96+
### 3. Admin Setup
97+
1. Set up Firebase authentication
98+
2. Add admin users through the admin interface
99+
3. Configure admin roles (admin/superadmin)
100+
101+
## Category System
102+
103+
The system uses a flexible category system with the following default categories:
104+
105+
### Amenities
106+
- 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
107+
108+
### Room Types
109+
- Dormitory, Private Room, Double Room, Twin Room, Single Room, Family Room, Female Only Dorm, Male Only Dorm, Mixed Dorm
110+
111+
### Location Types
112+
- City Center, Near Train Station, Near Airport, Beachfront, Mountain View, Rural Area, University District, Shopping District, Historic District, Business District
113+
114+
### Price Ranges
115+
- Budget ($10-25), Economy ($25-50), Mid-range ($50-100), Premium ($100-200), Luxury ($200+)
116+
117+
### Atmosphere
118+
- Party/Social, Quiet/Relaxed, Family Friendly, Backpacker, Digital Nomad, Student, Eco-friendly, Boutique, Traditional
119+
120+
## Usage
121+
122+
### For Admins
123+
1. **Add Hostels**: Use the "Add Hostel" button (FAB) to create new hostels
124+
2. **Manage Categories**: Add/edit categories and options through the admin interface
125+
3. **Moderate Reviews**: Approve/verify user comments and ratings
126+
4. **Update Information**: Edit hostel details, images, and contact information
127+
128+
### For Users
129+
1. **Browse Hostels**: View all hostels with filtering options
130+
2. **Search & Filter**: Use the filter panel to find specific hostels
131+
3. **View Details**: Click on hostel cards to see full information
132+
4. **Rate & Review**: Leave ratings and comments for hostels you've visited
133+
5. **View on Map**: Click "View on Map" to see hostel location on Google Maps
134+
135+
## Technical Stack
136+
137+
- **Frontend**: Next.js 14, React, TypeScript, Tailwind CSS
138+
- **Backend**: Next.js API Routes
139+
- **Database**: PostgreSQL with Drizzle ORM
140+
- **Authentication**: Firebase Auth
141+
- **Deployment**: Vercel (recommended)
142+
143+
## Contributing
144+
145+
1. Fork the repository
146+
2. Create a feature branch
147+
3. Make your changes
148+
4. Add tests if applicable
149+
5. Submit a pull request
150+
151+
## License
152+
153+
This project is licensed under the MIT License.
154+
155+
## Support
156+
157+
For support or questions, please open an issue in the repository or contact the development team.

SETUP_GUIDE.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Setup Guide for Hostel Management System
2+
3+
## Prerequisites
4+
5+
1. **PostgreSQL Database**: You need a PostgreSQL database running
6+
2. **Firebase Project**: For authentication (optional but recommended)
7+
3. **Node.js**: Version 18 or higher
8+
9+
## Step 1: Environment Configuration
10+
11+
Create a `.env.local` file in the root directory with the following variables:
12+
13+
```bash
14+
# Database Configuration
15+
DATABASE_URL="postgresql://username:password@localhost:5432/hostel_management"
16+
17+
# Firebase Configuration (for authentication)
18+
NEXT_PUBLIC_FIREBASE_API_KEY="your-firebase-api-key"
19+
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN="your-project.firebaseapp.com"
20+
NEXT_PUBLIC_FIREBASE_PROJECT_ID="your-project-id"
21+
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET="your-project.appspot.com"
22+
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID="123456789"
23+
NEXT_PUBLIC_FIREBASE_APP_ID="your-app-id"
24+
25+
# Firebase Admin SDK (for server-side operations)
26+
FIREBASE_ADMIN_PROJECT_ID="your-project-id"
27+
FIREBASE_ADMIN_PRIVATE_KEY="your-private-key"
28+
FIREBASE_ADMIN_CLIENT_EMAIL="your-client-email"
29+
```
30+
31+
### Database Setup Options:
32+
33+
#### Option A: Local PostgreSQL
34+
```bash
35+
# Install PostgreSQL locally
36+
sudo apt-get install postgresql postgresql-contrib
37+
38+
# Create database
39+
sudo -u postgres createdb hostel_management
40+
41+
# Create user (optional)
42+
sudo -u postgres createuser --interactive
43+
44+
# Update DATABASE_URL in .env.local
45+
DATABASE_URL="postgresql://username:password@localhost:5432/hostel_management"
46+
```
47+
48+
#### Option B: Cloud Database (Recommended)
49+
- **Neon**: Free PostgreSQL hosting
50+
- **Supabase**: Free PostgreSQL hosting with additional features
51+
- **Railway**: Easy PostgreSQL deployment
52+
53+
Example Neon URL:
54+
```
55+
DATABASE_URL="postgresql://username:password@ep-xyz.us-east-1.aws.neon.tech/hostel_management?sslmode=require"
56+
```
57+
58+
## Step 2: Install Dependencies
59+
60+
```bash
61+
npm install
62+
```
63+
64+
## Step 3: Run Database Migration
65+
66+
```bash
67+
npm run drizzle:migrate
68+
```
69+
70+
## Step 4: Seed the Database
71+
72+
```bash
73+
# Seed categories
74+
npx tsx drizzle/seed-hostel-categories.ts
75+
76+
# Seed sample hostels (optional)
77+
npx tsx drizzle/seed-hostels.ts
78+
```
79+
80+
## Step 5: Start Development Server
81+
82+
```bash
83+
npm run dev
84+
```
85+
86+
The application will be available at `http://localhost:3001`
87+
88+
## Step 6: Firebase Setup (Optional)
89+
90+
1. Go to [Firebase Console](https://console.firebase.google.com/)
91+
2. Create a new project
92+
3. Enable Authentication (Email/Password)
93+
4. Get your project credentials
94+
5. Update the Firebase variables in `.env.local`
95+
96+
## Troubleshooting
97+
98+
### Database Connection Issues
99+
- Ensure PostgreSQL is running
100+
- Check your DATABASE_URL format
101+
- Verify database exists and user has permissions
102+
103+
### Migration Issues
104+
- Make sure DATABASE_URL is set correctly
105+
- Check if database is accessible
106+
- Verify drizzle config is correct
107+
108+
### Firebase Issues
109+
- Ensure all Firebase variables are set
110+
- Check Firebase project configuration
111+
- Verify authentication is enabled
112+
113+
## Quick Start with Sample Data
114+
115+
If you want to test the system quickly:
116+
117+
1. Set up a free Neon database
118+
2. Update DATABASE_URL in .env.local
119+
3. Run migrations and seed scripts
120+
4. Start the development server
121+
122+
You'll have a fully functional hostel management system with sample data!
123+
124+
## Admin Access
125+
126+
To add hostels, you need admin privileges:
127+
128+
1. Set up Firebase authentication
129+
2. Add admin users through the admin interface
130+
3. Login with admin credentials to add/edit hostels
131+
132+
## Support
133+
134+
If you encounter any issues:
135+
1. Check the console for error messages
136+
2. Verify all environment variables are set
137+
3. Ensure database is accessible
138+
4. Check Firebase configuration

0 commit comments

Comments
 (0)