Skip to content

REST API built using Go that performs basic CRUD with LLAMA3 and Palm2 Integration

Notifications You must be signed in to change notification settings

ashuthe1/Golang-with-Integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FealtyX - GoLang Assignment

Installation

  1. Clone the repository:

    git clone https://github.com/ashuthe1/Golang-with-Integration.git
    cd Golang-with-Integration
  2. Initialize a Go module:

    go mod init FealtyX
    go mod tidy
  3. Run the application:

    go run main.go

Project Structure

.
├── handlers
│   └── handlers.go
├── models
│   └── models.go
├── ollama
│   └── ollama.go
├── main.go
└── README.md

Features

  • CRUD Operations:

    • Create a new student
    • Get all students
    • Get a student by ID
    • Update a student by ID
    • Delete a student by ID
  • AI Integration:

    • Generate a summary of a student by ID using the LLAMA3 and Google PaLM 2 API.
  • Concurrency:

    • Ensures the API can handle concurrent requests safely.
  • Error Handling:

    • Appropriately handles errors such as invalid input data and non-existing students.
  • Input Validation:

    • Ensures input data for creating and updating students is valid.

API Endpoints

Create a New Student

  • Endpoint: POST /students
  • Description: Creates a new student.
  • Request Body:
    {
      "name": "John Doe",
      "age": 20,
      "email": "[email protected]"
    }
  • cURL Command:
    curl -X POST http:https://localhost:8080/students \
    -H "Content-Type: application/json" \
    -d '{"name": "John Doe", "age": 20, "email": "[email protected]"}'

Get All Students

  • Endpoint: GET /students
  • Description: Retrieves a list of all students.
  • cURL Command:
    curl -X GET http:https://localhost:8080/students

Get a Student by ID

  • Endpoint: GET /students/{id}
  • Description: Retrieves a student by their ID.
  • cURL Command:
    curl -X GET http:https://localhost:8080/students/1

Update a Student by ID

  • Endpoint: PUT /students/{id}
  • Description: Updates a student by their ID.
  • Request Body:
    {
      "name": "Jane Doe",
      "age": 22,
      "email": "[email protected]"
    }
  • cURL Command:
    curl -X PUT http:https://localhost:8080/students/1 \
    -H "Content-Type: application/json" \
    -d '{"name": "Jane Doe", "age": 22, "email": "[email protected]"}'

Delete a Student by ID

  • Endpoint: DELETE /students/{id}
  • Description: Deletes a student by their ID.
  • cURL Command:
    curl -X DELETE http:https://localhost:8080/students/1

Generate a Summary of a Student by ID

  • Endpoint: GET /students/{id}/summary
  • Description: Generates a summary of a student profile by ID using the Google PaLM 2 API.
  • cURL Command:
    curl -X GET http:https://localhost:8080/students/1/summary

Concurrency

The API uses a mutex (sync.Mutex) to handle concurrent requests safely. This ensures data integrity when multiple requests are made simultaneously.

Error Handling

Errors are appropriately handled, such as:

  • Returning a 400 status code for invalid input data.
  • Returning a 404 status code if a student with a specified ID does not exist.
  • Returning a 500 status code for internal server errors.

Input Validation

Input data for creating and updating students is validated to ensure it meets the required format and constraints.

About

REST API built using Go that performs basic CRUD with LLAMA3 and Palm2 Integration

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages