Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c15ecf4
First Commit
Pushkar06p Feb 11, 2026
89205ed
Build GET API using hexagonal architecture
Pushkar06p Feb 14, 2026
a0d60fc
added warehouse app in urls
Pushkar06p Feb 19, 2026
af5e4ff
APIs will only perform in-memory operations
Pushkar06p Feb 19, 2026
d4a4ec5
created ProductService layer
Pushkar06p Mar 1, 2026
a7e4919
Update product model
Pushkar06p Mar 14, 2026
c9571bd
remove unnecessary files
Pushkar06p Mar 14, 2026
eccc141
create ProductCategory service layer
Pushkar06p Mar 14, 2026
4180221
Model products belonging to a category
Pushkar06p Mar 14, 2026
bbc5bc3
Add CRUD APIs for a product category
Pushkar06p Mar 14, 2026
cdc7ca8
Add APIs to fetch a list of products belonging to a category
Pushkar06p Mar 14, 2026
76cdcd0
Add APIs to add/remove products from categories
Pushkar06p Mar 14, 2026
f7f09a6
Add validation for brand requirement
Pushkar06p Mar 14, 2026
63788b3
handle existing products not having brand
Pushkar06p Mar 14, 2026
9de9305
unit tests for ProductCategoryService mocking the repository layers
Pushkar06p Mar 16, 2026
b864edd
unit tests for ProductService, mocking the repository layers
Pushkar06p Mar 16, 2026
b4172df
write seed scripts and setup tests for writing integration tests
Pushkar06p Mar 16, 2026
219479d
Write an integration test that tests the various APIs
Pushkar06p Mar 16, 2026
1f58885
Improve test coverage
Pushkar06p Mar 26, 2026
9fef166
Add Makefile
Pushkar06p Mar 26, 2026
d43af2a
Revise README for project details and setup instructions
Pushkar06p Mar 26, 2026
9595f08
Merge branch 'product-category-service-layer' of github.com:Pushkar06…
Pushkar06p Mar 26, 2026
d353f78
refactor: merge product_category into product_service
Pushkar06p Apr 1, 2026
04a8d99
refactor(api): convert verb-based URLs to RESTful endpoints
Pushkar06p Apr 1, 2026
81209ce
feat: implement product and category controllers and introduce reusab…
Pushkar06p Apr 1, 2026
af5d8c6
feat(service): implement product and category service layer with exc…
Pushkar06p Apr 1, 2026
2f5ecb3
feat: update product and category models and repositories
Pushkar06p Apr 1, 2026
a4261f7
test: add API integration tests and service unit tests
Pushkar06p Apr 1, 2026
d23e668
update Makefile
Pushkar06p Apr 1, 2026
10cbfec
refactor: rename product_service app to products
Pushkar06p Apr 1, 2026
574d42a
fix: update imports after renaming product_service to products
Pushkar06p Apr 1, 2026
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
48 changes: 48 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -----------------------------
# Variables
# -----------------------------
BACKEND_DIR = backend/python
FRONTEND_DIR = frontend
VENV = venv

PYTHON = $(BACKEND_DIR)/$(VENV)/Scripts/python
PIP = $(BACKEND_DIR)/$(VENV)/Scripts/pip

# -----------------------------
# Setup
# -----------------------------

venv:
cd $(BACKEND_DIR) && python -m venv $(VENV)

install-backend: venv
$(PIP) install --upgrade pip
$(PIP) install -r $(BACKEND_DIR)/requirements.txt

install-frontend:
cd $(FRONTEND_DIR) && yarn install

setup: install-backend install-frontend

# -----------------------------
# Run servers
# -----------------------------

run-backend:
cd $(BACKEND_DIR) && $(VENV)/Scripts/python manage.py runserver

run-frontend:
cd $(FRONTEND_DIR) && yarn start

# -----------------------------
# Testing
# -----------------------------

test:
cd $(BACKEND_DIR) && $(VENV)/Scripts/python -m pytest

coverage:
cd $(BACKEND_DIR) && $(VENV)/Scripts/python -m pytest --cov

html-coverage:
cd $(BACKEND_DIR) && $(VENV)/Scripts/python -m pytest --cov --cov-report=html
194 changes: 112 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,127 +1,157 @@
# Interneers Lab
# Product Service & Product Category API

