Skip to content

MukeshGKastala/simplemarketing

Repository files navigation

Simple Marketing

This project aims to enforce temporal uniqueness constraints at the API layer while ensuring data integrity for a RESTful promotions entity in a concurrent environment.


Why This Project?

The main focus of this project is to explore:

  • Conditional Uniqueness: When the uniqueness of a field (such as promotion_code) needs to be enforced conditionally, based on factors like whether a promotion is soft-deleted or has expired.
  • Use of Transactions: Ensuring the proper use of transactions to maintain data integrity in the face of concurrent operations.
  • Transaction Isolation Levels: Investigating how a database’s transaction isolation levels affect transactions when handling conflicting operations.

Design and Architecture

This service relies on a MySQL database to store promotions.

CREATE TABLE promotions (
	id INT AUTO_INCREMENT PRIMARY KEY,
	promotion_code VARCHAR(255) NOT NULL,
	start_date DATETIME NOT NULL,
	end_date DATETIME NOT NULL,
	created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
	updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
	deleted_at DATETIME DEFAULT NULL
);

API Endpoints

  • Create a promotion:
    • Create a new promotion with a unique promotion_code
  • List promotions:
    • Retrieve a list of all (non-deleted) promotions

Setup local development

Install tools

How to generate code

  • Generate server and SQL boilerplate:

    make generate

How to run

  • Run network:

    make compose
  • Run test:

    make test

About

A simple marketing service in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published