5.5 KiB
Omukk Python Software Engineer Recruitment Task
Congratulations on progressing to the technical screening stage. This evaluation is designed to assess your proficiency in Python backend development with a focus on FastAPI implementation.
Task Overview:
Expected Duration: 60-80 minutes using LLMs (maximum 2 hours)
Focus Areas
- FastAPI application development
- Python best practices
- SDK integration
- Using containers
- Problem-solving methodology
- Understanding REST principle
Evaluation Criteria:
- Code structure and maintainability
- Implementation efficiency
- Debugging capability
- Adherence to REST API conventions
- Documentation clarity
Guidelines:
- You may reference documentation or LLMs as needed
- Containerization via Docker is required
- Include clear setup instructions in your submission
Introduction
Omukk is developing a social media platform. Currently, we have features for users to create/edit/delete posts and like/unlike posts. However, if you look into the API docs, you will see that the endpoints do not follow the REST principles.
After login, you can try to post something but you will see that you are not allowed to do so as you are not verified. But there is no verification process implemented. You can tinker security.py a bit to bypass this rule. Then you will see that users are allowed to post emptry strings.
As a Software Engineer at Omukk, your task is to fix all these issues and make the social media platform work as expected.
Project Setup
- Clone this repository using
git clone https://git.omukk.dev/pptx704/python-hiring-task.git. - Copy the content of
.env.exampleto.envand fill in the values.
You can then run docker compose up to start the project. The docs will be available at http://localhost:8000/docs.
Or you can run docker compose up db to start the database only and use poetry to run the backend on a non-containerized environment. In that case, you can reference the following commands-
docker compose up db -d
poetry install
poetry run alembic upgrade head
poetry run fastapi dev
Then you can access the API docs at http://localhost:8000/docs.
Tasks
Your task is to fix all these issues and make the social media platform work as expected.
Fix the endpoints
The current endpoints are not following the REST principle. For example, a user should be able to fetch all posts using GET /posts/ and get a specific post using GET /posts/{post_id}. Similarly, editing and deleting a post should be done using PUT /posts/{post_id}.
Fix all the endpoints and add a new endpoint to fetch a specific post.
To toggle like for a post, you can use POST /posts/{post_id}/like.
Fix post creation and editing
This task is fairly simple. You need to add a check so that users cannot post empty strings. Return a 400 error if the post is empty. This shall be done for both creation and editing.
Implement the verification process
For this task, you need to implement two endpoints- one for sending a verification code to the user and another for verifying the code. For simplicity, let's assume that the verification code is a 6-digit number and you can directly go to the browser to verify. So the endpoints should be POST /auth/verify and GET /auth/verify/{code}.
To implement the verification mechanism, we will use Redis to store the verification code. When an unverified user makes a request to POST /auth/verify, you should generate a 6-digit code and store it in Redis with an expiration time of 10 minutes. You do not need to send an email to the user, rather just print the code to the console or send it as the API response. Use a key verify:{user_id} for the verification code. User can send as many post requests as needed and the code will be updated every time.
User then should be able to verify the code using GET /auth/verify/{code}. If the code is valid, you should set the user's is_verified field to True and return a success message. Upon successful verification, the redis entry should be deleted.
Since, we are using Redis, you need to have a container running for this. Update the docker-compose.yml file to include a Redis container. Additionally, update the settings.py and .env.example files to include the Redis connection details.
Version Bump
When you are all done, go to main.py and bump the version to 0.1.0.
Submission
Create a repository on GitHub/Gitlab and push your changes to it. Fill in this form. Make sure that your repository is public so that we can review your changes.
Additional Notes
- The tasks are kept simple and straightforward. Do not overcomplicate them (i.e. writing tests, optimizing DB queries, implementing rate limits etc.)
- Make sure that your code is formatted properly. We have included a pre-commit hook to format the code. You can run
poetry run pre-commit installto install it. Or you can simply runisortandblackto format your code. Totally upto you. - Take advantage of LLMs for your own sake.
- All necessary dependencies are already installed for you. You can still install more if you want to. However, the
poetry.lockfile should be updated to reflect the changes (At Omukk, we use Poetry to manage dependencies. Plainrequirements.txtor other dependency managers will not be accepted) - If running your project needs some additional steps, update the
Dockerfileto reflect the changes.
Good Luck!
Note: In case you need to contact us regarding this task, please reach out to rafeed@omukk.dev via email.