Welcome to the **Interneers Lab** repository! This serves as a minimal starter kit for learning and experimenting with:
- **Django** (Python)
- **Golang** (Go)
- **React** (with TypeScript)
- **MongoDB** (via Docker Compose)
- Development environment in **VSCode** (recommended)
This repository contains backend services for managing **Products** and **Product Categories**.
The project includes APIs, service layers, unit tests, integration tests, and automated development workflows using a **Makefile**.

**Important:** Use the **same email** you shared during onboarding when configuring Git and related tools. That ensures consistency across all internal systems.

### Project structure
---

## Project Structure
```
backend/
go/ # Golang backend (see backend/go/README.md)
python/ # Django (Python) backend (see backend/python/README.md)
frontend/ # React + TypeScript (see frontend/README.md)
├── backend/
│ ├── python/
│ │ ├── django_app/
│ │ ├── htmlcov/
│ │ ├── product_service/
│ │ ├── product_category/
│ │ ├── warehouse/
│ │ ├── docker-compose.yaml
│ │ ├── pytest.ini
│ │ └── requirements.txt
| |
│ └── go/
├── frontend/
├── Makefile
├── README.md
└── CHANGELOG.md
```
---

## Features

* Product CRUD APIs
* Product Category APIs
* Service layer abstraction
* Unit and integration tests
* Test coverage reporting
* Automated development commands using Makefile

---

## Table of Contents
## Prerequisites

Before running the project ensure the following are installed:

