Skip to content

renderjaviii/u-society-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quality Gate Status Security Rating Reliability Rating Maintainability Rating

Welcome to U Society - REST Manager!

RESTful API Orchestrator created for the U Society project.

Description

This microservice has the function of the resource server, so, if it’s the head of the whole ecosystem.

Getting started

Dependencies

  • Spring boot (Open source microservice-based Java web framework)
  • Docker (Used for package the application in containers)
  • Docker compose (Tool for defining and running multi-container applications)
  • MVN (Maven manager dependency, used to build and manage the entire project)
  • MySQL (Relational database management system)
  • OAUTH2 (Open standard for access delegation)
  • JWT (Java Web Tokens, open standard for creating signed and encrypted data)
  • Spring Security (It provides the authentication and authorization mechanisms)
  • Webflux (Reactive REST client used to interconnect all the microservices ecosystem)
  • SpringDoc OpenAPI (Used for automating the generation of API documentation)
  • Spring mail (Mails support)
  • Gmail SMTP (Email provider used to send emails)
  • Apache tomcat (Web server container)
  • Jackson databind (High-performance JSON processor)
  • Apache commons lang (Reusable static utility methods)
  • JUnit + Mockito (Unit testing stuff)
  • JaCoCo (Code coverage report generator)
  • Redis (In-memory key-value data structure store)
  • Lettuce client (Fully non-blocking Redis client)
  • Slugify (Uniques identifying part address generator)

Prerequisites

Installation

  1. Clone repository:
    git clone git@github.com:renderjaviii/u-society-api.git
  2. Recreate database:
    docker-compose -f src/main/resources/docker-db.yml up --build
  3. Recreate in-memory store (cache):
    docker-compose -f src/main/resources/docker-cache.yml up --build
  4. Compile Spring project and generate deployable file:
    mvn clean install
  5. Build docker image:
    docker build -t u-society/manager .
  6. Run docker container:
    docker-compose up --build -d
  7. Additional utilities:
  • Show container logs:
     docker-compose logs -f
  • Stop container:
     docker-compose down -v
  • Run tests and check code coverage:
     mvn clean test
  • Clean Redis cache:
     docker exec company-redis redis-cli flushall

ProTips:

  • If you need to change some server configuration locally (like port), update the environment variables located in file src/main/resources/development.env.
  • When you run the database's docker container, it will be populated using the seeders files: src/main/resources/data.sql and src/main/resources/import.sql (to avoid it, remove the entry points).

Usage

Refer to the Swagger documentation: https://localhost:8443/manager/swagger-ui/index.html.

If you want to interact with the API, please download Postman (or whatever API client that you prefer), this tool will help us to consume the endpoints, e.g., when the user's bearer token is required.

Please, have in mind that a self-signed SSL certificate was configured to fit out HTTPS security communication, so, you may need to add it into the CA store (or ignore the security warning).

Application bootstrapping

There are different Spring profiles (application versions) in order to have the suitable application's behaviors.

Stage Profile Features
Development dev Development tasks: local machine's resources (complete logging)
Testing qa E2E check: cloud resources (limited logging)
Live prod Production deployment: cloud instances (optimal perfomarnce)