Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0c02dc0
CHORE[Initial django project setup]
Ayobami6 Jul 21, 2024
16b4a8e
CHORE[Add third-party dependencies to django installed apps]
Ayobami6 Jul 21, 2024
5572551
CHORE[Set up logging]
Ayobami6 Jul 21, 2024
1c1ed2e
CHORE[Set up postgres db]
Ayobami6 Jul 21, 2024
60e729f
TEST[Set pytest for testing&test get_env util method]
Ayobami6 Jul 21, 2024
f46ce71
CHORE[Add rest_framework settings&jwt settings]
Ayobami6 Jul 21, 2024
79020f3
FEAT[Add user model]
Ayobami6 Jul 21, 2024
3ea1b6c
FEAT[Implement register endpoint]
Ayobami6 Jul 21, 2024
871c11d
FEAT[Implement login feature]
Ayobami6 Jul 21, 2024
88c92e2
TEST[Add test for login and register endpoint]
Ayobami6 Jul 21, 2024
2c06b25
FEAT[Add products&category models]
Ayobami6 Jul 22, 2024
45f6827
FEAT[Implement product list endpoint]
Ayobami6 Jul 22, 2024
329e4ab
FEAT[Implement products basic crud endpoints]
Ayobami6 Jul 22, 2024
333daa0
FEAT[Add order&orderpoduct models]
Ayobami6 Jul 22, 2024
2820f5e
FEAT[Implement place order endpoint]
Ayobami6 Jul 22, 2024
ff2f5bb
FEAT[Implement order history api endpoint]
Ayobami6 Jul 22, 2024
1f48bcf
TEST[Test implemented endpoints for products]
Ayobami6 Jul 22, 2024
d17af4a
TEST[Add test for order service endpoints]
Ayobami6 Jul 22, 2024
95f1065
CHORE[Add solution setup readme]
Ayobami6 Jul 22, 2024
8b291fd
CHORE[Update solution md&update .env.sampe]
Ayobami6 Jul 22, 2024
e98f616
feat: Configure project for deployment to kubernetes cluster& docker hub
Ayobami6 Oct 18, 2024
c39cb29
Standardize application port to 80
Ayobami6 Oct 19, 2024
8b25867
Docs: Update README with deployment and setup instructions
Ayobami6 Oct 19, 2024
28d8d79
**Subject: Fix typo in README deployment section**
Ayobami6 Oct 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
7 changes: 7 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SECRET_KEY=""
DB_NAME=""
DB_HOST=""
DB_USER=""
DB_PORT=""
DB_PASSWD=""
TEST_KEY="test_value"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ coverage.xml
local_settings.py
db.sqlite3
db.sqlite3-journal
migrations/

# Flask stuff:
instance/
Expand Down
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.PHONY: run
run:
@python manage.py runserver $(port)

install:
@pip install $(package)

csu:
@python manage.py createsuperuser

mms:
@python manage.py makemigrations

migrate:
@python manage.py migrate

shell:
@python manage.py shell

dbshell:
@python manage.py dbshell

test:
@pytest

clean:
@Get-ChildItem -Path . -Recurse -Directory -Filter '__pycache__' | ForEach-Object { Remove-Item -Recurse -Force $_.FullName }



help:
@echo "Usage: make [command]"
@echo "Available commands"
@echo "run - run django server"
@echo "install - install python package"
@echo "csu - createsuperuser"
@echo "mms - makemigrations"
@echo "migrate - migrate migrations"
@echo "shell - Open shell"
@echo "dbshell - Open dbshell"
@echo "test - run test"
91 changes: 91 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

# Welcome!

Hi! this your determinant test for the position of Django backend developer at **PayBox360**. If you have any issues, you can read this docs or also contact Lolu for further clarification.


## Overview

For this exercise you will be cover some basic concepts of web development and production ready deployment and you will hence be tested in the following basic concepts.

- Django and Django query-sets
- PostgreSQL Setup and connection to Django
- Cloud deployment
- PEP guidelines, conformity and quality of code
- General understanding of the python programming language.

## Test Rundown

You will be required to fork this repository into your personal account and then carry out few operations of extending functionality of the application and then make a pull request with your branch name to the main branch as you progress.

## Test Guide

After completing stage the process in in the rundown, please create branch for your self, please make sure to name the the branch with the following convention **\<yourname>/update**, and also all commits to your branch should carry a message in the following format **\<ACTIVITY>[Activity details]**.

- A sample branch name would be **paul/update**, and.,
- A sample commit message would be **FIX[ADDED CORS CONTROL]**

## Task Description

You are required to extend a skeleton application and build it into an inventory management system to such that it can provide the abilities below:


**Project: Simple E-commerce API**

**Requirements:**
1. **User Management:**
- Implement user registration and login with JWT authentication.

2. **Product Management:**
- Create models for Product and Category.
- Implement CRUD operations for products (create, read, update, delete).

3. **Order Management:**
- Create an Order model.
- Allow users to place orders with multiple products.
- Implement a basic order history endpoint for users.

**Detailed Instructions:**

1. **Setup:**
- Create a new Django project.
- Configure the project with Django REST Framework.
- Make sure to use PostgreSQL

2. **User Authentication:**
- Use Django's built-in User model.
- Implement registration and login endpoints using JWT for authentication.

