Code Monkey home page Code Monkey logo

madi-api's Introduction

Madi API

Madi API is a RESTful API built with Go, NestJS, and MongoDB. The API is designed to support the Madi mobile application, which is built with Ionic. The project is open source and hosted on GitHub.

The goal of Madi API is to improve daily lives by providing useful services and easy-to-use interfaces.

The following table lists the available services and their corresponding endpoints:

Services Method Endpoint Description
Authentication POST auth/signup-with-email Register using an email address
Authentication POST auth/signin-with-social Sign in and register with a social account
Authentication GET auth/signin-with-email Sign in using an email address
Authentication POST auth/register-token Register for FCM messaging
Authentication POST auth/unregister-token Unregister for FCM messaging
User GET user/:userId Retrieve a user's information
User GET user/my-car Retrieve the user's car information
User POST user/car Add a car (e.g. MG)
User PUT user/car Edit a car (e.g. only have the key)
Insurance GET insure/search/:carNo Search for a specific car
Notification GET notification/list Retrieve notifications

Getting Started

These instructions will help you get a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Go version 1.15+
  • Node.js version 14+
  • MongoDB version 4.4+

Installation

  1. Clone the repository to your local machine
git clone https://github.com/nuza555xx/madi-api.git 
  1. Change into the project directory
cd madi-api 
  1. Install the dependencies
go get -d -v ./... 
npm install 
  1. Start the MongoDB server mongod

  2. Build and run the API

cd authentication
go build .

cd user
npm run build

  1. The API should now be running on http://localhost:3000

Project Structure

The project is separated into two main directories:

  • authentication: This folder contains the Go code for handling user authentication and authorization.
  • user: This folder contains the NestJS code for handling user management (CRUD operations)

Built With

  • Go - The programming language used
  • NestJS - A progressive Node.js framework for building efficient and scalable server-side applications
  • Ionic - A popular open-source framework for building cross-platform mobile applications
  • MongoDB - A NoSQL document-based database

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us. Versioning We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Nuza - Initial work - nuza555xx See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

ER Diagram

erDiagram
    Account }|..|{ Car : has
    Account }|..|{ Device : has
    Account }|..|{ Notification : has
    Car }|..|{ InsuranceProvider : has
    Account {
        OID id
        string phone
        string email
        string password
        string displayName
        object setting
        object geolocation
        date createdAt
        date updatedAt
    }

    Device {
        OID id
        OID userId
        string deviceName
        string deviceUUID
        string firebaseToken
        date createdAt
        date updatedAt
    }

    Car {
        OID id
        OID userId
        OID insureId
        string brandName
        string genNo
        string carNo
        number expiredYear
        string insureRangeAmount
        date createdAt
        date updatedAt
    }

    Notification {
        OID id
        OID userId
        string title
        string message
        boolean read
        date readAt
        object ref
        date createdAt
        date updatedAt
    }

    InsuranceProvider {
        OID id 
        string name
        string phone
        string address
        date createdAt
        date updatedAt
    }

Loading

Sequence Diagram

sequenceDiagram
    Client->>+Rest: [POST] auth/signup-with-email
    Rest->>+DB: create user
    DB-->>-Rest: return user
    Rest-->>-Client: response accessToken
    
    Client->>+Rest: [POST] auth/signin-with-social
    Rest->>+DB: create user + query user
    DB-->>-Rest: return user
    Rest-->>-Client: response accessToken

    Client->>+Rest: [POST] auth/signin-with-email
    Rest->>+DB: query user
    DB-->>-Rest: return user
    Rest-->>-Client: response accessToken
    
    Client->>+Rest: [POST] auth/register-token
    Rest->>-DB: update user

    Client->>+Rest: [POST] auth/unregister-token
    Rest->>-DB: update user

    Client->>+Rest: [GET] user/userId
    Rest->>+DB: query user
    DB-->>-Rest: return user
    Rest-->>-Client: response user

    Client->>+Rest: [GET] user/my-car
    Rest->>+DB: query car
    DB-->>-Rest: return car
    Rest-->>-Client: response car[]

    Client->>+Rest: [POST] insure/car
    Rest->>+DB: create car
    DB-->>-Rest: return car
    Rest-->>-Client: response car

    Client->>+Rest: [PUT] insure/car
    Rest->>+DB: update car
    DB-->>-Rest: return car
    Rest-->>-Client: response car

    Client->>+Rest: [PUT] insure/search/carNo
    Rest->>+DB: query car
    DB-->>-Rest: return car
    Rest-->>-Client: response car

Loading

madi-api's People

Contributors

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