1. [Getting Started with Git & Forking](#getting-started-with-git-and-forking)
2. [Prerequisites & where to find them](#prerequisites--where-to-find-them)
3. [Setting up & running](#setting-up--running)
4. [Development Workflow](#development-workflow)
- [Pushing Your First Change](#pushing-your-first-change)
5. [Making your first change](#making-your-first-change)
6. [Running Tests](#running-tests)
7. [Frontend Setup](#frontend-setup)
8. [Further Reading](#further-reading)
* Python 3.10+
* pip
* Node.js (for frontend)
* Yarn
* Make

---

## Getting Started with Git and Forking
## Setup Instructions

### 1. Setting up Git and the Repo
Clone the repository:

1. **Install Git** (if not already):
- **macOS**: [Homebrew](https://brew.sh/) users can run `brew install git`.
- **Windows**: Use [Git for Windows](https://gitforwindows.org/).
- **Linux**: Install via your distro's package manager, e.g., `sudo apt-get install git` (Ubuntu/Debian).
```bash
git clone <repository-url>
cd interneers-lab
```

2. **Configure Git** with your name and email:
```bash
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com" # Use the same email you shared during onboarding
```
Create virtual environment and install dependencies:

3. **What is Forking?**
```bash
make setup
```

Forking a repository on GitHub creates your own copy under your GitHub account, where you can make changes independently without affecting the original repo. Later, you can make pull requests to merge changes back if needed.
This command will:

4. Fork the Rippling/interneers-lab repository (ensure you're in the correct org or your personal GitHub account, as directed).
5. **Clone** your forked repo:
```bash
git clone git@github.com:<YourUsername>/interneers-lab.git
cd interneers-lab
```
* Create a Python virtual environment
* Install backend dependencies
* Install frontend dependencies

## Prerequisites & where to find them
---

Prerequisites (Python, Go, Node, Docker, etc.) and how to verify your setup are documented in each part of the repo:
## Running the Backend

- **[backend/python/README.md](backend/python/README.md)** — Python/Django, virtualenv, MongoDB
- **[backend/go/README.md](backend/go/README.md)** — Go, MongoDB
- **[frontend/README.md](frontend/README.md)** — Node, Yarn, React
Start the backend server:

Use the README for the part you're working on.
```bash
make backend
```

---

## Setting up & running
## Running the Frontend

Setup and run instructions live in the domain READMEs:
Start the frontend application:

- **Python backend:** [backend/python/README.md](backend/python/README.md) — venv, dependencies, `runserver`, Docker Compose for MongoDB
- **Go backend:** [backend/go/README.md](backend/go/README.md) — `make setup`, `make build-and-run`, Docker Compose
- **Frontend:** [frontend/README.md](frontend/README.md)
```bash
make frontend
```

---

## Development Workflow
## Running Tests

### Making your first change
Execute all tests:

Step-by-step tutorials live in the domain READMEs:
```bash
make test
```

- **[backend/python/README.md](backend/python/README.md)** — Django starters (e.g. Hello World, Hello {name} API)
- **[backend/go/README.md](backend/go/README.md)** — Go hello-world and APIs
- **[frontend/README.md](frontend/README.md)** — React hello-world and APIs
This will run **pytest test suites** including unit tests.

### Pushing Your First Change
---

1. **Stage and commit**:
```bash
git add .
git commit -m "Your descriptive commit message"
```
2. **Push to your forked repo (main branch by default):**
```bash
git push origin main
```
## Running Tests with Coverage

Generate test coverage:

```bash
make coverage
```

Example output:

```
---------- coverage ----------
Name Stmts Miss Cover
----------------------------------------------
product_service/service.py 45 3 93%
product_category/service.py 30 2 93%
----------------------------------------------
TOTAL 75 5 93%
```

---

## Running Tests
## Development Workflow

See the domain READMEs for how to run tests in each stack:
Typical development workflow:

- [backend/python/README.md](backend/python/README.md)
- [backend/go/README.md](backend/go/README.md)
- [frontend/README.md](frontend/README.md)
```bash
make setup
make test
make coverage
```

---

## Further Reading
## Testing Overview

The project includes:

### Unit Tests

* Test service layer logic
* Mock repository layers

### Integration Tests

Each domain has detailed README with links to relevant docs. In general:
* Validate API endpoints
* Test full request-response flow

- **Django:** [docs.djangoproject.com](https://docs.djangoproject.com/)
- **React:** [react.dev](https://react.dev/learn)
- **Go:** [go.dev/doc](https://go.dev/doc/)
- **MongoDB:** [docs.mongodb.com](https://docs.mongodb.com/)
- **Docker Compose:** [docs.docker.com/compose](https://docs.docker.com/compose/)
Integration tests may require additional services (e.g. MongoDB) and may be skipped if dependencies are unavailable.
Binary file added backend/python/.coverage
Binary file not shown.
3 changes: 3 additions & 0 deletions backend/python/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
omit =
warehouse/*
1 change: 1 addition & 0 deletions backend/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,4 @@ docker compose down # Stop MongoDB
docker compose ps # List running containers
docker compose logs -f # View logs
```
<!-- Starting Django -->
66 changes: 66 additions & 0 deletions backend/python/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import pytest
from pymongo import MongoClient
from mongoengine import disconnect, connect

@pytest.fixture(scope="session")
def mongo_client():
client = MongoClient("mongodb://root:example@localhost:27019/?authSource=admin")
yield client
client.close()

@pytest.fixture(scope="session", autouse=True)
def setup_database():
disconnect()
connect(
db="test_db",
host="mongodb://root:example@localhost:27019/test_db?authSource=admin"
)
yield
disconnect()


@pytest.fixture(scope="function")
def test_db(mongo_client):
db = mongo_client["test_db"]

for collection in db.list_collection_names():
db[collection].delete_many({})

yield db

for collection in db.list_collection_names():
db[collection].delete_many({})

@pytest.fixture
def seeded_categories(test_db):
from products.models import Category

cat1 = Category(name="Fruits", description="Fresh fruits").save()
cat2 = Category(name="Vegetables", description="Fresh vegetables").save()

return [str(cat1.id), str(cat2.id)]

from products.models import Product

@pytest.fixture
def seeded_products(seeded_categories):
p1 = Product(
name="Apple",
price=10,
category=str(seeded_categories[0]),
brand="Fruit Brand",
quantity=50
).save()

p2 = Product(
name="Carrot",
price=8,
category=str(seeded_categories[1]),
brand="Veg Brand",
quantity=40
).save()

return [p1.id, p2.id]



11 changes: 11 additions & 0 deletions backend/python/django_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"products",
]

MIDDLEWARE = [
Expand Down Expand Up @@ -121,3 +123,12 @@
# https://docs.djangoproject.com/en/6.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

from mongoengine import connect

from mongoengine import connect

connect(
db="product_db",
host="mongodb://root:example@localhost:27019/product_db?authSource=admin"
)
Loading