Skip to content

bkhablenko/upday-backend

Repository files navigation

upday-backend

CircleCI

TODO: Describe implemented use cases.

How to Run

./gradlew clean build -x test && docker compose up --build

API documentation will be available at http://localhost:8090.

Sample API Requests

List all authors

curl -i http://localhost:8080/api/v1/authors

Get author by ID

curl -i http://localhost:8080/api/v1/authors/espFx31ogpynhXHNJ2TW72

List all articles

curl -i http://localhost:8080/api/v1/articles

Get article by ID

curl -i http://localhost:8080/api/v1/articles/5hAthjCg7vobqEgG6WDruY

Search articles

By author ID:

curl -i 'http://localhost:8080/api/v1/articles?authorId=espFx31ogpynhXHNJ2TW72'

By topics:

curl -i 'http://localhost:8080/api/v1/articles?tags=motorcycling'

By date range:

curl -i "http://localhost:8080/api/v1/articles?publicationDateStart=$(date +%Y-%m-%d)"

Publish a new article

curl -i http://localhost:8080/api/v1/articles \
  -H 'Authorization: Basic YWRtaW46cEA1NXcwcmQ=' \
  -H 'Content-Type: application/json' \
  --data '{
      "title": "The Motorcycle Gangs: Losers and Outsiders",
      "description": "Reflections and insights into the Hell'\''s Angels motorcycle club and their engagement in criminal activities.",
      "body": "Some fancy text goes here.",
      "tags": ["california", "criminal"],
      "authors": ["espFx31ogpynhXHNJ2TW72"]
  }'

Edit an article

curl -i http://localhost:8080/api/v1/articles/5hAthjCg7vobqEgG6WDruY \
  -X PUT \
  -H 'Authorization: Basic YWRtaW46cEA1NXcwcmQ=' \
  -H 'Content-Type: application/json' \
  --data '{
      "description": "Here goes a better description."
  }'

Remove an article

curl -i http://localhost:8080/api/v1/articles/5hAthjCg7vobqEgG6WDruY \
  -H 'Authorization: Basic YWRtaW46cEA1NXcwcmQ=' \
  -X DELETE

Notes

This project is not perfect and could be improved in certain areas.

CI

  • Build the app and run tests with Docker Compose
  • Split the pipeline into multiple jobs
  • Configure parallelism
  • Scan project dependencies for vulnerabilities

CD

  • Create a Helm chart to deploy the app in K8s

API Security

Ideally, we'd use OAuth 2 with Keycloak. Given the time constraint, however, some endpoints require Basic authentication instead.

(In-memory user credentials: admin:p@55sw0rd.)

Rate Limiting

Rate limiting is out of the scope of this project, but it's something that we'd definitely need in a production environment.

Caching

Once published, news articles rarely change. It makes sense to cache them for improved performance.

Pagination

There's none 🤷 Consider extending PagingAndSortingRepository.

Observability

Other

  • Configure DB connection pool
  • Validate @RequestBody payloads

License

This project is licensed under the terms of the MIT license. See the LICENSE file for details.

About

Simple REST API for serving news articles.

Topics

Resources

License

Stars

Watchers

Forks

Contributors