GithubHelp home page GithubHelp logo

bryannahabwe / backend-stage-two-task Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 247 KB

This application performs CRUD (Create, Read, Update, Delete) operations on a user domain. It provides a simple API to manage user records.

Python 100.00%

backend-stage-two-task's Introduction

HNG Backend Stage 2 Task - CRUD Application

This application performs CRUD (Create, Read, Update, Delete) operations on a user domain. It provides a simple API to manage user records.

Table of Contents

Getting Started

Use Case Diagram for API Classes

API Classes UML Diagram

This UML diagram provides an overview of the structure of our API classes and their relationships.

Entity-Relationship Diagram (ERD)

Entity-Relationship Diagram (ERD)

The ERD illustrates the database tables and their relationships in the application.

Prerequisites

Before you begin, ensure you have met the following requirements:

  • Python: You must have Python 3.7 or higher installed. If not, you can download and install Python from the Official Python website.

  • Virtual environment (optional but recommended): It's a good practice to create a virtual environment for your project. You can create one using the built-in venv

Installation

Follow these steps to set up and run the CRUD application:

  1. Clone the repository:

    git clone https://github.com/BryanNah/backend-stage-two-task
    
  2. Navigate to the project directory:

    cd backend-stage-two-task
    
  3. Create and activate a virtual environment (optional but recommended):

     python -m venv venv          # Create virtual environment
     source venv/bin/activate    # Activate virtual environment (Linux/macOS)
     venv\Scripts\activate       # Activate virtual environment (Windows)
    
  4. Install the required dependencies:

    pip install -r requirements.txt
    
  5. Start the CRUD application:

    uvicorn task.main:app --port 8000
    

The application will be accessible at http://localhost:8000.

API Endpoints

Create User

Endpoint: /api
HTTP Method: POST
Request Body: JSON
Response: JSON

Read User

Endpoint: /api/{user_id}
HTTP Method: GET
Response: JSON

Update User

Endpoint: /api/{user_id}
HTTP Method: PUT
Request Body: JSON
Response: JSON

Delete User

Endpoint: /api/{user_id}
HTTP Method: DELETE
Response: JSON

Request and Response Formats

User Creation Request:

Field: name
Type: String

User Response:

Field: id, Type: Integer
Field: name, Type: String

Sample API Usage

Here are some sample API requests and responses:

For information about the API Usage (https://hng-backend-task-tcnq.onrender.com/docs)

Create User:

  • Request
      POST http://localhost:8000/api
      Content-Type: application/json
      
      {
          "name": "John Doe"
      }
  • Response
    {
      "id": 1
      "name": "John Doe"
    }
    

Read User:

  • Request
     GET http://localhost:8000/api/1
  • Response
    {
      "name": "John Doe"
    }
    

Update User:

  • Request
      PUT http://localhost:8000/api/1
      Content-Type: application/json
      
      {
          "name": "Nahabwe Brian"
      }
  • Response
    {
      "id": 1
      "name": "Nahabwe Brian"
    }
    

Delete User:

  • Request
     DELETE http://localhost:8000/api/1
  • Response
    {
      "details": "User successfully deleted"
    }
    

Known Limitations or Assumptions Made During Development

1. The API assumes that the id field of a user is unique and auto-incrementing.
2. The API assumes that the name field of a user is a string.
3. The API does not perform any authentication or authorization.
4. The database used is SQLite which stores data in the file on local system.

backend-stage-two-task's People

Contributors

nahabwebryan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.