/articles

Simple article service that allows users to view, create, and edit articles

Primary LanguageJava

LinkedIn

Table of Contents
  1. About The Project
  2. Structure and contracts
  3. Getting Started

About The Project

The goal of this project is to demonstrate code examples and approaches to software development. The project is a simple article service that allows users to view, create, and edit articles and comments through REST requests. It also demonstrates working with a message broker (RabbitMQ), such as sending messages about new articles and comments, as well as receiving messages about user deletions.

(back to top)

Build

  1. Build: mvn clean package
  2. Then, run docker compose up and Compose will start and run entire app.

If additional configuration is required, it can be done using environment variables:

  • SERVER_ADDRESS - App service address

    example: 127.0.0.1

    default: 0.0.0.0

  • SERVER_PORT - App service port

    example: 1234

    default: 8090

  • DB_URL - JDBC connection url

    example: jdbc:postgresql://{host}:{port}/{db_name}

  • RABBITMQ_HOST - rabbitmq host address

  • RABBITMQ_PORT - rabbitmq port

  • RABBITMQ_USERNAME - rabbitmq user

  • RABBITMQ_PASSWORD - rabbitmq password

  • RABBITMQ_VHOST - rabbitmq virtual host

    default: main

  • ACCESS_TOKEN_HEADER - Authorization token header for REST requests

    example: Authorization

    default: X-Access-Token

  • INCLUDE_TRACE - Include stack traces to 5XX responses

    example: false

    default: true

(back to top)

Structure and contracts

ERD

erd

(back to top)

Swagger

swagger-ui: http://127.0.0.1:8090/

swagger-ui looks like this: swagger

(back to top)

RabbitMQ messages

  • The service produces messages in the following format:
{
  "messageId": "e730b04d-dbd6-403e-9021-de3dea75a993",
  "articleId": 3,
  "title": "New Article",
  "createdAt": "2024-07-09T20:00:00Z"
}

queue: articles

{
  "messageId": "e730b04d-dbd6-403e-9021-de3dea75a993",
  "authorId": "e730b04d-dbd6-403e-9021-de3dea75a993",
  "text": "New comment",
  "createdAt": "2024-07-09T20:00:00Z"
}

queue: comments

  • The service consumes messages in the following format:
{
  "userId": "e730b04d-dbd6-403e-9021-de3dea75a993"
}

queue: deactivated-users

(back to top)

Authorization and roles

There are 3 functional roles:

  • ROLE_ADMIN - crate and edit articles
  • ROLE_USER - crate and edit comments
  • anonymous - can only view content

(back to top)

License

This code is private and proprietary. It cannot be copied, modified, distributed, or used under any circumstances without explicit permission from the owner. Unauthorized use of this code is strictly prohibited.