Talabat Codes is a server application designed to distribute voucher codes for the Talabat food delivery service in conjunction with the purchase of event tickets.
Here's a high-level overview of how it works:
- Voucher Code Distribution: The application is an independent API that distributes voucher codes stored in a database. When the API is called, typically from an event ticketing system, it receives the email of the purchaser and the ticket number.
- Voucher Code Selection: Upon receiving a request, the application selects the first unused code from the database.
- Voucher Code Delivery: The selected voucher code is then sent to the provided email address.
- Database Update: After the voucher code is sent, the application stores the ticket number in the database alongside the corresponding code. This marks the code as used and associates it with the ticket purchase.
- Logging: The application maintains log files to track its operations and assist in troubleshooting and auditing. It logs information such as when and to whom codes are sent, and any errors that occur.
The application is built with Node.js and Express, and it uses Prisma for database management. It's designed to be deployed as a Docker container, which makes it easy to run on any platform that supports Docker.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Node.js
- Docker
- Clone the repository:
git clone https://github.com/yourusername/talabat-codes.git2. Install the dependencies:
npm install3. Copy the .env.example file to .env and fill in your environment variables.
4. Generate Prisma Client
npx prisma generate5. Build the project:
npm run buildTo start the application in development mode, run:
npm run devTo start the application in production mode, run:
npm run startThis project uses Prisma for database management.
To seed the database with voucher codes:
# Using default CSV file (./data/vouchers.csv)
npm run seed:db
# Or specify a custom CSV file
npm run seed:db ./path/to/your-codes.csvTo push the Prisma schema to the database, run:
npm run db:pushTo send coupon codes to a list of email addresses from a CSV file:
# Using default CSV file (./data/emails.csv)
npm run send:coupons
# Or specify a custom file and rate limit
npm run send:coupons ./path/to/your-emails.csv 5For more details, see Sending Coupons Documentation.
To deploy the application to a remote server, run:
npm run deployThis will build a Docker image of the application and start it on the remote server.
- Node.js
- Express
- Prisma
- SendGrid
This project is licensed under the ISC License.