Skip to content

Week 8 api integration#86

Open
Purrna Srivastav (Purrnsr) wants to merge 16 commits into
Rippling:mainfrom
Purrnsr:week-8-api-integration
Open

Week 8 api integration#86
Purrna Srivastav (Purrnsr) wants to merge 16 commits into
Rippling:mainfrom
Purrnsr:week-8-api-integration

Conversation

@Purrnsr

@Purrnsr Purrna Srivastav (Purrnsr) commented Apr 10, 2026

Copy link
Copy Markdown

This PR includes the complete implementation of Week 8 along with a demo video showcasing the progression of the frontend from Week 6 → Week 7 → Week 8.

Demo Video : https://drive.google.com/file/d/1cNuGJK7tHMBMr5JzqfbqixvC0CNtvYG2/view?usp=sharing

Week 6 – HTML, CSS, Vanilla JS

  • Built a basic product UI using HTML and CSS
  • Created product display cards
  • Initially used dummy/static data
  • Integrated backend APIs using fetch
  • Rendered products dynamically using DOM manipulation

Week 7 – React + TypeScript

  • Migrated frontend to React with TypeScript
  • Built reusable components:
    • <Product />
    • <ProductList />
  • Used dummy data to focus on component structure
  • Implemented props-based data flow
  • Added basic UI structure (Header, Navbar)

Week 8 – API Integration, State Management & Routing

  • Integrated frontend with real backend database
  • Implemented API calls for:
    • Fetching products
    • Fetching categories
    • Updating products
  • Managed state using React hooks (useState, useEffect)
  • Added routing:
    • /products
    • /products/:id
    • /categories/:id
  • Built Product Detail page with editable form (controlled inputs)
  • Implemented product update using PUT API
  • Handled category updates via:
    • DELETE (remove old category)
    • POST (assign new category)

Category Functionality

  • Added ability to move products across categories
  • Built Category Page to:
    • Display category details
    • List all products under that category
  • Reused <Product /> component with conditional rendering

UX Enhancements

  • Added loading spinner component
  • Implemented error handling UI
  • Added success feedback messages
  • Improved navigation flow across pages
  • Ensured clean and reusable component structure

We get

  • Dynamic API-driven frontend
  • Clean state management
  • Multi-page navigation
  • Product editing and category management
  • Proper separation between data updates and relationships
    .

Note

Medium Risk
Introduces new MongoDB connection initialization and CRUD endpoints for products/categories, plus client-side routing and update flows that can affect data integrity and deployment configuration. Risk is moderate due to new DB wiring, bulk upload, and category reassignment behavior.

Overview
Backend: Adds MongoDB (MongoEngine) integration via DjangoAppConfig.ready() calling init_db() and environment-driven settings (MONGO_URI, CORS, hosts/secret). Introduces product/category domain models, repositories, services, and controllers with consistent success_response/error_response, including pagination/filtering, updated_after listing, soft-delete, bulk CSV upload, and endpoints to assign/remove a product’s category; also adds a seed_categories management command and a migration script to backfill missing categories.

Frontend: Replaces the CRA starter UI with a routed React app (/products, /products/:id, /categories/:id) that fetches from the new APIs, provides a product edit page (PUT + separate category reassignment via DELETE/POST), adds basic layout components (header/nav/loader), and bumps react-router-dom plus adds lint/format scripts.

Reviewed by Cursor Bugbot for commit de9216c. Configure here.

purrnasrivastav and others added 16 commits February 16, 2026 23:33
… to MongoEngine ORM, add request/response models and audit fields (advanced section implemented as well)
…s for ProductService/ProductCategoryService with mocking; implemented integration tests with Django and MongoDB; refactored tests to use seed command; added negative/parameterized test cases; created seed_categories command; added regression script (run_tests.bat); configured .env; improved assertions. ~69%% coverage
…n, dynamic rendering, expandable UI, loading/empty states, and improved UX.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 7 potential issues.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit de9216c. Configure here.

message=updated["error"]
if isinstance(message, list):
message = message[0]
return error_response("VALIDATION_ERROR", updated["error"], status=400)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PUT error returns raw list instead of extracted message

High Severity

In the PUT handler, after extracting the first element from a list-type error into message, the code passes updated["error"] (the original, possibly list value) to error_response instead of the processed message variable. When the error is a list, the error_response message parameter receives a list instead of a string, producing malformed JSON error output.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit de9216c. Configure here.

MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate SecurityMiddleware and SessionMiddleware in MIDDLEWARE list

Medium Severity

SecurityMiddleware and SessionMiddleware each appear twice in the MIDDLEWARE list. This causes them to execute twice per request/response cycle, which can lead to unexpected behavior such as duplicate header processing or performance overhead.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit de9216c. Configure here.


# DEFAULT PK
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
print("Mongo URI:", MONGO_URI)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Print statement leaks MongoDB URI to stdout

High Severity

print("Mongo URI:", MONGO_URI) logs the MongoDB connection URI (which typically contains credentials) to stdout on every Django startup. This is debug code that was accidentally left in the settings file.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit de9216c. Configure here.


@classmethod
def delete_category(cls, category_id):
return cls.category_repository.delete(category_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test file redefines service class, shadowing real import

Medium Severity

The test file imports ProductCategoryService from the services module on line 7, then immediately redefines a local class ProductCategoryService on line 12 that shadows the import. The test methods (test_create_category_none_title, test_list_categories_empty) are methods of this non-TestCase class, so they are never executed by the test runner. The entire file tests nothing.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit de9216c. Configure here.

});
})
.catch((err) => console.error(err));
</script>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React index.html replaced with conflicting vanilla JS

High Severity

The CRA public/index.html template was replaced with a standalone vanilla JS page. It includes an inline <script> that calls data.forEach(...) on the API response (which is actually a wrapped object, not an array). React also mounts to the same product-container div. The <div id="root"> was removed, and essential CRA meta tags, manifest link, and <noscript> fallback were stripped out.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit de9216c. Configure here.

Comment thread frontend/src/index.tsx
@@ -1,22 +1,13 @@
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing CSS import leaves spinner component unstyled

Medium Severity

The import "./index.css" was removed from index.tsx, but index.css contains the .spinner class used by Loader.tsx. Without this import, the loading spinner renders as an unstyled empty div with no animation, making it invisible to users.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit de9216c. Configure here.

if category or price_min or price_max:

price_min = float(price_min) if price_min else None
price_max = float(price_max) if price_max else None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unhandled ValueError when parsing price filter parameters

Medium Severity

float(price_min) and float(price_max) will raise an unhandled ValueError if a user passes non-numeric query strings like ?price_min=abc, resulting in a 500 server error. The pagination parameters just below (lines 64–67) are correctly wrapped in a try/except ValueError, but the price filter conversions lack the same protection.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit de9216c. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants