Guest House Management System
Full-stack Guest House Management System for colleges/institutions with role-based workflows.
Stack
- Frontend: Next.js 14 (App Router) + TypeScript
- UI: Tailwind CSS + shadcn-style component primitives
- Backend: Next.js API routes
- Database: PostgreSQL
- Driver:
pg - Auth: JWT cookie session + role-based access
Roles
EMPLOYEE: Create, modify, cancel own bookingsAPPROVER: Approve/reject official bookingsESTATE_PRIMARY: Monitoring dashboard with booking details
Features Implemented
- Ecode login with JWT session
- Role-based dashboard access
- Booking form with:
- total guest auto-calculation
- rooms required auto-calculation
- Cancellation/modify flow with search filters
- Approver action screen
- Estate manager primary and secondary screens
- Reports:
- date-range based booking report
- Export reports to CSV/PDF
API Routes
POST /api/auth/loginPOST /api/auth/logoutGET /api/auth/mePOST /api/bookingsGET /api/bookingsGET /api/bookings/:idPUT /api/bookings/:idPOST /api/approvalPOST /api/room-allocationGET /api/reports?start_date=YYYY-MM-DD&end_date=YYYY-MM-DDGET /api/reports/export?format=csv|pdf&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD
Setup
- Install dependencies:
npm install
- Create your env file:
copy .env.example .env.local
- Update
.env.localwith your PostgreSQL connection details:
DB_HOST=aws-1-ap-northeast-2.pooler.supabase.com
DB_PORT=5432
DB_USER=postgres.blcocysbvqftdldanejj
DB_PASSWORD=your-password
DB_NAME=postgres
DB_SSL=true
- Create the database and tables in PostgreSQL:
-- Open and run: database/schema.sql
- Insert sample data:
-- Open and run: database/seed.sql
- Run the app:
npm run dev
- Verify database connection:
- Open
http://localhost:<port>/login. - Sign in with a seed user.
- If login works and dashboard data loads, DB connection is successful.
Step-by-Step: Connect to Database (Quick Guide)
- Create a PostgreSQL database, including Supabase if you prefer hosted Postgres.
- Run
database/schema.sql. - Run
database/seed.sql. - Set
DB_HOST,DB_PORT,DB_USER,DB_PASSWORD,DB_NAME, andDB_SSLin.env.local. - Add your Cloudflare Turnstile keys if you want login protection enabled locally:
NEXT_PUBLIC_TURNSTILE_SITE_KEYTURNSTILE_SECRET_KEY
- Start app with
npm run devand test login.
Default Seed Logins
EMP001 / passwordAPP001 / passwordEST001 / passwordEST002 / password
Deployment Notes
- Use a managed PostgreSQL database or Supabase for easiest deployment.
- If the app is hosted on Vercel, set
DB_HOST,DB_PORT,DB_USER,DB_PASSWORD,DB_NAME,DB_SSL=true,JWT_SECRET,NEXT_PUBLIC_TURNSTILE_SITE_KEY, andTURNSTILE_SECRET_KEYin the Vercel Environment Variables screen. - The login form uses Cloudflare Turnstile invisible mode, so you must create a Turnstile widget in Cloudflare and paste its site key and secret key into those env vars.
- Keep database, Turnstile, and JWT secrets in environment variables, never in source control.
Folder Structure
app/App Router pages and API routescomponents/UI and dashboard componentslib/DB, auth, validation, reports utilitiesdatabase/schema.sqlSQL schemadatabase/seed.sqlsample seed data