Skip to content

Latest commit

 

History

History
153 lines (113 loc) · 5.86 KB

README.md

File metadata and controls

153 lines (113 loc) · 5.86 KB

Java Demo Project

This project is intended to showcase my software engineering and development skills.

It is a demo project but incorporates key software design and clean code principles.

1. Features

This project represents a backend module of a basic Store Management System (SMS), it provides APIs to:

  • Create cart with/without items.
  • Get cart details.
  • Add/remove items to/from cart.
  • Checkout cart (inc. processing applicable discount offers).

Items examples:

  • Bread - 1.20€ per Packet
  • Milk - 0.85€ per Bottle
  • Tuna - 1.65€ per Tin

Offers examples:

  • 15% discount on Bread this week
  • Buy 2 bottles of Milk and get 50% discount on Bread
  • 20% direct discount on cart

2. Demonstrated Skills

2.1. Design Patterns

Applied Design Pattern Use Case Example
Strategy Define condition/execution strategies for different types of offers Discount Strategies
Builder/Director Build cart objects Cart Builder
Factory Method Create repositories based on config properties Items Repository
Singleton Maintain unique instance of several models (using CDI @ApplicationScoped) Cart/Offer Services

2.2. Dependency Injection (DI)

2.3. Clean Code Principles

  • KISS: code is written as SIMPLE as possible.
  • DRY: code relies on re-usability and abstraction to prevent duplication.
  • YAGNI: no unnecessary functionalities are implemented (except for some cases for the sake of this demo).
  • Readability: descriptive & self-explanatory classes, methods, and variable names.
  • Convention: code follows consistent and standard naming conventions.

2.4. Code Documentation

  • Code is self-explanatory.
  • Code is documented in javadoc format.
  • Clarification comments are added when necessary.
  • Nothing is commented out!

2.5. Automated Testing

2.6. OOP & OOD Principles

  • Code is fully OOP (thanks to Java!).
  • Abstraction: code relies on abstraction to handle complexity (DI, design patterns, ...).
  • Encapsulation: code implements restricted access to data members and methods (with getters/setters when required).
  • Inheritance: classes are structured in hierarchical manner.
  • Polymorphism: ex. via strategy design pattern.

2.7. Additional Features

2.8. System Design

  • Used C4 model to design the system in multiple levels of abstraction.
  • High level diagrams can be found here.

3. Deployment

To deploy the project on your device, clone it and run the following:

Build (Maven)

To compile java files and create executable war/jar packages:

mvn clean package

Create docker network

To create docker network (first time only):

docker network create smsjavademo_net

Run docker container

To build docker image and start container:

docker-compose up --build

4. API Reference

To run APIs, simply use attached Postman collection in /docs/postman.

Ping

  GET /sms/api/engineering/ping

Create Cart

  POST /sms/api/cart
  • Body - raw (json): [... "itemIdentifier" ...]

Cart Details

  GET /sms/api/cart/{cartId}

Add Item

  POST /sms/api/cart/{cartId}/items
Parameter Type Description
itemIdentifier String Required. Item to be added

Remove Item

  DELETE /sms/api/cart/{cartId}/items/{itemIdentifier}

Cart Checkout

  GET /sms/api/cart/{cartId}/checkout

5. Screenshots

Here are some examples of APIs response:

Cart Details Response

Cart Details Response

Cart Checkout Response

Cart Checkout Response

API Error Response

API Error Response