Skip to content

Marko19907/urban-infusion-server

Repository files navigation

Urban Infusion server, group 7

This repository contains the backend made for the Urban Infusion project from NTNU's Application Development (IDATA2306) subject. The project counts towards 100% of the final grade in the subject.

The front-end part can be found here: https://github.com/Marko19907/urban-infusion-website

Java CI with Maven

Built With

  • Kotlin - A modern, cross-platform, statically typed, general-purpose programming language.
  • Spring Boot - Server framework used to build the REST API.
  • Docker - Used to containerize the app.
  • MySQL - For the persistent database.
  • Apache Derby - Used for the embedded database.
  • HTTPS - Used for communications security in production.
  • JWT - As the authentication mechanism.

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

This is a list of things you need in order to use this application.

  • IntelliJ IDEA 2022.1.0 or newer, necessary as Kotlin is bundled in the IDE, not needed if building directly with Maven
  • JDK 17 or newer, always needed
  • Docker is not needed
  • A database installation is not needed, the server can run in embedded mode with the Apache Derby database

Downloading the project

Via HTTPS:

git clone https://github.com/Marko19907/Urban-Infusion-server.git

Via SSH:

git clone [email protected]:Marko19907/Urban-Infusion-server.git

or download it directly as a zip from here.

Install methods

GitLab Releases [Recommended]

  1. Download the latest build from this repository's "Releases" page
  2. Run the downloaded .jar with the CMD using the java -jar nameOfTheJarFile.jar command.
  3. The server should then start with an embedded database and be available at http://localhost:8080
    This is the preferred method.

Other installation methods

Via IntelliJ

  1. Make sure you have installed the correct version of IntelliJ as specified in the "Prerequisites" section.
  2. Download and the extract zip-file or clone project to the desired location as specified in the "Downloading the project" section.
  3. Open the pom.xml file with IntelliJ.
  4. In IntelliJ, launch the Application class located in the no.ntnu.webdev.webproject7 package.
  5. The server should then start with an embedded database and be available at http://localhost:8080
    Options in other IDEs may vary.

Via Maven in any IDE

  1. Clone or download the repo as a zip as specified in the "Downloading the project" section.
  2. Run mvn package in the project folder with an IDE of your choice.
  3. Navigate to the /target folder and launch the generated .jar with the CMD.
  4. The server should then start with an embedded database and be available at http://localhost:8080

Project structure

webproject7
├───configs
├───controllers
├───dto
├───exceptions
├───models
├───repositories
├───security
├───serializers
├───services
└───utilities

We have tried to keep the project organized by categorizing classes into packages by their respective domains.

Configs

Contains the different configurations, for ex. cors and security configs

Controllers

Houses the controller classes that provide the REST endpoints for the app

DTO

Contains all the different DTOs (Data Transfer Objects)

Exceptions

Contains the different exceptions that are used to signal errors

Repositories

Contains the repository classes tasked with connecting to the DB

Security

The JWT implementation

Serializers

Houses the custom JSON deserializers that translate strings to enum types

Services

Contains all the service classes that house the business logic

Utilities

Contains mostly static functions that are used throughout the app

Database schema

The following is our database schema:

An image of the database schema

Project requirements

The application has two main roles:

  1. Admin
  2. User

An admin can do everything that a user can but admins can access extra functionality that is not available to users.

A user can:

  • Signup and log in
  • View products
  • Send in an order
  • Write a comment for a product
  • Edit their own comment
  • See other user's comments

An admin can:

  • Add a new product
  • Update a product
  • Delete a product
  • See all user orders
  • Mark an order as processed
  • See all user comments for each product
  • Delete any user comment

Our app currently has a predefined admin user and a regular user used under testing:

Admin:

  • username: admin
  • password: admin

User:

  • username: user
  • password: user

Note: These predefined users are only meant to be used for demo and development purposes, they should not be included in a real scenario.

Disclaimers

  • All product images used were fetched from pngegg.com and are covered by their non-commercial use only license.
  • The user images used in this project have been generated by an AI and do not depict any person currently alive or dead.