A REST API in Go that performs basic CRUD (Create, Read, Update, Delete) operations on a list of students.
Utilizes Ollama with the llama3 model to generate summaries for given students.
Includes validations to ensure proper request data for the struct using middleware.
Ensures concurrency safety using RWMutex to protect shared data.
The project is designed to manage student data, providing endpoints to create, read, update, and delete student records. Additionally, it integrates with Ollama's AI model to generate concise summaries of student details, enhancing the system's functionality with intelligent data processing.
-
Clone the repository using the command:
git clone https://github.com/naresh2002/Student-Management-System.git
-
Open a terminal in the cloned directory and run:
go mod tidy
-
OPTIONAL:
To use the Get Student Summary endpoint, you need to first install: a. Ollama
b. Then install the llama3 model of Ollama using:ollama run llama3
c. Once installation is complete, open a new terminal and start Ollama using the commands:
sudo systemctl enable ollama sudo systemctl start ollama ollama serve
-
Now you are all set to test the project. Start the project using:
go run main.go
You can test the endpoints given below using either Postman or by running curl commands through the terminal.
-
Get All Students [GET]
http://127.0.0.1:8000/student/all
curl command:curl -X GET http://localhost:8000/student/all | jq
-
Get Student By ID [GET]
http://127.0.0.1:8000/student/{id}
curl command:curl -X GET http://localhost:8000/student/1 | jq
-
Create Student [POST]
http://127.0.0.1:8000/student/add
JSON input:{ "name": "ABC DEF", "age": 23, "email": "abcdef@gmail.com" }
curl command:
curl -X POST http://localhost:8000/student/add -d '{ "name": "ABC DEF", "age": 23, "email": "abcdef@gmail.com" }'
-
Update Student [PUT]
http://127.0.0.1:8000/student/update/{id}
JSON input:{ "name": "Abc Def", "age": 23, "email": "abcdef@gmail.com" }
curl command:
curl -X PUT http://localhost:8000/student/update/2 -d '{ "name": "Abc Def", "age": 23, "email": "abcdef@gmail.com" }'
-
Delete Student [DELETE]
http://127.0.0.1:8000/student/delete/{id}
curl command:curl -X DELETE http://localhost:8000/student/delete/1
-
Get Student Summary [GET]
To use the summary endpoint, make sure that llama3 model is installed as described in step 3.
http://127.0.0.1:8000/student/summary/{id}
curl command:curl -X GET http://localhost:8000/student/summary/1 | jq
If you no longer require Ollama and wish to uninstall it, follow this guide to completely remove Ollama from your system.