lucasmontano / magic-link Goto Github PK
View Code? Open in Web Editor NEWGenerate, send and validate a magic link.
License: MIT License
Generate, send and validate a magic link.
License: MIT License
Poetry is a dependency manager.
Poetry allows the same development environment for all developers and organizing the project on a pyproject.toml
file, following the "Python standards" PEP-517 and PEP-518.
After install Poetry you can run the following command to install all dependencies on a Python's virtual environment:
$ poetry install
To activate the virtual environment you can run:
$ poetry shell
To add a dependency you can run:
$ poetry add [PACKGE_NAME]
To add remove a dependency you can run:
$ poetry remove [PACKGE_NAME]
Python virtual environment allows with one command the use of the same interpreters and packages by all devs
As a user that has voted, I should be able to confirm my new vote.
The user will receive the magic link sent by the Confirmation Service #11 , the link is a GET request to this API.
A user can vote multiple times, but the last vote will override the previous ones. This API should write in the database the computed vote.
API Endpoint: /vote/confirmation/JWT
API Response
The API should return 200 status code if the vote is accepted and 400 if the request is invalid.
Note: we can create a separated issue to redirect the user to a cool webpage :)
As a user, I want to be able to vote in an ongoing poll.
User
A user is anyone that has access to the API and it's identified by an e-mail.
Vote Options
In a ranked poll, the user has the right to vote in multiple options. The options should be sent sorted by preference.
Example: ["my best option", "second best option", "third best option"]
Validation
The API should check if all informed options are available in the current poll.
Example:
["PHP", "JAVA", "JS"]
["VB", "PHP"]
API Request
{
"identifier": "[email protected]",
"options": ["VB", JAVA"]
}
API Response
Code: The API should return 204 status code if the vote is accepted and 400 if the request is invalid.
Body: The API should return an error message or empty body (if succeed).
Error message
{
"detail": {
"message": "You are trying to vote in one or more invalid options, please check the available options.",
"options": [
"VB",
"COBOL",
"Delphi"
]
}
}
Tech Implementation
The vote is added to the Redis queue and should be consumed by the Confirmation Service #11 .
For deploy project on cloud, I think could be use Heroku.
For this, could be use docker containers or Procfile to config instances of worker and web.
If chose use a Procfile, this link could help you: https://devcenter.heroku.com/articles/python-rq
As a user that sent its vote, I should be able to confirm my identification.
All votes received from #10 should be confirmed by a magic link. This service should consume the Queue as FIFO (First In First Out).
Requirements.txt is important to a contributor easily install dependencies running only pip install -r requirements.txt
instead:
$ pip install ...
...
$ pip install ...
Write the algorithm to evaluate the winner in a ranked voting.
Adding commits guideline, fastAPI introduction and project overview to the README.
i though in 2 options:
Decide which message broker we should use for queuing the votes: RabbitMQ, Redis or others?
Define which database we're going to use for storing the confirmed votes(JWT), current poll options, current poll results.
Confirmed votes payload
{
"options": ["PHP", "JAVA", "Python"],
"identifier": "[email protected]"
}
Vote stored
_id: identifier hash
vote: payload
Note: Each vote is transformed into a JWT and stored in the database.
Current Poll options
{
"options": ["PHP", "JAVA", "Python"]
}
Current Poll result
{
"result": "Python"
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.