This application is the final project I created during my software studies.
The application is a Fullstack project, it is written in Java language on the server side and in React on the client side.
This is a coupon management system that allows companies to generate coupons as part of advertising and marketing campaigns that they run.
The system also has registered customers, the customers can purchase coupons, coupons are limited in quantity and validity, a customer is limited to one coupon of each type.
The system records the coupons purchased by each customer.
The revenue of the system is from the purchase of coupons by the customers and by the creation of new coupons by the companies.
- Administrator - manages the system, managing the lists of companies and the customers.
- Company β managing a list of coupons associated with the company.
- Customer - who buy coupons.
Since I always had a great passion and a special connection while working on the server side, during the software studying, I decided to do the server side in 3 different ways, each of them focusing on a different technological technique.
Writing the server side in plain old Java.
For the database I used:
- SQL
- JDBC
- ConnectionPool that manage the connections queries sent to the database.
In this project I used simple login() method for authentication & authorization.
Click here to see this project on Github:
https://github.com/itsmechelly/CouponSystem_JavaProject
In the second project I rewrite the core system for more recent technology - I used Java language and Spring Framework.
For the database I used:
- Spring Hibernate JPA.
For the authentication & authorization I used the Sessions technique.
Click here to see this project on Github:
https://github.com/itsmechelly/CouponSystem_SpringProject_SessionTechnique
In the second project I rewrite the core system for more recent technology - I used Java language and Spring Framework.
For the database I used:
- Spring Hibernate JPA.
For the authentication & authorization I used the JTW technique.
π The current repo represent this 3rd project.
https://github.com/itsmechelly/coupon-system-server
π NOTE: this project is the final version and deployed to AWS cloud, click to browse the website:
CLICK HERE TO SEE THE WEBSITE!
π To login, use those details:
Admin: β‘οΈ e-mail: admin@admin.com password: admin
Company: β‘οΈ e-mail: zootAllures@company.com password: zootAllures
Customer: β‘οΈ e-mail: cust1@cust.com password: 1111
This part of the application was written using React libraries and is built as a Single Page Application (SPA).
The communication between server side and client side was done using Json and RESTful API.
Click here to see this project on Github:
https://github.com/itsmechelly/coupon-system-client
π NOTE: this project is the final version and deployed to AWS cloud, click to browse the website:
CLICK HERE TO SEE THE WEBSITE!
π To login, use those details:
Admin: β‘οΈ e-mail: admin@admin.com password: admin
Company: β‘οΈ e-mail: zootAllures@company.com password: zootAllures
Customer: β‘οΈ e-mail: cust1@cust.com password: 1111
Java Beans are pure information classes that represent the information managed by the application.
Below is the diagram of the Java Beans classes:
As we will see below, this project implements an MVC architecture.
After the user performs a request on the client side, the first layer that is activated on the server side is the controller layer.
The first controller the client encounters is the login controller.
Login Controller calls to Login Service.
The login service contains a method that checks the type of the client, then, according to the client type, generates a new Token that will be valid for 30 minutes.
This token addresses the specific service type of the client.
And then this service returns the generated token to the controller and inserts it into a new HttpHeaders object.
Then, whenever a request comes from the client endpoint, the HttpHeader requests this token. In each such request - the system will check whether the token transferred in the header is indeed compatible with the real token.
For securely transmitting the login information I used JSON Web Token (JWT) library (SignatureAlgorithm.HS256).
The token is automatically updated every 30 minutes.
This is how it looks in macro view:
Diagram of login class in details:
According to the client type, and after the client's first request has been made - the login, and after the client has a token that is activated behind the scenes - now, with every request the client sends - the relevant controller will be activated (as mentioned, the token and the client type are stored in the HttpHeader).
The request is passed to the Service Layer into the specific method, which in turn checks whether the token is valid.
The service layer contains an operates the business logic and then passes the request to another layer I created - Impl Layer (I created this layer to create separation in access to the Repository layer - this creates extra protection).
And finally - there is a repository Layer that is managed by Spring Hibernate JPA and it is the one that adds, updates, deletes, and manages the information stored in the database.
A Facade Design Pattern is used here.
Such a design allows simple operations to be outsourced, which behind the scenes use a series of extra operations.
Because there is three classes need to use the service components, each by his client type - I defined an abstract base class β ClientService that reference to the service classes (it will first login() and then direct to the relevant service layer according to the client type).
A basic infrastructure service named CouponExpirationDailyJob was established to clean the system from expired coupons.
The job is a process that runs in the background regularly and checks and cleans coupons once every 24 hours.
The job is executed using a Spring Scheduling that runs parallel to the system activity.
Below is the job diagram for this job activity:
In addition to the Java exceptions, I created system-specific exceptions:
Please click the link below to browse the website:
CLICK HERE TO SEE THE WEBSITE!
π Note: to login, use those details:
Admin: β‘οΈ e-mail: admin@admin.com password: admin
Company: β‘οΈ e-mail: zootAllures@company.com password: zootAllures
Customer: β‘οΈ e-mail: cust1@cust.com password: 1111
π Note: to enter those routes you should first login, you can use those details: e-mail: admin@admin.com password: admin
admin/addCompany
admin/addCompany
/admin/updateCompany
/admin/deleteCompany/{companyId}
/admin/getOneCompanyById/{companyId}
/admin/getAllCompanies
/admin/addCustomer
/admin/updateCustomer
/admin/deleteCustomer/{customerId}
/admin/getOneCustomerById/{customerId}
/admin/getAllCustomers
π Note: to enter those routes you should first login, you can use those details: e-mail: zootAllures@company.com password: zootAllures
/company/addCompanyCoupon
/company/updateCompanyCoupon
/company/deleteCompanyCoupon
/company/getAllCompaniesCoupons
/company/getAllCouponsByCategory/{couponCategory}
/company/getAllCouponsUnderMaxPrice
/company/getCompanyDetails
π Note: to enter those routes you should first login, you can use those details: e-mail: cust1@cust.com password: 1111
/customer/purchaseCoupon
/customer/getAllCustomerCoupons
/customer/getAllCouponsByCategory/{couponCategory}
/customer/getAllCouponsUnderMaxPrice
/customer/getCustomerDetails
Language & Framework: Java Language, Spring Framework
Database: Spring Hibernate, Spring JPA (MySQL Driver), SQL, MySQL
Authentication & Authorization: JSON Web Token (JWT) library
Scheduling Mechanisms: Spring Scheduling
Architecture & Design Patterns: Spring MVC Layers, Singleton Pattern, Facade Pattern, Factory Pattern
Communication between Client side and Server side: Restful API
Client-Side: React, JavaScript, Typescript, Bootstrap 5, HTML, CSS
Thanks for reading,
Chelly π©π»βπ»