Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Backend Technical Test

This repository contains a technical test for a senior backend Django position.

Important

Please, check NOTES

Project Structure

your-tech-test-repo/

├── backend/ # Contains the Django project

│ ├── backend/

│ ├── cards/ # Contains the card model and views

│ ├── users/ # Contains the user model

│ ├── providers/ # Contains the provider client

│ ├── manage.py

│ └── requirements.txt

├── Dockerfile # Defines the Django application image

├── docker-compose.yml # Orchestrates the Django app and PostgreSQL database

├── .env # Environment variables for database (optional, but recommended)

└── README.md # These instructions

Prerequisites

To run this test, you need to have Docker Desktop installed and running on your machine.

Setup Instructions

  1. unzip the code:
unzip test_senior_backend.zip
cd test_senior_backend   
  1. (Optional but Recommended) Create a .env file:
    If you don't already have one, create a file named .env in the root of this repository (next to docker-compose.yml). You can use the following default values, or change them if you prefer:
DB_NAME=mydjangodb  
DB_USER=user  
DB_PASSWORD=password  
  1. Build and run the Docker containers:
    This command will build the Docker images (if not already built) and start the Django application (web service) and PostgreSQL database (db service) in detached mode (meaning they run in the background).
docker compose build  
docker compose up -d  
  1. Run database migrations:
    Once the containers are running, you need to apply the database migrations.
docker compose exec web python manage.py migrate  
  • docker compose exec web: Executes a command inside the web container.
  • python manage.py migrate: Standard Django migration command.
  1. Create a superuser (optional, for accessing Django Admin):
    If your task requires interacting with the Django admin, you might want to create a superuser.
docker compose exec web python manage.py createsuperuser  

Follow the prompts to set up a username, email, and password.

  1. Access the application:
    Run the following command to start the Django development server:
docker compose exec web python manage.py runserver  

The Django application should now be running and accessible in your web browser at:
http://localhost:8000

If you created a superuser, the Django admin will be at http://localhost:8000/admin/.

  1. Run tests:
    You can run the Django test suite with the following command:
docker compose exec web python manage.py test  

Shutting Down

When you are finished, you can stop and remove the containers:

docker compose down  
  

-   docker compose down: Stops the running containers and removes them, along with their networks. It does not remove the named volumes (like db_data), so your database data will persist. If you want to remove volumes too, add -v or --volumes.

The Task

Implement the functionality to create a debit card. The scenario is the following:

  • Suppose the user has been already created
  • The user makes a request to create a debit card selecting only the card color.
  • The backend calls an external provider (already mocked) to create the debit card in the provider system.
  • The backend creates the debit card in the database.
  • The backend returns the debit card to the client.

Your solution should demonstrate a very strong understanding of:

  1. Clean Architecture / Domain Separation: Structure this code into logical layers.
  2. Robust Error Handling: Handle various failure scenarios, especially those originating from the external provider.
  3. Data Consistency: Ensure that the database state remains consistent even if the external provider call fails or vice-versa.
  4. Testability: Test your implementation using unit tests.

Submission

Please push your solution to a new private GitHub repository or a compressed folder and share it with us. Include any relevant notes or assumptions in your README.md or a separate NOTES.md file.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages