SMS API
The API exposes four endpoints:
a. signin [POST] - to get your jwt token
b. generate-token [GET]- to get your call limit
c. inbound/sms [POST] - to send inbound sms
d. outbound/sms [POST] - to send outbound sms.
ARCHITECTURE OVERVIEW
- domain - defining the models
- Dto - defining the data transfer objects
- redisconfig - defines configuration properties for our redis server
- repository - data access for both MySQL and redis
- security - spring security configurations
- service - business logic
- controller - routes for API calls
The application uses Bucket4j for rate limiting
DATABASE MIGRATION
The application uses liquibase for database migration. Kindly ensure queries for all schema changes are created in a file in the resource classpath and registered in the liquibase dbchangelog master.xml file.
SETUP
The application is built with Java 17, it can however be compiled with Java 8 upwards.
If you dont want to setup the code on your machine, please skip to #6
-
If you want to setup the code on your host, install JDK 8 or 17 (both are LTS Java versions).
-
Install mysql https://dev.mysql.com/doc/mysql-installation-excerpt/5.7/en/
-
Install Redis. you can get the zip archive at https://github.com/microsoftarchive/redis/releases/tag/win-3.2.100
-
Install IntelliJ IDEA or any fully-featured Java IDE of your choice.
-
Clone this repository to your IDE of choice.
-
You can run the run the build with having to setup the code yourself.
-
Just install JRE 8 or 17 on your host
-
Copy the fat jar from target/accounts-0.0.1-SNAPSHOT.jar
-
On your windows shell or mac or linux, navigate to the path you copied the jar to and execute the command "Java -jar accounts-0.0.1-SNAPSHOT.jar"
-
Try it out from the swagger at http://localhost:9999/account-mmk/swagger-ui/index.html
SAMPLE REQUEST
First, get your jwt token
http://localhost:9999/users/signin
{ "username":"azr1", "auth_id":"20S0KPNOIM" }
For everyother calls, pass the token in header as Authorization parameter. prefix with "Bearer " Token expires in 10mins. Generate another one.
http://localhost:9999/inbound/sms
{ "from":"34356765444", "to":"4924195509198", "text":"STOP" }
For outbound/sms API, you need to first call the limit throtlling endpoint first.
http://localhost:9999/outbound/sms/generate-token
Then;
http://localhost:9999/outbound/sms
{ "from":"34356765444", "to":"4924195509198", "text":"STOP" }