A full-stack web application for managing hostel operations β student registrations, room allocations, and daily attendance tracking. The backend is powered by Spring Boot and uses Google Sheets as the database, making data accessible and editable directly from a spreadsheet without any database hosting costs.
- Overview
- Architecture
- Project Structure
- Features
- Prerequisites
- Google Sheets Setup
- Backend Setup
- Frontend Setup
- Running the App
- API Reference
- Data Models
- Google Sheets Structure
- Tech Stack
The system has three core modules:
- Students β register, update, and remove hostel residents
- Rooms β manage rooms across blocks with capacity and occupancy tracking
- Attendance β mark daily check-in/check-out status per student with date-range queries
All data is stored in a Google Sheet, giving non-technical staff full visibility and easy export (CSV, Excel, PDF) without ever touching the application.
Browser (Next.js :3000)
β
β /api/* (Next.js rewrites β proxy)
βΌ
Spring Boot REST API (:8080)
β
β Google Sheets API v4
βΌ
Google Sheets Spreadsheet
βββ Students sheet
βββ Rooms sheet
βββ Attendance sheet
The Next.js next.config.mjs rewrites all /api/* requests to http://localhost:8080/api/*, so the frontend never hardcodes the backend port directly in component code.
Hostel-Management-System/
β
βββ Hostel-backend-main/ # Spring Boot backend
β βββ pom.xml # Maven dependencies
β βββ src/main/
β βββ java/com/hostelmanagement/
β β βββ HostelManagementApplication.java # Entry point
β β βββ config/
β β β βββ GoogleSheetsConfig.java # Google Sheets API bean
β β βββ controller/
β β β βββ StudentController.java # /api/students endpoints
β β β βββ RoomController.java # /api/rooms endpoints
β β β βββ AttendanceController.java # /api/attendance endpoints
β β βββ model/
β β β βββ Student.java # Student entity + sheet row mapping
β β β βββ Room.java # Room entity + sheet row mapping
β β β βββ AttendanceRecord.java # Attendance entity + sheet row mapping
β β βββ service/
β β βββ GoogleSheetsService.java # Low-level read/write/delete helpers
β β βββ StudentService.java # Student CRUD logic
β β βββ RoomService.java # Room CRUD + availability logic
β β βββ AttendanceService.java # Attendance CRUD + date range logic
β βββ resources/
β βββ application.properties # Server + Google Sheets config
β βββ google-sheets-credentials.json # β Place your service account key here
β
βββ Hostel-frontend-main/ # Next.js frontend
βββ app/
β βββ page.tsx # Dashboard β stats, check-ins, occupancy
β βββ layout.tsx # Root layout
β βββ students/page.tsx # Students list + management
β βββ rooms/page.tsx # Rooms list + management
β βββ attendance/page.tsx # Attendance table + marking
β βββ api/ # Next.js Route Handlers (mock fallback)
β βββ students/route.ts
β βββ rooms/route.ts
β βββ attendance/route.ts
βββ components/
β βββ add-student-dialog.tsx # Form dialog β add new student
β βββ add-room-dialog.tsx # Form dialog β add new room
β βββ take-attendance-dialog.tsx # Bulk attendance marking dialog
β βββ ui/ # shadcn/ui component library
βββ lib/
β βββ api-client.ts # Axios wrapper for all backend calls
β βββ utils.ts
βββ next.config.mjs # Proxy rewrites /api/* β :8080
βββ package.json
Dashboard
- Live stats: total students, available rooms, present today, number of blocks
- Recent check-ins table (last 5 present students for the day)
- Per-block room occupancy progress bars
Students
- Add students with name, email, phone, address, emergency contact, room assignment
- Validates room exists and is available before registration
- Edit and delete student records
Rooms
- Add rooms with block, floor, capacity, type (standard / deluxe / suite), and status
- Filter by block or status
- View available rooms at a glance
Attendance
- Bulk attendance marking via searchable, filterable student table with checkboxes
- Filter by block or search by name/ID
- View attendance by date or date range
- Query per-student attendance history
| Tool | Version | Notes |
|---|---|---|
| Java | 17+ | Required for Spring Boot 3.x |
| Maven | 3.6+ | Bundled via ./mvnw wrapper |
| Node.js | 18+ | For Next.js frontend |
| Google Cloud account | β | For Sheets API credentials |
Go to Google Sheets, create a new spreadsheet named "Hostel Management System", and add three sheets (tabs): Students, Rooms, Attendance.
From the URL: https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit β copy the YOUR_SPREADSHEET_ID portion.
- Go to Google Cloud Console
- Create a project (or select an existing one)
- Enable the Google Sheets API
- Go to IAM & Admin β Service Accounts β Create service account
- Download the JSON key file and rename it
google-sheets-credentials.json
Open the spreadsheet β Share β add the service account email (found inside the JSON file, e.g. name@project.iam.gserviceaccount.com) with Editor access.
Hostel-backend-main/src/main/resources/google-sheets-credentials.json
cd Hostel-backend-mainUpdate src/main/resources/application.properties with your spreadsheet ID:
google.sheets.spreadsheet.id=YOUR_SPREADSHEET_ID_HERE
google.sheets.service.account.email=your-service-account@project.iam.gserviceaccount.com
google.sheets.project.id=your-gcp-project-idBuild and run:
./mvnw clean install
./mvnw spring-boot:runThe API will be available at http://localhost:8080.
On first startup, the app auto-creates header rows in each sheet if they are empty.
cd Hostel-frontend-main
npm installOptionally create a .env.local if the backend runs on a different host/port:
NEXT_PUBLIC_API_URL=http://localhost:8080Start the backend first, then the frontend in a separate terminal:
# Terminal 1 β Backend
cd Hostel-backend-main
./mvnw spring-boot:run
# Terminal 2 β Frontend
cd Hostel-frontend-main
npm run devVisit http://localhost:3000.
Base URL: http://localhost:8080
All controllers use @CrossOrigin(origins = "*").
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/students |
Get all students |
| GET | /api/students/{id} |
Get student by ID |
| POST | /api/students |
Create new student |
| PUT | /api/students/{id} |
Update student |
| DELETE | /api/students/{id} |
Delete student |
| GET | /api/students/room/{room} |
Get students by room |
| GET | /api/students/block/{block} |
Get students by block |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/rooms |
Get all rooms |
| GET | /api/rooms/{id} |
Get room by ID |
| POST | /api/rooms |
Create new room |
| PUT | /api/rooms/{id} |
Update room |
| DELETE | /api/rooms/{id} |
Delete room |
| GET | /api/rooms/block/{block} |
Get rooms by block |
| GET | /api/rooms/status/{status} |
Get rooms by status |
| GET | /api/rooms/available |
Get all available rooms |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/attendance |
Get all attendance records |
| GET | /api/attendance/{id} |
Get record by ID |
| GET | /api/attendance/date?date=YYYY-MM-DD |
Get attendance for a specific date |
| POST | /api/attendance |
Save attendance for a date |
| GET | /api/attendance/student/{studentId} |
Get attendance by student |
| GET | /api/attendance/range?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD |
Get attendance by date range |
| DELETE | /api/attendance/{id} |
Delete an attendance record |
POST /api/attendance request body:
{
"date": "2024-08-15",
"attendance": {
"ST001": true,
"ST002": false,
"ST003": true
}
}| Field | Type | Description |
|---|---|---|
id |
String | Unique student ID (e.g. ST001) |
name |
String | Full name |
email |
String | Email address |
phone |
String | Phone number |
address |
String | Permanent address |
emergencyContact |
String | Emergency contact number |
room |
String | Assigned room (e.g. A-101) |
joiningDate |
String | Date of joining (YYYY-MM-DD) |
| Field | Type | Description |
|---|---|---|
id |
String | Unique room ID |
roomNumber |
String | Room identifier (e.g. A-101) |
block |
String | Block label (A / B / C / D) |
floor |
String | Floor number |
capacity |
int | Maximum occupants |
occupants |
int | Current occupants |
status |
String | available / occupied / maintenance |
| Field | Type | Description |
|---|---|---|
id |
String | Unique record ID |
date |
String | Date (YYYY-MM-DD) |
studentId |
String | Student reference |
name |
String | Student name (denormalized) |
room |
String | Student's room at time of record |
checkInTime |
String | Check-in time or - if absent |
checkOutTime |
String | Check-out time or - if absent |
status |
String | present / absent |
The application auto-initializes headers on first run:
Students sheet
| ID | Name | Email | Phone | Address | Emergency Contact | Room | Joining Date |
Rooms sheet
| ID | Room Number | Block | Floor | Capacity | Occupants | Status |
Attendance sheet
| ID | Date | Student ID | Name | Room | Check In Time | Check Out Time | Status |
| Technology | Version | Role |
|---|---|---|
| Spring Boot | 3.1.0 | REST API framework |
| Java | 17 | Runtime |
| Maven | β | Build tool |
| Google Sheets API | v4-rev20220927 | Data storage layer |
| google-auth-library | 1.19.0 | Service account OAuth2 auth |
| google-api-client | 2.2.0 | HTTP client for Google APIs |
| Technology | Version | Role |
|---|---|---|
| Next.js | 15.2.4 | React framework (App Router) |
| React | 19 | UI library |
| TypeScript | 5.x | Type safety |
| Tailwind CSS | 3.x | Styling |
| shadcn/ui + Radix UI | β | Accessible component library |
| Axios | 1.9.0 | HTTP client for API calls |
| Recharts | 2.15.0 | Chart components |
| React Hook Form | 7.x | Form state management |
| Zod | 3.x | Schema validation |
| next-themes | 0.4.4 | Dark mode |