This repository contains source code for backend server of Forty-Two e-portfolio platform. This project is built for IT Project at The University of Melbourne. Todo: WEBSITE DESCRIPTION TO BE COMPLETED
Spring Boot
v2.3.4Gradle
6.4.1Redis
6.0.9MongoDB
4.4.1RabbitMQ
3.8.9This project requires Redis, MongoDB and RabbitMQ. We've created docker-compose
configurations to simplify this process.
dev
:
prod
:
local
:
test
:
Once you've decided which environment you want to use, cd
into that directory.
The following guide uses dev
as an example. i.e. at ./docker-compose/dev/
example.env
example.env
to .env
docker-compose up
to run the application in the foregrounddocker-compose up -d
to start application in the backgroundThe server will be listening to the port assigned if you see the following output.
server_1 | 2020-10-27 14:06:30.843 INFO 1 --- [ main] t.eportfolio.server.ServerApplication : Started ServerApplication in 122.533 seconds (JVM running for 131.832)
You can use http://localhost:PORT/api/swagger-ui.html
to access API documentation.
The server read configuration such as database connection from environment variables.
docker-compose up
command in any subfolder(i.e. dev/local/prod/test) of thedocker-compose
directory
will use the .env
file inside the subfolder.--env-file
flag to specify an environment file if you don't want to use .env
The following snippet lists all environment variables used in this project with description.
You can also find this example in each subfolder with name example.env
.
# ------- Slack -------
# Spring profile
PROFILE=local
# Set slack hook url if you want watchtower to notice image update
SLACK_HOOK_URL=
# ------- Watchtower -------
# Path of docker configuration json. Set this to pull image from private docker registry.
DOCKER_CONFIG_PATH=
# ------- Server -------
# Port number the application will be listening
SERVER_PORT=8090
# ------- Redis -------
# Redis Configuration
# Redis host
SPRING_REDIS_HOST=redis
# Redis port number
SPRING_REDIS_PORT=26379
# Redis password
SPRING_REDIS_PASSWORD=
# ------- Rabbit MQ -------
# Port number of rabbitmq management port
# Access the website using http://localhost:${RABBITMQ_WEB_PORT}/
RABBITMQ_WEB_PORT=15672
# RabbitMQ host
SPRING_RABBITMQ_HOST=rabbitmq
# RabbitMQ port number
SPRING_RABBITMQ_PORT=5672
# RabbitMQ username
SPRING_RABBITMQ_USERNAME=
# RabbitMQ password
SPRING_RABBITMQ_PASSWORD=
# ------- Mongo DB -------
# specify database to use
SPRING_MONGO_DB_NAME=
# MongoDB connection string. It should start with mongodb+srv:// or mongodb://
SPRING_MONGO_CONNECTION_STRING=
# ------- Azure -------
# Azure storage account connection string
SPRING_AZURE_STORAGE_CONNECTION_STRING=
# default container name
SPRING_AZURE_STORAGE_CONTAINER_NAME=
# ------- 3rd Party API -------
# We use free images from unsplash.com to create example portfolio
# Unsplash access API key
SPRING_UNSPLASH_ACCESS_KEY=
docker-compose -f ./docker-compose/local/docker-compose.yml up -d
cp ./docker-compose/local/example.env ./docker-compose/local/.env
.env
file at ./docker-compose/local/.env
export $(cat ./docker-compose/local/.env | xargs)
to export environment variables to active shell. Alternatively, you can use EnvFile
for IntelliJ IDEA to mange environment variables../gradlew bootRun
on *unix or .\gradlew.bat bootRun
on Windows. Note that it might take a while to download dependencies.
The server will be listening on port 8090 by default.
You can use http://localhost:PORT/api/swagger-ui.html
to access API documentation.This project has implemented unit testing for API endpoints.
docker-compose -f ./docker-compose/test/docker-compose.yml up -d
cp ./docker-compose/test/example.env ./docker-compose/test/.env
export $(cat ./docker-compose/test/.env | xargs)
to export environment variables to active shell./gradlew test
on *unix or .\gradlew.bat test
on Windows. Note that it might take a while to download dependencies.The following outlines structure of the repository with description.
.
├── diagram: diagrams
├── docker-compose: docker-compose files to spin up the server in a second
│ ├── redis.conf: Redis configuration
│ ├── example.env: an empty .env file which you need to fill
│ ├── dev
│ │ └── docker-compose.yml
│ ├── local
│ │ └── docker-compose.yml
│ ├── prod
│ │ └── docker-compose.yml
│ └── test
│ └── docker-compose.yml
├── readme.md
├── server.plantuml
├── sonarqube: SonarQube configurations
│ └── sonar.properties
├── sonarqube.yml: docker-file to set up SonarQube instance
├── build.gradle
├── settings.gradle
├── gradlew
├── gradlew.bat
└── src: source code
├── main: see Spring Boot Project Structure below
The following outlines the Spring Boot Application structure. We structured the project based on a layered architecture model.
.
├── main
│ ├── java
│ │ └── tech
│ │ └── eportfolio
│ │ └── server
│ │ ├── ServerApplication.java: Entrypoint of the application
│ │ ├── common: contains code shared within the application like utility classes
│ │ ├── config: Spring Boot Configuration Classes
│ │ ├── controller: controllers
│ │ ├── dto: POJOs that carries data between the client and the server
│ │ ├── interceptor: interceptors
│ │ ├── job: Quartz jobs
│ │ ├── listener: Event listeners
│ │ ├── model: Domain models
│ │ ├── repository: Spring Data Repositories
│ │ ├── security: Spring security configuration
│ │ ├── server.plantuml: UML of the server package
│ │ └── service: Service interfaces and implementation
│ └── resources: Spring properties
│ ├── application-dev.yml: properties for development environment
│ ├── application-local.yml: properties for local environment
│ ├── application-prod.yml: properties for production environment
│ └── application-test.yml: properties for testing environment
└── test: testcases
└── java
└── tech
└── eportfolio
└── server
├── Swagger2MarkupTest.java
├── controller: controller tests
├── listener: listener tests
└── service: service tests
Thanks goes to these wonderful people (emoji key):
Yunfei Jing 💻 |
Skylar-Yang 💻 |
Zijian-Zeng 💻 |
Haswell Fan 💻 |
FishWith7sMemory 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!