Skip to content

Microservice-based REST API backend for a forum application. The backend is built using Java with Spring. The application utilizes most of the current technologies used in enterprise solutions. The application is containerized using Docker and deployed using Docker Compose.

Notifications You must be signed in to change notification settings

LudwigAndreas/Forum-REST-API-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Forum REST API Backend

🚧 Project Status: In Progress 🚧

Note: This project is currently under development. Not all features have been implemented yet. Please refer to the Features section for details on what has been completed and what is still in progress.

Overview

Microservice-based REST API backend for a forum application. The backend is built using Java with Spring. The application utilizes most of the current technologies used in enterprise solutions. The application is containerized using Docker and deployed using Docker Compose.

Features

  • User authentication and authorization using Keycloak
  • Topics service implemented using Spring WebFlux
  • User service integrated with Keycloak
  • Topics service caching using Redis
  • Common Docker Compose setup
  • User service caching using Redis
  • Id Generator service for generating unique IDs for topics
  • Topics service sharding using Id Generator service
  • Gateway service using Spring Cloud Gateway
  • Monitoring using Prometheus and Grafana
  • Distributed tracing using Jaeger
  • Analytics service for tracking user activity
  • Kafka for data streaming
  • CI/CD pipeline using Jenkins
  • Deployment using Kubernetes

Table of Contents

Architecture

Diagram

Architecture Diagram

Components

  • Gateway: API Gateway using Spring Cloud Gateway.
  • Authentication: User authentication and authorization using Keycloak as SSO.
  • Users: Synchronous REST API for user management using PostgreSQL database.
  • Topics: Reactive REST API for topic management using MongoDB database and caching using Redis.
  • Id Generator: Unique ID generation using Snowflake for Topics service.
  • Monitoring: Monitoring using Prometheus and Grafana.
  • Tracing: Distributed tracing using Jaeger.
  • Analytics: Analytics service for tracking user activity.

Data Flow

  1. Gateway: Receives incoming requests and routes them to the appropriate service.
  2. Authentication: Authenticates the user and generates a JWT token.
  3. Users: Manages user data and provides user information
  4. Topics: Manages topic data and provides topic information
  5. Id Generator: Generates unique IDs for topics
  6. Monitoring: Monitors the health of the services
  7. Tracing: Traces the requests between services
  8. Analytics: Tracks user activity

Getting Started

Prerequisites

  • Docker: Containerization
  • Docker Compose: Deployment

Installation

  1. Clone the repository

    git clone https://github.com/LudwigAndreas/Forum-REST-API-Backend.git
  2. Change directory

     cd Forum-REST-API-Backend
  3. Build the Docker images

    docker-compose build
  4. Start the services

     docker-compose up

Services

Keycloak

Keycloak is used as the SSO for user authentication and authorization. The service is responsible for generating JWT tokens for authenticated users. Keycloak is pre-configured with the following admin credentials:

Username: admin
Password: admin

Keycloak can be accessed at http://localhost:8080.

Users

User service is a synchronous REST API for user management. It implements CRUD operations for user data. The service uses a PostgreSQL database for storing user data. Service integrated with Keycloak: when a user is created, a new user is also created in Keycloak.

User service can be accessed at http://localhost:8081.

Topics

Topic service is a reactive REST API for topic management. It implements CRUD operations for topic data. Reactive stack based on Spring WebFlux. The service uses a MongoDB database for storing topic data. The service also uses Redis for caching topic data. The service also uses an Id Generator service for generating unique IDs for topics (it used for sharding).

Topic service can be accessed at http://localhost:8082.

Analytics

Analytics service is responsible for tracking user activity. The service is not implemented yet. The data is fed into the service via Kafka.

Configuration

Environment Variables

The services are configured using environment variables. The environment variables are defined in the .env file.

# Keycloak
KEYCLOAK_URL=http://keycloak:8080
KEYCLOAK_REALM=forum
KEYCLOAK_CLIENT_ID=forum
KEYCLOAK_CLIENT_SECRET=secret

# Users
USERS_URL=http://users:8081

# Topics
TOPICS_URL=http://topics:8082

Deployment

Docker Compose

The application is containerized using Docker and deployed using Docker Compose. The services are defined in the docker-compose.yml file.

docker-compose up

Usage

Examples of how to use the API endpoints described in the docs directory. (Not implemented yet)

Authentication

To authenticate a user, send a POST request to the Keycloak token endpoint with the user credentials.

curl -X POST http://localhost:8080/auth/realms/forum/protocol/openid-connect/token \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'username=admin&password=admin&grant_type=password&client_id=forum&client_secret=secret'

API Requests

The services can be accessed using the following endpoints:

Documentation for the API endpoints can be found in the docs directory. (Not implemented yet)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

Microservice-based REST API backend for a forum application. The backend is built using Java with Spring. The application utilizes most of the current technologies used in enterprise solutions. The application is containerized using Docker and deployed using Docker Compose.

Topics

Resources

Stars

Watchers

Forks