GithubHelp home page GithubHelp logo

acknowledge / bot-data-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from musibs/spring-boot-swagger-project

0.0 1.0 0.0 532 KB

Data API for chatbot - with Spring Boot, Swagger and H2

Java 100.00%

bot-data-api's Introduction

Data API

API made with Java Spring Boot to save and retrieve data from chatbot conversations.

Dependencies

  • Spring Boot Web
  • Spring Boot Data JPA
  • H2 database

The whole project is managed with Maven. With Maven you can install the dependencies, run the tests and then launch the app locally. For convenience, a standard IDE like IntelliJ allows you to do that easily.

A JAR file is generated, but no specific steps are done to deploy the project to a production environment yet.

REST Endpoints

  • POST data/{customerId}/{dialogId}: Create new dialogue entry
  • POST consents/{dialogId}: Give (or not) consent to store the dialogue
  • GET data: Get filtered and paginated data back

Swagger is used to document the API and run test requests:

Swagger interface

To manually run some test requests from the terminal, here are some examples:

  • curl -X POST localhost:8080/data/2/23 -H 'Content-type:application/json' -d '{"text":"Hey hey", "language":"EN"}'
  • curl -X POST localhost:8080/consents/6 -H 'Content-type:application/json' -d 'true'
  • curl -X GET "http://localhost:8080/data?language=EN&pageNo=0&pageSize=10"

Data storage

The API currently stores data in a local H2 relational database for ease of use. The database is cleared when the service goes down. At startup, the database is inflated with a few dummy data automatically. It is not meant to be deployed in production.

Feel free to connect to the database via the browser. Access to H2 database interface: http://localhost:8080/h2-console/

  • Credentials in local setup:
    • JDBC URL: jdbc:h2:mem:testdb
    • Password: password

H2 interface

Improvements to do

  • Keep the data in-memory while there is no consent, and only save the whole dialog when consent is given
  • Create an Enum for language to limit this field to supported languages
  • Create a "service" to export the logic currently sitting in the controller
  • Define better tests (unit tests and integration tests) and improve coverage
  • Add authentication to access the API (Basic Auth, API Key or OAuth)
  • Define deployment settings and setup a CI/CD pipeline

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.