Giter Club home page Giter Club logo

jbproject2's Introduction

John Bryce Coupon Project

About

This is the backend code of the final project in the John Bryce Fullstack Java course. The Coupon Project is a RESTful coupon management CRUD application written with Spring Boot that has three possible end-users: an admin user for managing companies and customers, a company user for managing coupons and finally a customer user for purchasing coupons. While this repository contains the frontend static files required for a complete run, in order to view the Angular frontend source code please refer to the JBProject Angular repository.

Technologies

The Coupon Project uses Java 1.8 for access to modern features while maintaining some backwards compatibility and Spring Boot for quick and easy implementation of dependencies. Dependencies include JPA with Hibernate ORM to define and manage database interactions and Spring-Web for RESTful MVC conventions. The database of choice is MySQL for convenient development testing with the Workbench application.

Installation and Launch

To launch this application on your machine make sure you have installed:

  • JDK 13
  • MySQL 8 (Note: backwards compatibility not tested against newer versions)

Other dependencies should install automatically from pom.xml instructions in most IDEs. Alternatively you may search for- and install them manually from MVNRepository.

Next, go to src/main/resources/application.properties and change spring.datasource.username= and spring.datasource.password= to the username and password of your MySQL server. Optionally you may also wish to change the DB name by replacing spring.datasource.url= to jdbc:mysql://localhost:3306/+YourDBNameHere+?serverTimezone=UTC&createDatabaseIfNotExist=true.

Finally, simply run the file src/main/java/com.example/JBPRojest2/JbProject2Application.java and navigate to localhost:8080 in your browser. Optionally, you may un-comment the first try-catch statement before the first run to fill the database with randomly generated data.

Overview

Models\Beans

The primary beans (models) are:

  • Company - with a OneToMany relationship to coupons it created.
  • Coupon - with a ManyToMany relationship to customers who purchased it.
  • Customer - with a ManyToMany relationship to coupons they purchased (mapped by Coupon).
  • CategoryType - an Enum containing coupon categories.

The Coupon-Customer relationship is defined in the Coupon bean for convenience in CRUD operations, namely deletes.

The Admin user is hard coded with no DB representation.

Important!

As of Spring Boot 2.2.5 the Session bean is required for the proper functionality of the token-sessions system. Attempting to bypass this bean by working directly with a fresh HashMap will result in a bug that fills the HashMap with junk data and breaks functionality. This bean also holds a lastActive property used in the frontend to log out inactive users.

Facades

The ClientFacade is an empty facade for all other facades to extend for polymorphism. The GenericFacade contains methods that should be available for all client types, including anonymous users (not logged in). Other facades behave as expected, defining available methods for each client type.

Controllers

MvcConfiguration is a resource handler that directs Spring to correctly prioritize the Angular routing system over its internal mappings. WebConfig creates an injectable sessions bean for user sessions storage.

Login Manager

The login manager directory contains the actual LoginManager which, as the name suggests, contains the login method called by user facades, as well as a ClientType enum for use in said function. Additionally, it is also home to the CouponExpirationDailyJob, a threaded script that checks for expired coupons once per day, or at termination, and clears them from the database.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.