A simple Django RESTful API to create and list product inventory entries. This API was built for an interview assignment for roche.
- WRITE Endpoint: Create a new product by sending
product_name,price, andquantity. - READ Endpoint: List all products in JSON format.
- Validation: Strong input validation with proper error messages.
- Error Handling: Returns structured JSON responses with appropriate HTTP status codes.
- Tests: Unit tests to verify core functionality.
- Python 3.13+
- pip or uv ( I have used uv but either can work)
# Clone the repo
git clone https://github.com/yourusername/interview-with-roche.git
cd interview-with-roche
# Create virtual environment
uv venv .venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
uv add django djangorestframework
OR
uv pip install .# Apply migrations
python manage.py migrate
# Run the development server
python manage.py runserverAPI will be available at: http://localhost:8000/api/products/
curl -X POST http://localhost:8000/api/products/ \
-H "Content-Type: application/json" \
-d '{"product_name": "Monitor", "price": 300, "quantity": 80}'curl http://localhost:8000/api/products/{
"1": {
"product_name": "Monitor",
"price": 300.0,
"quantity": 80
}
}> python manage.py test inventoryApp
Found 4 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
....
----------------------------------------------------------------------
Ran 4 tests in 0.007s
OK
Destroying test database for alias 'default'...Repective depdencies should be installed automatically when creating virtualenv, however some configuaration needs tweaking.
To do that, please Open your settings.py file and locate the DATABASES configuration. Replace it with the respective Snowflake-specific settings as needed.