3. **Product and Category Models:**
- Create models with appropriate fields (e.g., name, description, price for Product; name for Category).
- Establish relationships (e.g., a product belongs to a category).
- Implement endpoints for managing products (list, detail, create, update, delete).

4. **Order Model:**
- Create an Order model with fields like user (ForeignKey), product (ManyToManyField), quantity, and date.
- Implement an endpoint for placing orders.
- Create an endpoint to retrieve the order history for the authenticated user.

5. **Testing:**
- Write unit tests for each endpoint.

**Evaluation Criteria:**
- Correctness: The implementation should meet the requirements.
- Code Quality: Clean, readable, and maintainable code.
- Use of Django Best Practices: Proper use of Django features and conventions.
- Testing: Quality and coverage of unit tests.

**Bonus:**
- Implement search functionality for products.
- Add pagination to product listing.


## Resources for task

**Finally**
You will be provided with a virtual machine IP address hosted on Digital Ocean please host your project appropriately using NGINX, GUNICORN and POSTGRESQL (as database). A password for the droplet will be provided.

- Please add your postman link to the above created endpoints for review.
- Also note that you can ignore the Docker and CI/CD instantiations on the application.

### Good luck, as we look forward to working with you at Liberty Assured in building amazing projects and relationships.
115 changes: 37 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,50 @@
## Minimal E-commerce Backend API Development Test Solution

# Welcome!
### Setup

Hi! this your determinant test for the position of Django backend developer at **PayBox360**. If you have any issues, you can read this docs or also contact Lolu for further clarification.
- Install dependencies
```sh
poetry install
```

- Activate poetry venv
```sh
poetry shell
```
- Set up PSQL Database configuration
```sh
cp .env.sample .env
# update the configuration details inside the .env
```
- Run makemigrations (This is because dev migrations are not being pushed to Github)
```sh
make mms
```

## Overview
- Run Migrate
```sh
make migrate
```

For this exercise you will be cover some basic concepts of web development and production ready deployment and you will hence be tested in the following basic concepts.
- Start the application
```sh
make run
```

- Django and Django query-sets
- PostgreSQL Setup and connection to Django
- Cloud deployment
- PEP guidelines, conformity and quality of code
- General understanding of the python programming language.
## Deployment
Currently the application is being deployed to AWS ECS(Elastic Container Service)

## Test Rundown
- live url at
[live](http://liberty-lb-723786584.eu-north-1.elb.amazonaws.com)

You will be required to fork this repository into your personal account and then carry out few operations of extending functionality of the application and then make a pull request with your branch name to the main branch as you progress.
- Visit Postman Documentation
[docs](https://documenter.getpostman.com/view/35174244/2sA3kVjgC9)

## Test Guide
- Run Test
```sh
make test
```

After completing stage the process in in the rundown, please create branch for your self, please make sure to name the the branch with the following convention **\<yourname>/update**, and also all commits to your branch should carry a message in the following format **\<ACTIVITY>[Activity details]**.

- A sample branch name would be **paul/update**, and.,
- A sample commit message would be **FIX[ADDED CORS CONTROL]**

## Task Description

You are required to extend a skeleton application and build it into an inventory management system to such that it can provide the abilities below:


**Project: Simple E-commerce API**

**Requirements:**
1. **User Management:**
- Implement user registration and login with JWT authentication.

2. **Product Management:**
- Create models for Product and Category.
- Implement CRUD operations for products (create, read, update, delete).

3. **Order Management:**
- Create an Order model.
- Allow users to place orders with multiple products.
- Implement a basic order history endpoint for users.

**Detailed Instructions:**

1. **Setup:**
- Create a new Django project.
- Configure the project with Django REST Framework.
- Make sure to use PostgreSQL

2. **User Authentication:**
- Use Django's built-in User model.
- Implement registration and login endpoints using JWT for authentication.

3. **Product and Category Models:**
- Create models with appropriate fields (e.g., name, description, price for Product; name for Category).
- Establish relationships (e.g., a product belongs to a category).
- Implement endpoints for managing products (list, detail, create, update, delete).

4. **Order Model:**
- Create an Order model with fields like user (ForeignKey), product (ManyToManyField), quantity, and date.
- Implement an endpoint for placing orders.
- Create an endpoint to retrieve the order history for the authenticated user.

5. **Testing:**
- Write unit tests for each endpoint.

**Evaluation Criteria:**
- Correctness: The implementation should meet the requirements.
- Code Quality: Clean, readable, and maintainable code.
- Use of Django Best Practices: Proper use of Django features and conventions.
- Testing: Quality and coverage of unit tests.

**Bonus:**
- Implement search functionality for products.
- Add pagination to product listing.


## Resources for task

**Finally**
You will be provided with a virtual machine IP address hosted on Digital Ocean please host your project appropriately using NGINX, GUNICORN and POSTGRESQL (as database). A password for the droplet will be provided.

- Please add your postman link to the above created endpoints for review.
- Also note that you can ignore the Docker and CI/CD instantiations on the application.

### Good luck, as we look forward to working with you at Liberty Assured in building amazing projects and relationships.
2 changes: 1 addition & 1 deletion app/app/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")

application = get_asgi_application()
Loading