/microblog-microservice-app

Backend of a microblog application with twitter-like functionality (posts, quotes, responses, customizable user profiles, likes, tags, mentions, etc.). Implemented using Spring Boot, Kubernetes, PostgreSQL, Redis.

Primary LanguageJava

Microblog app

A microblogging platform composed of multiple containerized services.

A diagram showing the architecture of the project

API

HTTP Method Endpoint Link to documentation
GET /login Docs
GET /oauth2/authorize Docs
POST /oauth2/token Docs
POST /oauth2/introspect Docs
POST /api/users/register Docs
GET /api/users Docs
GET /api/users/me Docs
PATCH /api/users/me Docs
GET /api/users/{id} Docs
GET /api/users/{id}/profile-counters Docs
GET /api/users/{id}/follow Docs
POST /api/users/{id}/follow Docs
DELETE /api/users/{id}/follow Docs
GET /api/users/{id}/followers Docs
GET /api/users/{id}/following Docs
GET /api/posts/{id} Docs
GET /api/posts/{id}/responses Docs
GET /api/posts/{id}/quotes Docs
GET /api/posts/{id}/post-counters Docs
GET /api/posts Docs
POST /api/posts Docs
POST /api/posts/{id}/responses Docs
POST /api/posts/{id}/quotes Docs
DELETE /api/posts/{id} Docs
GET /api/posts/{id}/like Docs
POST /api/posts/{id}/like Docs
DELETE /api/posts/{id}/like Docs
GET /api/feed Docs
POST /api/posts/{id}/report Docs
GET /api/tags/{name}/posts Docs
GET /api/tags/popular Docs
GET /api/notifications Docs
GET /api/notifications/unread-counter Docs
POST /api/notifications/read-all Docs
POST /api/notifications/{id}/read Docs
GET /api/reports Docs
POST /api/reports/{id} Docs

Components of the application

auth

Configures a public client which uses the Authorization Code Flow with PKCE during the process of granting access tokens to users.

gateway

API gateway of the application.

user

Implements:

  • creation of accounts for new users
  • searching for users by their username (exact or partial)
  • fetching/updating user's profile information
  • following and unfollowing users
  • sending notifications to users when they are followed
  • fetching lists of follows/followers of users
  • fetching a list of known followers (i.e. "this user is followed by these people that you follow")

post

Implements:

  • creating and deleting posts/quotes/responses
  • liking/unliking posts
  • fetching information about how many likes/responses/quotes a post has
  • tagging posts
  • sending notifications to users when they are being mentioned/quoted/responded to
  • fetching the most popular tags
  • fetching contents of tags
  • fetching post's quotes and responses
  • fetching the feed for anonymous or authenticated users
  • reporting content which violates rules

notification

Implements:

  • fetching the most recent notifications of a user
  • fetching the number of the unread notifications
  • marking a single notification as 'read'
  • marking all notifications as 'read'

report

Implements:

  • fetching reports based on their status (checked/unchecked)
  • accepting or rejecting reports (accepting a report results in the deletion of the reported post)

Initializing the development version of the application

Jenkins Credentials required to execute the entire pipeline:

Credential ID Credential Type Credential Description
dockerhub-credentials Username+Password Username and password of the user whose dockerhub repository will host the built images.
echelon133-credentials Secret Text Static token which is bound to some user who has the privileges required to manage the cluster. Static token file
user-postgres-secret Secret File .env file containing POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD for the database owned by the user service.
post-postgres-secret Secret File .env file containing POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD for the database owned by the post service.
notification-postgres-secret Secret File .env file containing POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD for the database owned by the notification service.
report-postgres-secret Secret File .env file containing POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD for the database owned by the report service.
redis-auth-secret Secret File .env file containing REQUIREPASS for the Redis auth token storage owned by the auth service.
queue-secret Secret File .env file containing REQUIREPASS for the Redis queue that is used by the services to communicate between each other.
confidential-client-secret Secret File .env file containing CLIENT_ID, CLIENT_SECRET for these services which need to use OAuth2 while sending HTTP requests to other services.

When Jenkins finishes the build successfully, these should be the expected results:

  • All services have been built
  • All services have been tested
  • *The Docker image of gateway has been built and pushed to dockerhub
  • *The Docker image of user has been built and pushed to dockerhub
  • *The Docker image of post has been built and pushed to dockerhub
  • *The Docker image of auth has been built and pushed to dockerhub
  • *The Docker image of notification has been built and pushed to dockerhub
  • *The Docker image of report has been built and pushed to dockerhub
  • Cluster's namespaces and permissions have been configured
  • Cluster's secrets required by the services have been created
  • Cluster's resources have been created/updated by applying all .yml configuration files from the k8s folder

*Step is skipped if dockerhub already hosts that version of the service