-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Horlawhumy-dev/setup
Setup Project
- Loading branch information
Showing
7 changed files
with
251 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,7 +296,7 @@ celerybeat.pid | |
.env | ||
.venv | ||
env/ | ||
venv/ | ||
venv | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
install: | ||
pip3 install -r requirements.txt | ||
|
||
runserver: | ||
python3 manage.py runserver | ||
|
||
tests: | ||
pytest | ||
|
||
makemigrations: | ||
python3 manage.py makemigrations | ||
|
||
migrate: | ||
python3 manage.py migrate | ||
|
||
createsuperuser: | ||
python3 manage.py createsuperuser [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,87 @@ | ||
# drugstoc_inventory | ||
Drugstoc BE Interview Technical Assessment | ||
# Drugstoc Inventory Management APIs Assessment | ||
|
||
A simple Django backend for a inventory mananagement that manages users, products, orders and reports. It supports basic CRUD (Create, Read, Update, Delete) operations for all services. | ||
|
||
## Features | ||
|
||
- Endpoints for managing users authentication and authorization with RBAC | ||
- Endpoints for products where only admin can make full CRUD operations | ||
- Basic error handling | ||
- Normal can create orders with list of products | ||
- Reporting endpoints for sales and products stock management | ||
|
||
## Project Structure | ||
|
||
drugstoc_inventory/ | ||
│ ├── init.py | ||
│ ├── main.py | ||
│ ├── crud/ | ||
│ │ ├── init.py | ||
│ │ ├── author.py | ||
│ │ └── post.py | ||
│ ├── models/ | ||
│ │ ├── init.py | ||
│ │ ├── author.py | ||
│ │ └── post.py | ||
│ ├── schemas/ | ||
│ │ ├── init.py | ||
│ │ ├── author.py | ||
│ │ └── post.py | ||
│ ├── db/ | ||
│ │ ├── init.py | ||
│ │ └── database.py | ||
│ └── api/ | ||
│ ├── init.py | ||
│ ├── author.py | ||
│ └── post.py | ||
└── README.md | ||
└── run_tests.sh | ||
└── requirements.txt | ||
|
||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
|
||
- Python 3.7+ install | ||
- Make install | ||
|
||
### Installation | ||
|
||
1. **Clone the repository:** | ||
|
||
```bash | ||
git clone https://github.com/Horlawhyumy-dev/drugstoc_inventory.git | ||
cd drugstoc_inventory | ||
|
||
|
||
2. **Create Virtual Environment and Install Requirements** | ||
```bash | ||
python3 -m venv env | ||
source env/bin/activate # On Windows use `env\Scripts\activate` | ||
make install | ||
``` | ||
|
||
3. **Run Migrations** | ||
```bash | ||
make migrate | ||
``` | ||
|
||
4. **Run and Excute Tests Script** | ||
|
||
``` | ||
chmod +x run_tests.sh | ||
./run_tests.sh | ||
``` | ||
|
||
5. **Start Server** | ||
|
||
```bash | ||
make runserver | ||
``` | ||
|
||
## Internal API Endpoints Documentation | ||
|
||
``` | ||
./api_doc.txt file | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
API Descriptions: | ||
|
||
This application provides a RESTful API for Drugstoc Inventory Management. | ||
|
||
Endpoints: | ||
|
||
1. POST /authors/ | ||
- Description: Create a new author | ||
- Request Body: AuthorCreate schema | ||
- Response: Author schema | ||
|
||
2. GET /authors/ | ||
- Description: Retrieve a list of authors | ||
- Query Parameters: | ||
- skip (int, optional): Number of authors to skip (default: 0) | ||
- limit (int, optional): Maximum number of authors to return (default: 10) | ||
- Response: List of Author schemas | ||
|
||
3. GET /authors/{author_id} | ||
- Description: Retrieve an author by ID | ||
- Path Parameters: | ||
- author_id (int): The ID of the author to retrieve | ||
- Response: Author schema | ||
- Exceptions: | ||
- 404 Not Found: If the author is not found | ||
|
||
4. PATCH /authors/{author_id} | ||
- Description: Update an existing author | ||
- Path Parameters: | ||
- author_id (int): The ID of the author to update | ||
- Request Body: AuthorUpdate schema | ||
- Response: Author schema | ||
- Exceptions: | ||
- 404 Not Found: If the author is not found | ||
|
||
5. DELETE /authors/{author_id} | ||
- Description: Delete an author | ||
- Path Parameters: | ||
- author_id (int): The ID of the author to delete | ||
- Response: 204 No Content | ||
- Exceptions: | ||
- 404 Not Found: If the author is not found | ||
|
||
Schemas: | ||
|
||
1. Author | ||
- Properties: | ||
- id (int): The unique identifier of the author | ||
- name (str): The name of the author | ||
|
||
2. AuthorCreate | ||
- Properties: | ||
- name (str): The name of the author to create | ||
|
||
3. AuthorUpdate | ||
- Properties: | ||
- name (str): The updated name of the author | ||
|
||
|
||
Post Endpoints: | ||
|
||
1. GET /posts/?author_id={author_id} | ||
- Description: Retrieve a list of all posts for a specific author | ||
- Query Parameters: | ||
- author_id (int): The ID of the author to filter the posts by | ||
- Response: List of Post schemas | ||
|
||
2. GET /posts/{post_id}/?author_id={author_id} | ||
- Description: Retrieve a specific post by ID for a given author | ||
- Path Parameters: | ||
- post_id (int): The ID of the post to retrieve | ||
- author_id (int): The ID of the author to filter the post by | ||
- Response: Post schema | ||
- Exceptions: | ||
- 404 Not Found: If the post is not found for the given author | ||
|
||
3. POST /posts/?author_id={author_id} | ||
- Description: Create a new post by a specific author | ||
- Query Parameters: | ||
- author_id (int): The ID of the author creating the post | ||
- Request Body: PostCreate schema | ||
- Response: Post schema | ||
|
||
4. PUT /posts/{post_id}/?author_id={author_id} | ||
- Description: Update an existing post for a specific author | ||
- Path Parameters: | ||
- post_id (int): The ID of the post to update | ||
- author_id (int): The ID of the author updating the post | ||
- Request Body: PostCreate schema | ||
- Response: Post schema | ||
- Exceptions: | ||
- 404 Not Found: If the post is not found for the given author | ||
|
||
5. DELETE /posts/{post_id}/?author_id={author_id} | ||
- Description: Delete a post by a specific author | ||
- Path Parameters: | ||
- post_id (int): The ID of the post to delete | ||
- author_id (int): The ID of the author deleting the post | ||
- Response: 204 No Content | ||
- Exceptions: | ||
- 404 Not Found: If the post is not found for the given author |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SECRET_KEY= | ||
DEBUG= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
django | ||
djangorestframework==3.15.1 | ||
Pillow==10.3.0 | ||
pytest-django==4.8.0 | ||
django-redis==5.4.0 | ||
|
||
whitenoise # https://github.com/evansd/whitenoise | ||
redis # https://github.com/redis/redis-py | ||
hiredis # https://github.com/redis/hiredis-py | ||
celery # pyup: < 6.0 # https://github.com/celery/celery | ||
django-celery-beat # https://github.com/celery/django-celery-beat | ||
flower # https://github.com/mher/flower | ||
# Django | ||
# ------------------------------------------------------------------------------ | ||
django-environ # https://github.com/joke2k/django-environ | ||
django-redis # https://github.com/jazzband/django-redis | ||
# Django REST Framework | ||
django-cors-headers # https://github.com/adamchainz/django-cors-headers | ||
pyotp # https://github.com/pyotp/pyotp | ||
pydantic | ||
|
||
# Code quality | ||
# ------------------------------------------------------------------------------ | ||
flake8 # https://github.com/PyCQA/flake8 | ||
flake8-isort # https://github.com/gforcada/flake8-isort | ||
coverage # https://github.com/nedbat/coveragepy | ||
black # https://github.com/psf/black | ||
djlint # https://github.com/Riverside-Healthcare/djLint | ||
pylint-django # https://github.com/PyCQA/pylint-django | ||
pylint-celery # https://github.com/PyCQA/pylint-celery | ||
pre-commit # https://github.com/pre-commit/pre-commit | ||
|
||
|
||
gunicorn # https://github.com/benoitc/gunicorn | ||
|
||
# Monitoring | ||
# ----------------------------------------------------------------------------- | ||
sentry-sdk[django] # sentry-sdk[django] | ||
six |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
_#!/bin/bash | ||
export PYTHONPATH=./ | ||
rm -rf test.db | ||
pytest |