Giter Club home page Giter Club logo

bag-it-api's Introduction

BagIt Backend

๐Ÿ›ก๏ธ This repository houses the backend for BagIt. BagIt a mobile application that improves the grocery shopping experience, by allowing users to easily create and share shopping lists.

Architecture

The BagIt backend is shown below (highlighted in red).

Search

The backend consists of three(3) main components:

  1. User Authentication API - Users must first register and login to be able to access the SignalR Hub. Clients that are successfully authenticated receive a JSON Web Token (JWT) that can then use to access the Hub. The API is deploy on Microsoft Azure and can ge accessed here: https://bag-it-api.azurewebsites.net/api/user The endpoints for the API are as follows:

    GET

    • /api/user: Test that the user endpoint works

    POST

    • /api/user/register: Create new user

      • Body:
        • Username: String (optional): The username of the user
        • Email: String (required): The email address of the user
        • Password: String (required): The password of the user
    • /api/user/login: Sign user in

      • Body:
        • Email: String (required): The email address of the user
        • Password: String (required): The password of the user
  2. SignalR Hub - The Hub allows for real-time client-to-server (and server-to-client) communication. The former means that users receive shopping list updates in real-time. Unauthorized clients are not able to invoke Hub methods. The Hub is deploy on Microsoft Azure and can ge accessed here, assuming the valid jwt is supplied (see 3. below) : https://bag-it-api.azurewebsites.net/listHub

  3. SQLite Database - This self-contained database stores all the list information and users. See the ERD diagram below.

Search

Built With

  • .NET Maui
  • C#

Getting Started

1. Download starter and install dependencies

Clone this repository:

git clone [email protected]:jsam07/bag-it-api.git

2. Start the REST API server

dotnet run

The server is now running on https://localhost:7210. You can now make API requests, e.g. https://localhost:7210/api/user.

3. Testing SignalR Hub

Recall, you can only access the Hub by providing a valid jwt (generated after successful login). See below for an example: The jwt token can be obtained by authenticating via the api/user/login route specified above - the response shape is as follows:

{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYiLCJleHAiOjE2NDkwNjA4MzksImlzcyI6Imh0dHBzOi8vYmFnLWl0LWFwaS5henVyZXdlYnNpdGVzLm5ldCIsImF1ZCI6Imh0dHBzOi8vYmFnLWl0LWFwaS5henVyZXdlYnNpdGVzLm5ldCJ9.GscRb0fipj79Abl3aUQoT6zUpjxn6oIV0v_SI6t7RME",
    "expiration": "2022-04-04T08:27:19Z"
}

Use the test-client example project in the root directory to test Hub invocations:

let jwt = "token_here"
const connection = new signalR.HubConnectionBuilder()
    .withUrl("https://localhost:7210/listHub", { accessTokenFactory: () => jwt })
    .withAutomaticReconnect()
    .build();

Status

Search

bag-it-api's People

Contributors

jsam07 avatar matteomiceli avatar

Stargazers

Wim De Vriendt 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.