loyalty-card

command module
v0.0.0-...-4eb21ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2025 License: MIT Imports: 1 Imported by: 0

README

Loyalty Card Service

Go Version Build Status Docker


Table of Contents


Overview

Loyalty Card is a modern, open-source RESTful service for managing loyalty programs, guests, scores, and tags. Built with Go, Fiber, and GORM, it offers a robust API, modular architecture, and full Docker support. Ideal for businesses, developers, and open-source contributors looking for a scalable and extensible loyalty management backend.


Demo & API Docs

  • Swagger/OpenAPI Documentation: View API Docs
  • Live Swagger UI: /api/v1/swagger/index.html (when running the service)

Features

  • RESTful API for managing guests, scores, and tags
  • Modular Go codebase with clear separation of concerns
  • CLI support via Cobra
  • OpenAPI/Swagger auto-generated documentation
  • Dockerized for easy deployment
  • Makefile for streamlined development workflows
  • Environment-based configuration
  • PostgreSQL & SQLite support via GORM
  • Extensible and open for contributions

Getting Started

Prerequisites
Quickstart (Docker Compose)
git clone https://github.com/patricksferraz/loyalty-card.git
cd loyalty-card
cp .env.example .env
# Edit .env as needed (set REST_PORT, DB_DEBUG, DSN)
docker-compose up -d
Manual Setup (Go)
git clone https://github.com/patricksferraz/loyalty-card.git
cd loyalty-card
cp .env.example .env
# Edit .env as needed
go mod tidy
go run main.go
Environment Variables

See .env.example:

  • REST_PORT - Port for REST API
  • DB_DEBUG - Enable DB debug logs
  • DSN - Database connection string

Usage

API Endpoints

All endpoints are prefixed with /api/v1.

Guests
  • POST /guests - Create a new guest
  • GET /guests/{guest_id} - Retrieve guest by ID
Scores
  • POST /scores - Create a new score
  • GET /scores/{score_id} - Retrieve score by ID
  • POST /scores/{score_id}/use - Use a score
  • POST /scores/{score_id}/tags - Add a tag to a score
Tags
  • POST /tags - Create a new tag
  • GET /tags - Search tags
  • GET /tags/{tag_id} - Retrieve tag by ID
Example: Create a Guest
curl -X POST http://localhost:<REST_PORT>/api/v1/guests \
  -H 'Content-Type: application/json' \
  -d '{"name": "John Doe", "doc": "123456789"}'
API Documentation

Development

Makefile Commands
  • make build - Build Docker image
  • make up - Start services (Docker Compose)
  • make down - Stop and remove containers
  • make logs - Tail logs
  • make gtest - Run Go tests with coverage
  • make attach - Open shell in running container
Running Tests
make gtest
Contributing

Contributions are welcome! Please open issues or submit pull requests. For major changes, open a discussion first.


Tech Stack

  • Language: Go 1.18+
  • Web Framework: Fiber
  • ORM: GORM
  • CLI: Cobra
  • API Docs: Swagger/OpenAPI
  • Containerization: Docker, Docker Compose
  • Database: PostgreSQL, SQLite

License

This project is licensed under the GNU GPLv3.


Contact & Community


Acknowledgements

Documentation

Overview

Copyright © 2022 Patrick Ferraz <patrick.ferraz@coding4u.tech>

Directories

Path Synopsis
app
domain
infra
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL