Sends notifications to users at their specified time through email, by filtering out previously notified challenges and filtering in by specified tags(Ex: NodeJs, Java) from TopCoder RSS Feed.
TRY IT OUT https://custom-built.dev/app/tpcn
Framework: Spring Boot.
Databse: MongoDB.
- On app start up, a notification task is scheduled at a fixed rate, set through
schedule_rate
property. - This will at each invocation divides the
schedule_rate
into equal sections, set throughschedule_sections
property. - For each section it schedules an task using
java.util.concurrent.ScheduledExecutorService
. - These tasks wake up at their intervals and fetch all users scheduled in this interval from the database and send notifications to them through their emails.
- The variance between user scheduled time and actual notification time can be tuned by adjusting
schedule_sections
property. - For example: If a variance of +/- 10 min is acceptable, then you can set
schedule_rate
as 1800000(30 min in ms) andschedule_sections
as 3. schedule_sections
property should be inline withtask_scheduler
max pool size in AppConfig.
- This app uses JWT access tokens to identify users between requests, signed using SHA256withECDSA.
- Implementation of JWT access token authentication is based on RFC7519.
- App has admin endpoint which can be accessed by admin users to get error log and summary of successful/un-successful messages.
- When exceptions are raised in the app, they are gracefully handled and details are asynchronously logged in db.
- Install and start mongodb, and update
db.host
anddb.port
properties inapplication.properties
file. - Create 256 bit EC key and store it in JKS format.
$ keytool -genkeypair -keyalg EC -keysize 256 -sigalg SHA256withECDSA -storetype JKS -keystore test.jks -alias test
- Update keystore alias, file and password in
JKS_KEYSTORE_ALIAS
,JKS_KEYSTORE_FILE
andJKS_KEYSTORE_PASSWORD
properties inapplication.properties
file or as ENV variables. - App uses Gmail STMP server to send mail, please provide Gmail credentials as
APP_SENDER_MAIL
andAPP_SENDER_MAIL_PASSWORD
ENV variables. - Update
schedule_rate
in milliseconds andschedule_sections
properties inapplication.properties
to your choice. - Set the app log level by
logging.level.com.app
property. - Run the db init scripts in build-scripts/mongodb folder
$ cd build-scripts/mongodb
$ mongo db-colls-test-init.js
$ mongo db-colls-init.js
- db-colls-test-init.js creates collections for unit test cases.
- Build the app using
mvn install
command and run the jar file by providingLOG_HOME
system property to store logs or run by AppRunner main method from your IDE. - To run as docker container
cd
into build-scripts/server paste the jar previously built into this folder and from build folder run build.sh by providing these three arguments:- path to store mongodb database data
- path to store logs
- app version
Example
$ ./build.sh /var/app/tpcn/db /var/app/tpcn/logs 2.3
- Import postman collection and environment in
POST_MAN
folder to check and get info about API.
- App main root package is
com.app
which containsAppRunner
which initializes the app. - Sub packages
com.app.config
for app configuration,com.app.controller
for app REST controllers,com.app.controlleradvice
for controller advices,com.app.converters
for http message converters,com.app.dao
for app data access objects,com.app.exception
for app exception classes,com.app.interceptors
for app http interceptors,com.app.model
for app models,com.app.notifier
for app user notifier,com.app.scheduler
for app scheduler,com.app.service
for app services,com.app.util
for app util classes.
- AccessTokenService creates and verifies JWT access tokens.
- StatusService contains async methods to log successful/un-successful events.
- ChallengeNotificationScheduler schedules notifications at fixed rate.
- ChallengeNotifier notifies new challenges by filtering out old challenges and filtering in by tags.
- AuthInterceptor verifies the access token of incoming requests.
- Add option to change challenge type to develop/design.
- Make build script for windows.