Skip to content

A Go project which manages the student of the institute or school building rest apis and scalable backend.

License

Notifications You must be signed in to change notification settings

SAHIL-Sharma21/students-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Student management

Description

This project is a RESTful API for managing student data, built using Golang and SQLite. It supports CRUD (Create, Read, Update, Delete) operations for handling student information, allowing the following functionalities:

  • Manage students with CRUD operations
  • Get list of students
  • Get student by id
  • Update student by id
  • Delete student by id

Dependencies

  • Golang: A statically typed programming language designed for building scalable and efficient applications.
  • Sqlite: A lightweight, serverless database engine stored in a single file, suitable for applications with limited data storage needs.

Configuration

  • env: Environment configuration for development and production setups.
  • storage_path: File path for SQLite database storage.
  • http_server: HTTP server configuration for setting the server’s listening address and port.

Configuration parameters are set in a YAML file (e.g., config/local.yml).

sample configuration (config/local.yml)

    env: "dev"
    storage_path: "storage/storage.db"
    http_server:
      address: "localhost:8085"

Getting started

Prerequisites

  • Go installed on the machine
  • clone the repository
  • Ensure the config/local.yml file is present in the config folder or setup correctly.

Run the following command to start the server

    go run cmd/students-management/main.go -config config/local.yml 

Output

    2024/10/27 14:17:46 INFO Server started address=localhost:8085

API Endpoints

Base URL

    http://localhost:8085/api/v1
  1. Create a new student
    POST http://localhost:8085/api/v1/students
    header: Content-Type: application/json
    body: {
        "name": "Alice Johnson",
        "age": 19,
        "email": "[email protected]",
    }

sample response:

    {
        "id": 1
    }
  1. Get list of students
    GET http://localhost:8085/api/v1/students

sample response:

[
    {
        "id": 1,
        "name": "sahil",
        "email": "[email protected]",
        "age": 24
    },
    {
        "id": 4,
        "name": "kshitij",
        "email": "[email protected]",
        "age": 26
    }
]
  1. Get student by id
    GET http://localhost:8085/api/v1/students/4

sample response:

{
    "id": 4,
    "name": "kshitij",
    "email": "[email protected]",
    "age": 26
}
  1. Update student by id
    PATCH http://localhost:8085/api/v1/students/4
    header: Content-Type: application/json
    body: {
        "name": "kshitij",  # update name
        "email": "[email protected]",  # update email
        "age": 26  # update age
    }

sample response:

{
    "id": 4,
    "name": "kshitij",
    "email": "[email protected]",
    "age": 26
}
  1. Delete student by id
    DELETE http://localhost:8085/api/v1/students/4

sample response:

{
    "message": "Student deleted successfully."
}

Testing with postman

To facilitate API testing, you can import these request examples into Postman:

  • Open Postman and create a new collection.
  • Add requests for each endpoint, copying the details from the examples above.
  • Run the requests individually or as a collection to interact with the API.

About

A Go project which manages the student of the institute or school building rest apis and scalable backend.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages