Simple springboot API for addressBook. Supports all REST controllers and have custom error handling for every specific case, also supports redis caching.

Overview

AddressBook-SpringBoot-API

Simple Springboot API for addressBook with redis cache. Supports all REST controllers and have custom error handling for every specific case. All of the releases, remote SQL, Kafka servers and redis-server will be made unavailable as soon as this assignment passes it's final stage.

Redis cache working on remote server gif is available @ https://bit.ly/33R55W2

Kafka WEB UI available here

Updates

* 24-Jan-2022 (v0.0.4)
   - Added apache kafka for now it have both producer and consumer with 3 topics.
   - New get API that generates analytics from JSON data gather by Kafka producer (localhost:7090/api/analytics).
   - Kafka for now have 2 broker in different DC with replication factor of 2 to prevent data loss in case one Kafka broker is down.
   - As well as, 3 partitions for each topic to load balance messages between servers and have better horizontal scaling.
   	   
* 21-Jan-2022 (v0.0.3)
   - Changed default caching to redis cache.
   - On testing using remote redis server, I found 2-5ms overhead verse testing on local redis server.
   
* 20-Jan-2022 (v0.0.2)
   - Added support to get by phoneNo to method that gets record by either Id or email.
   - Changed getMapping from /api/get/ to /api/
   - Improved code to get records by id/email/phoneNo (all 3 are unique)
   - Added cache to more methods with cacheEvict key entries on save/saveAll/Update/delete.

Assumptions

  • Assumed that in an addressBook, email and PhoneNo will always be unique. And per record can have atmost 1 phoneNo and Email.
  • And that no one is using existing database with duplicate entries.
  • Any record in the database is unique for field email and phoneNo.
  • For now phoneNo field doesn't have any number validation regex, which I do plan on adding it in next update cycle. So with that said, one can input email or any other field as PhoneNo, that might contradict with findBy methods. I hope atleast until v.0.3 no one does :3

Setup

  1. Clone the application

    git clone https://github.com/ShirishSaxena/AddressBook-SpringBoot-API.git
    cd AddressBook-SpringBoot-API
  2. Create MySQL database

    create database assign3rd
  3. Change MySQL username and password as per your MySQL installation

    • open src/main/resources/application.properties file.

    • change spring.datasource.username and spring.datasource.password properties as per your mysql installation

  4. Run the app

    You can run the spring boot app by typing the following command -

    mvn spring-boot:run

    The server will start on port 7090. And can be changed from application.properties

    You can also package the application in the form of a jar file and then run it like so -

    mvn package
    java -jar target/addressBook-0.0.3-SNAPSHOT.jar
  5. Generate Logs (Optional) pip install pyperclip

    Run sampleGenerator.py Change these variables as needed

    count = 20 # generate count no of random records
    

    It'll generate List of POST req and copy to your clipboard. Finally, paste it on POSTMAN...

Further Improvements

  • Implement findByPhoneNo to GET,PUT,DELETE req. (Added 20-Jan-22 update)
  • Improve queries to saveAll

Error codes

   GET Mapping 
	G100 : No records by id.
	G101 : No records by Email.
	G102 : No records by PhoneNo.
	G103 : No records by Name(First And/Or Last).

   POST Mapping (RequestBody validation)
	P100 : firstName is required and can not be null or empty. { "firstName" : "yourName"}
	P101 : lastName is required and can not be null or empty. { "lastName" : "yourName"}
	P102 : Email is required and can not be null or empty. { "email" : "valid@email"}
	P103 : phoneNo is required and can not be null or empty.
	P104 : address is required and can not be null or empty.

	P111 : Not a valid email.
	P112 : Duplicate email found.
	P121 : Duplicate PhoneNo found.

   PUT Mapping
	U100 : No record found to update [id/email].

   DELETE Mapping
	D100 : Parameter not in id or email.

API supports all REST mappings (GET, POST, PUT, DELETE)

All of the requests made in these screenshot are from remote database with about 200ms ping, so response is slow.

GET requests

  • Get all records saved in the addressBook.

     localhost:7090/api/getAll/
    

    image

  • Get By ID or EmailAddress or PhoneNo(all are Unique field)

     localhost:7090/api/{parameter}
    

    gif

  • Get By FirstName or LastName or both ``` localhost:7090/api/getName/{param}

     param here can be single word, that is it will find that word in both firstName and LastName.
     or it can have single space {ex. Adam Evee} then it'll find all matching records having firstName as 'Adam' and lastName as 'Evee'.
    
  • Get By Address localhost:7090/api/getAddress/{param} Finds all records matching the param in address field of database.

POST requests (with error handling)

  • Add single record

     localhost:7090/api/
     
     {
     	"firstName" : "firstName",
     	"lastName" : "lastName",
     	"email" : "valid@email",
     	"address" : "Any address???",
     	"phoneNo" : "000000000"
     }
    

    image

  • Add multiple records

     localhost:7090/api/saveAll
     [
     {
     	"firstName" : "firstName",
     	"lastName" : "lastName",
     	"email" : "valid@email",
     	"address" : "Any address???",
     	"phoneNo" : "000000000"
     },
     
     {
     	"firstName" : "firstName",
     	"lastName" : "lastName",
     	"email" : "valid@email",
     	"address" : "Any address???",
     	"phoneNo" : "000000000"
     }
     
     ]
    

    image

    Tested on same server as mysql-server

    tested on same server as mysql

DELETE requests (Support delete by either id or email)

```
localhost:7090/api/
```

image

PUT requests (need id or email to not be null)

```
localhost:7090/api/
```

image

You might also like...

🦄 开源社区系统:基于 SpringBoot + MyBatis + MySQL + Redis + Kafka + Elasticsearch + Spring Security + ... 并提供详细的开发文档和配套教程。包含帖子、评论、私信、系统通知、点赞、关注、搜索、用户设置、数据统计等模块。

🦄 开源社区系统:基于 SpringBoot + MyBatis + MySQL + Redis + Kafka + Elasticsearch + Spring Security + ... 并提供详细的开发文档和配套教程。包含帖子、评论、私信、系统通知、点赞、关注、搜索、用户设置、数据统计等模块。

Echo — 开源社区系统 项目上线到服务器之后可能会出现各种各样的 BUG,比如 Elasticsearch 服务启动失败导致搜索模块不可用,但是在本地运行是完全没问题的,所以各位小伙伴可以放心下载部署。 📚 项目简介 Echo 是一套前后端不分离的开源社区系统,基于目前主流 Java Web

Jan 7, 2023

lilishop是采用JAVA开发的B2B2C多用户商城系统/电商系统/电子商务。基于当前流行技术组合的前后端分离商城系统:后端使用 SpringBoot、MybatisPlus、SpringSecurity、redis、ES、mysql、mongodb等主流技术,前端使用vue框架iview、uniapp。支持分布式部署,分布式事务,支持docker、k8s。商城支持 PC、WAP、H5、小程序、APP等各个客户端

lilishop是采用JAVA开发的B2B2C多用户商城系统/电商系统/电子商务。基于当前流行技术组合的前后端分离商城系统:后端使用 SpringBoot、MybatisPlus、SpringSecurity、redis、ES、mysql、mongodb等主流技术,前端使用vue框架iview、uniapp。支持分布式部署,分布式事务,支持docker、k8s。商城支持 PC、WAP、H5、小程序、APP等各个客户端

Lilishop B2B2C商城系统 官方公众号 & 开源不易,如有帮助请点Star 介绍 官网:https://pickmall.cn Lilishop 是一款Java开发,基于SpringBoot研发的B2B2C多用户商城,前端使用 Vue、uniapp开发 系统全端全部代码开源 产品前后端分离

Dec 31, 2022

SpringBoot SpringSecurity Jpa mybatis-plus websocket Redis camunda Vue3 Vite ant-design VbenAdmin vxe-table bpmn.js

SpringBoot SpringSecurity Jpa mybatis-plus websocket Redis camunda Vue3 Vite ant-design VbenAdmin vxe-table bpmn.js

Dec 13, 2022

消息推送平台 - 所使用的技术栈包括:SpringBoot、SpringDataJPA、MySQL、Docker、docker-compose、Kafka、Redis、Apollo、prometheus、Grafana、GrayLog等等

消息推送平台 - 所使用的技术栈包括:SpringBoot、SpringDataJPA、MySQL、Docker、docker-compose、Kafka、Redis、Apollo、prometheus、Grafana、GrayLog等等

项目介绍 austin项目核心功能:发送消息 项目出现意义:只要公司内有发送消息的需求,都应该要有类似austin的项目,对各类消息进行统一发送处理。这有利于对功能的收拢,以及提高业务需求开发的效率 系统项目架构 austin项目核心流程:austin-api接收到发送消息请求,直接将请求进MQ。a

Dec 31, 2022

A personal blog based on Vue+SpringBoot+MySql+Redis+Shiro+JWT

A personal blog based on Vue+SpringBoot+MySql+Redis+Shiro+JWT

项目:Vue-SpringBoot-PersonalBlog 个人博客网址:http://www.huchao.vip/blogs CSDN:毛_三月 介绍 一个基于SpringBoot + Vue+MybatisPlus+Shiro+JWT+Redis开发的前后端分离博客项目,带有超级详细开发文档

Dec 20, 2022

Euphony Demo for patients and assistants in case of an emergency.

Euphony Demo for patients and assistants in case of an emergency.

sound-helper Eutophia sample project Overview sound-helper is a sample application using the euphony Acoustic Data Telecommunication Library. This app

Sep 6, 2021

Test case to check if the Log4Shell/CVE-2021-44228 hotfix will raise any unexpected exceptions

Log4Shell Hotfix Side Effect Test Case I wanted to know if any ClassNotFoundException or similar unexpected exception is raised when one applies the C

Nov 9, 2022

Auto-Unit-Test-Case-Generator automatically generates high-level code-coverage JUnit test suites for Java, widely used within the ANT Group.

中文README传送门 What is Auto-Unit-Test-Case-Generator Auto-Unit-Test-Case-Generator generates JUnit test suites for Java class just as its name. During te

Dec 22, 2022

A springboot starter for retrofit, and supports many functional feature enhancements, greatly simplifying development

A springboot starter for retrofit, and supports many functional feature enhancements, greatly simplifying development

retrofit-spring-boot-starter English Document Retrofit是适用于Android和Java且类型安全的HTTP客户端,其最大的特性的是支持通过接口的方式发起HTTP请求。而spring-boot是使用最广泛的Java开发框架,但是Retrofit官方

Jan 5, 2023
Releases(v0.0.4)
Owner
Shirish Saxena
Shirish Saxena
By this package we can get sim info, call logs and sms logs.Also we can find for specific sim info and call logs as well.

sim_sms_call_info A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package

 Hasib Akon 3 Sep 17, 2022
SpringBoot show case application for reactive-pulsar library (Reactive Streams adapter for Apache Pulsar Java Client)

Reactive Pulsar Client show case application Prerequisites Cloning reactive-pulsar Running this application requires cloning https://github.com/lhotar

Lari Hotari 9 Nov 10, 2022
Spring-boot application using redis as a caching database

Java Spring-boot application using Redis as a caching database Running Application Entities involved Two main entities are involved MasterHouse (maste

null 18 Aug 9, 2022
Welcome to the EHS robotics club's GitHub repository, this will also be used as our primary community center and means of communication. Also be sure to join our remind for on the go updates @EHSFTC21

NOTICE This repository contains the public FTC SDK for the Ultimate Goal (2020-2021) competition season. Formerly this software project was hosted her

null 5 Feb 25, 2022
Hi, Spring fans! We're going to learn how to build Kubernetes operators, CRDs, and controllers

Bootiful Kubernetes Operators Make sure youre in the default namespace of a Kubernetes cluster. Not sure fi this matters but I am, so it might help. T

Josh Long 14 Dec 29, 2022
hibernate redis 二级缓存使用 spring boot redis 配置

hibernate-redisson-spring-boot-starter 介绍 使用 Redisson 作为 hibernate redis 二级缓存提供器,redisson-hibernate-53(hibernate-version) 无法使用 spring boot 配置文件创建的 org

null 4 Jul 3, 2022
Jornada Big Tech: I will have 3 months to study and prepare myself for the Big Tech interviews. Repository containing all my study material.

Jornada Big Tech (Big Tech Journey) Jornada Big Tech: I will have 3 months to study and prepare myself for the Big Tech interviews. Repository contain

Camila Maia 87 Dec 8, 2022
A distributed lock that supports the use of Redis and Zookeeper, out of the box, fast and easy to use

lock-spring-boot-starter A distributed lock that supports the use of Redis and Zookeeper, out of the box, fast and easy to use 一款基于 Redis 和 Zookeeper

Pear Stack 9 Oct 15, 2022
backend for a sharing app using SpringBoot, Redis, MySQL, and AWS S3.

moments_v2_backend (Work In Progress) backend for a sharing app using SpringBoot, Redis, MySQL, and AWS S3. This is the second version of my project S

Haiming Sun 53 Dec 26, 2022
A high availability shopping(ecommerce) system using SpringBoot, Spring Cloud, Eureka Server, Spring Cloud Gateway, resillience4j, Kafka, Redis and MySQL.

High-availability-shopping-system A high availability shopping(ecommerce) system using SpringBoot, Spring Cloud, Eureka Server, Spring Cloud Gateway,

LeiH 1 Oct 26, 2022