Git Product home page Git Product logo

looprassignment's Introduction

LooprAssignment

User Cart API

This project implements a user cart API with JWT-based authentication using Python and FastAPI. It allows users to register, login, and manage their shopping carts by adding, updating, and deleting products.

Features

  • User registration and login with password hashing
  • JWT-based authentication for protected routes
  • Adding, updating, and deleting products in the user's cart
  • Aggregated cart information including total price and total quantity
  • Integration with a coupon code functionality for applying discounts

Requirements

  • Python
  • FastAPI
  • Uvicorn (for running the server)
  • PyJWT
  • Passlib
  • Pydantic

Installation

  1. Clone the repository:

Replace <repository-url> with the URL of this GitHub repository.

  1. Install the required dependencies using pip:

  2. Start the server:

The server should now be running on http://localhost:8000.

API Endpoints

  • POST /users/register: Register a new user.
  • POST /users/login: Login with username and password to obtain an access token.
  • GET /users/me: Get the current user's information.
  • POST /cart/add: Add a product to the user's cart.

Note: Please refer to the code for additional API endpoints related to managing the cart.

Authentication

This API uses JWT-based authentication. To access protected routes, include the JWT access token in the Authorization header of your requests: Replace <access-token> with the access token obtained from the login endpoint.

Data Storage

  • User data is stored in a JSON file (data/users.json).
  • Product data is stored in a JSON file (data/products.json).
  • Cart data is stored in separate JSON files for each user (data/cart_<username>.json).

Contributing

Contributions to this project are welcome. Feel free to open issues and submit pull requests to suggest improvements or add new features.

License

This project is licensed under the MIT License.

looprassignment's People

Contributors

dhirajgilda 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.