- Generating & Selling Tickets
- Continuous & periodic Draws
- Tech Stack
- Features
- How to run & Install Locally
- API Reference
- Running Tests
Testing: Postman Server: Javascript, NodeJS, ExpressJS
- Postman - for testing the APIs
- VSCode - IDE
- Create lottery every 1 minute
- Assign winning ticket
- API system to call winning ticket & winning user
- Moongoose & MongoDB
- Login System
- User System
- Testing via Mocha/Jest (currently only using Postman)
Currently the system assigns a winning ticket from the start along with ticket buyers However a better system would be to allow users to purchase tickets and assign a winner after the 1 minute mark then regenerate a new lottery.
Adding in the ability to add new users as well. A Simple login system, a reward system for every lottery won.
I would rather than using a scheduler use a countdown for a time set by the lottery generation to 1.5 minutes from the time it is generated after the time runs out it outputs a winner and winning ticket. Then proceeds to make a new lottery with the same process.
Also adding a MongoDB would add a lot in terms of optimization for data storage due to its binary version of JSON. Also aids it in supporting more advanced types of data.
The flexibility & simplicity are big pros.
Since this is not a massive scale project it will not require or benefit from the use of a relational database.
Clone the project
Go to the project directory
(assuming you have downloaded it on your local computer / server)
cd my-project
Install dependencies
(make sure you have node installed on the device that will be running this project)
npm install
Start the server
npm start
(starts the backend at http://localhost:3030/)
To check or test
if the backend is running check
@ http://localhost:3030/test/
POST http://localhost:3030/api/lottery/create
GET http://localhost:3030/api/lottery/:lotteryid/remove
GET http://localhost:3030/api/lottery/list
GET http://localhost:3030/api/lottery/:lotteryid/generate
POST http://localhost:3030/api/lottery/:lotteryid/buy/:number
GET http://localhost:3030/api/lottery/:lotteryid/winner
GET http://localhost:3030/api/user/create