myHostel HTTP API is a dynamic and efficient hostel management system developed using the GoFr framework.
Gone are the days of signing attendance sheets and dealing with piles of paperwork. With our API, everything from checking attendance to managing hostel resources is just a click away.It is designed to modernize and simplify hostel administration by using the power of digital solutions.
- CRUD operations for student management.
- Attendance tracking for students.
- Real-time message broadcasting system using WebSockets, keeping students and staff connected and informed.
- Reduces reliance on paper, contributing to environmentally friendly practices.
/hostel-management-system
|-- /api
| |-- /students
| | |-- add_student.go
| | |-- get_students.go
| | |-- get_student.go
| | |-- update_student.go
| | |-- delete_student.go
| |-- /attendances
| |-- record_attendance.go
| |-- get_attendance.go
| |-- update_attendance.go
| |-- delete_attendance.go
|-- /models
| |-- student.go
| |-- attendance.go
| |-- message.go
|-- main.go
- Endpoint:
/student
- Method: POST
- Endpoint:
/students
- Method: GET
- Endpoint:
/student/{studentID}
- Method: GET
- Endpoint:
/student/{studentID}
- Method: PUT
- Endpoint:
/student/{studentID}
- Method: DELETE
- Endpoint:
/attendances
- Method: POST
- Endpoint:
/attendances/{studentID}
- Method: GET
- Description: Retrieve all attendance records for a specific student.
- Endpoint:
/attendances/{recordID}
- Method: PUT
- Endpoint:
/attendances/{recordID}
- Method: DELETE
-
Endpoint:
/websocket
-
Method: WebSocket Connect
-
Description: Connect to the WebSocket to engage in real-time chat. Send a JSON message with
sender
,receiver
, andcontent
fields, and the message will be broadcasted to all connected clients.Warden sending message
Student-1 receiving message
Student-2 receiving message
- Student Table:
- Attendance Table:
-
Ensure you have go installed
Go (version 1.x or higher)
-
Clone the repository using:
git clone https://github.com/aynashi/myHostel.git
-
Install GoFr Modules:
go get gofr.dev
-
Install Other Dependencies:
go mod tidy
-
You can run the mysql server and create a database locally using the following docker command:
docker run --name gofr-mysql -e MYSQL_ROOT_PASSWORD=root123 -e MYSQL_DATABASE=test_db -p 3306:3306 -d mysql:8.0.30
- Access test_db database and create table students with columns id and name
docker exec -it gofr-mysql mysql -uroot -proot123 test_db -e {sql code }
-
GoFr reads configuration via environment variables(.env) in configuration folder.
-
Run the api
go run main.go
This would start the server at 9000 port.