-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
270 lines (209 loc) ยท 8.01 KB
/
index.js
File metadata and controls
270 lines (209 loc) ยท 8.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# ๐ช Hong Kong Food Carnival
<div align="center">




**A comprehensive event management and booth reservation system for food carnival events**
[Features](#-features) โข [Installation](#-installation) โข [Usage](#-usage) โข [Tech Stack](#-tech-stack) โข [License](#-license)
</div>
---
## ๐ Overview
The Hong Kong Food Carnival platform is a full-featured web application designed to streamline event management, booth reservations, and vendor operations for large-scale food carnival events. Built with Node.js and Express, it offers real-time updates, interactive booth mapping, QR code ticketing, and comprehensive analytics.
## โจ Features
### ๐ซ For Attendees
- **Interactive Booth Exploration** - Visual floor plans with real-time availability
- **Smart Booking System** - Reserve premium, standard, or economy booths
- **Digital Ticketing** - QR code-based tickets with instant generation
- **Secure Payments** - Multiple payment methods supported
- **Profile Management** - Track bookings, transactions, and preferences
- **Real-time Updates** - Live booth availability via WebSocket
### ๐จโ๐ผ For Administrators
- **Event Management** - Create and manage multiple carnival events
- **Booth Configuration** - Dynamic booth editor with tier management
- **User Administration** - Comprehensive user management dashboard
- **Transaction Monitoring** - Real-time payment and booking tracking
- **Analytics Dashboard** - Revenue insights, booking trends, and statistics
- **QR Scanner** - Validate tickets and manage check-ins
### ๐จ Visual Features
- **Themed Booth Zones** - Wellness, Snacks, Global Flavors, Organic, Desserts, Beverages
- **Multi-floor Support** - Harbour View Hall & Sky Garden Pavilion
- **Responsive Design** - Mobile-friendly interface
- **Interactive Maps** - Color-coded booth status visualization
## ๐ Installation
### Prerequisites
- Node.js 18.x or higher
- npm or yarn package manager
### Setup Steps
1. **Clone the repository**
```bash
git clone https://github.com/YOUR_USERNAME/BoothSystem.git
cd BoothSystem
```
2. **Install dependencies**
```bash
npm install
```
3. **Configure environment** (optional)
```bash
# Create .env file
PORT=3000
SESSION_SECRET=your-secret-key
NODE_ENV=development
```
4. **Start the server**
```bash
npm start
```
5. **Access the application**
```
http://localhost:3000
```
## ๐ Usage
### Default Accounts
**Admin Account:**
- Username: `admin`
- Password: `adminpass`
**Test User Account:**
- Username: `TestUser`
- Password: `TestUser123`
### Key Routes
| Route | Description |
|-------|-------------|
| `/` | Home & Login |
| `/register` | New user registration |
| `/dashboard` | User dashboard |
| `/booths/:eventId` | Browse and book booths |
| `/payment/:bookingId` | Secure payment processing |
| `/digital-ticket/:bookingId` | View digital ticket |
| `/admin/*` | Admin panel (requires admin role) |
## ๐ Tech Stack
### Backend
- **Express.js 5.x** - Web application framework
- **Socket.IO 4.x** - Real-time bidirectional communication
- **EJS** - Server-side templating
- **bcrypt** - Password hashing
- **Express Session** - Session management
- **Multer** - File upload handling
### Frontend
- **Vanilla JavaScript** - Client-side interactivity
- **Chart.js** - Data visualization
- **CSS3** - Modern styling and animations
### Features & Libraries
- **QRCode** - QR code generation
- **PDFKit** - PDF ticket generation
- **json2csv** - Data export functionality
- **uuid** - Unique identifier generation
### Data Management
- **JSON File Storage** - Lightweight data persistence (development)
- In-memory caching for serverless deployments
## ๐ Project Structure
```
minproj/
โโโ api/ # Serverless function entry
โ โโโ index.js
โโโ data/ # Data layer
โ โโโ db.json # JSON database
โ โโโ store.js # Data access functions
โโโ public/ # Static assets
โ โโโ css/
โ โ โโโ styles.css # Application styles
โ โโโ js/ # Client-side scripts
โ โ โโโ analytics-dashboard.js
โ โ โโโ booth-editor.js
โ โ โโโ booth-map.js
โ โ โโโ dashboard.js
โ โ โโโ qr-scanner.js
โ โโโ uploads/ # User uploads
โโโ views/ # EJS templates
โ โโโ partials/ # Reusable components
โ โโโ admin-*.ejs # Admin pages
โ โโโ booths.ejs # Booth selection
โ โโโ dashboard.ejs # User dashboard
โ โโโ digital-ticket.ejs # Ticket display
โ โโโ login.ejs # Authentication
โ โโโ payment.ejs # Payment processing
โ โโโ profile.ejs # User profile
โโโ server.js # Main application server
โโโ package.json # Dependencies
โโโ README.md # Documentation
```
## ๐ฏ Key Functionalities
### Booth Management
- **Three-tier system**: Premium ($820), Standard ($620), Economy ($480)
- **40 booths** across two floors with themed zones
- **Real-time availability** tracking
- **Visual status indicators**: Available, Booked, Processing
### Payment Processing
- Credit/Debit card support
- PayPal integration
- Bank transfer options
- Secure transaction logging
### Digital Ticketing
- Unique QR codes for each booking
- Downloadable PDF tickets
- Email delivery ready
- Admin QR scanner for validation
### Analytics & Reporting
- Revenue tracking by tier
- Booking trends over time
- Popular booth analysis
- Transaction history export (CSV)
## ๐ Deployment
### Render.com (Recommended)
1. Push code to GitHub
2. Connect repository to Render
3. Deploy as Web Service
4. `render.yaml` configuration included
### Alternative Platforms
- **Railway.app** - Easy deployment with CLI
- **Fly.io** - Global edge deployment
- **Heroku** - Traditional PaaS
- **DigitalOcean App Platform** - Managed infrastructure
> **Note**: Vercel serverless deployment requires additional configuration for sessions and file uploads.
## ๐ Security Features
- **bcrypt** password hashing
- Session-based authentication
- CSRF protection ready
- Secure cookie configuration
- Input validation and sanitization
## ๐ API Endpoints
### Public Routes
- `GET /` - Home page
- `POST /login` - User authentication
- `POST /register` - User registration
- `GET /booths/:eventId` - View available booths
- `POST /bookings` - Create new booking
### Protected Routes
- `GET /dashboard` - User dashboard
- `GET /profile` - User profile
- `POST /profile/upload` - Avatar upload
- `GET /transactions` - Transaction history
### Admin Routes
- `GET /admin/dashboard` - Admin overview
- `GET /admin/analytics` - Analytics dashboard
- `GET /admin/booth-editor/:eventId` - Edit booth configuration
- `POST /admin/events` - Create new event
- `DELETE /admin/users/:userId` - Remove user
## ๐ License
This project is licensed under the ISC License.
## ๐ฅ Authors
Built with โค๏ธ for Hong Kong Food Carnival 2025
## ๐ Known Issues
- Serverless deployments (Vercel) require external database for data persistence
- Socket.IO features disabled in serverless environments
- File uploads stored in `/tmp` directory on serverless platforms
## ๐ฎ Future Enhancements
- [ ] PostgreSQL/MongoDB integration
- [ ] Email notification system
- [ ] Mobile app (React Native)
- [ ] Vendor management portal
- [ ] Multi-language support
- [ ] Advanced analytics with ML predictions
- [ ] Social media integration
- [ ] Live event streaming
---
<div align="center">
**โญ Star this repository if you find it helpful!**
Made with Express.js โข Socket.IO โข Chart.js
</div>