Skip to content

ImGajeed76/discountdb-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DiscountDB API 🚀

Backend API service for DiscountDB - the open-source coupon and discount database.

Technology Stack 💻

  • Language: Go
  • Cache: Redis
  • Database: PostgreSQL
  • API Documentation: Swagger/OpenAPI

Prerequisites

  • Go 1.21+
  • Docker and Docker Compose
  • swag (for API documentation)

Getting Started 🛠️

1. Clone the repository

git clone https://github.com/ImGajeed76/discountdb-api.git
cd discountdb-api

2. Install dependencies

go mod download

3. Set up environment variables

cp .env.example .env

Configure the following in your .env:

  • PostgreSQL connection details
  • Redis connection details

4. Generate Swagger documentation

# Install swag if you haven't already
go install github.com/swaggo/swag/cmd/swag@latest
swag init -g ./cmd/api/main.go

5. Run the API using Docker Compose

To simplify the setup of Redis and PostgreSQL, use the provided docker-compose.yml file:

  1. Start the services using Docker Compose:
docker-compose up -d

This will spin up Redis and PostgreSQL containers.

6. Run the API locally

Once Redis and PostgreSQL are running via Docker Compose, you can run the API:

go run cmd/api/main.go

Troubleshooting

  • Ensure Docker is running and the containers are healthy (docker ps to check their status).
  • If ports 5432 or 6379 are already in use, update the docker-compose.yml file to use different host ports.

Stopping the Docker Services

To stop the services:

docker-compose down

This will stop and remove the containers.

License 📜

This project is licensed under the GNU General Public License v3 (GPL-3.0). See the LICENSE file for details.

Related Projects 🔗

Contributing 🤝

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Submit a pull request

Support 💬

For questions and support:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages