Skip to content

Commit 29534b2

Browse files
Merge pull request #2 from Sooraj-krishna/main
Latest NearbyHostel code Transported the code from sooraj rep to codecompass for further developement
2 parents 572acc8 + 7295db4 commit 29534b2

File tree

105 files changed

+23087
-0
lines changed

Some content is hidden

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

105 files changed

+23087
-0
lines changed

.github/workflows/nextjs.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Deploy Next.js site to Pages
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Detect package manager
25+
id: detect-package-manager
26+
run: |
27+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
28+
echo "manager=yarn" >> $GITHUB_OUTPUT
29+
echo "command=install" >> $GITHUB_OUTPUT
30+
echo "runner=yarn" >> $GITHUB_OUTPUT
31+
elif [ -f "${{ github.workspace }}/package.json" ]; then
32+
echo "manager=npm" >> $GITHUB_OUTPUT
33+
echo "command=ci" >> $GITHUB_OUTPUT
34+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
35+
else
36+
echo "Unable to determine package manager"
37+
exit 1
38+
fi
39+
40+
- name: Setup Node.js
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: "20"
44+
cache: ${{ steps.detect-package-manager.outputs.manager }}
45+
46+
- name: Setup Pages
47+
uses: actions/configure-pages@v5
48+
with:
49+
static_site_generator: next
50+
51+
- name: Restore cache
52+
uses: actions/cache@v4
53+
with:
54+
path: .next/cache
55+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
56+
restore-keys: |
57+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
58+
59+
- name: Install dependencies
60+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
61+
62+
- name: Build with Next.js
63+
run: ${{ steps.detect-package-manager.outputs.runner }} next build
64+
env:
65+
FIREBASE_ADMIN_SDK_KEY: ${{ secrets.FIREBASE_ADMIN_SDK_KEY }}
66+
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
67+
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}
68+
NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }}
69+
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }}
70+
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }}
71+
NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}
72+
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}
73+
74+
75+
- name: Upload artifact
76+
uses: actions/upload-pages-artifact@v3
77+
with:
78+
path: ./out
79+
80+
deploy:
81+
environment:
82+
name: github-pages
83+
url: ${{ steps.deployment.outputs.page_url }}
84+
runs-on: ubuntu-latest
85+
needs: build
86+
steps:
87+
- name: Deploy to GitHub Pages
88+
id: deployment
89+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts

HOSTEL_README.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
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

Comments
 (0)