[cite_start]This project is a backend service built for the Streamoid Backend Intern/Fresher take-home exercise[cite: 1, 2]. [cite_start]It simulates a system for online sellers to upload, validate, and manage their product catalogs from a CSV file before listing them on marketplaces[cite: 6, 14].
The application is built with Node.js, Express.js, and SQLite.
- [cite_start]CSV Upload: Upload a product catalog via a
multipart/form-datarequest[cite: 16]. - [cite_start]Data Validation: Each row of the CSV is validated against a set of rules (e.g.,
price <= mrp, required fields)[cite: 17, 33]. - [cite_start]Database Storage: Valid products are parsed and stored in an SQLite database[cite: 17, 37].
- [cite_start]Product Listing: An endpoint to list all stored products with pagination support[cite: 18, 40].
- [cite_start]Product Search: An endpoint to search and filter products by brand, color, and price range[cite: 18, 43].
To run this project locally, follow these steps:
-
Clone the repository:
git clone <your-github-repository-url>
-
Navigate to the project directory:
cd streamoid-backend -
Install dependencies:
npm install
-
Create the
uploadsdirectory: The application requires anuploadsfolder in the root directory to temporarily store CSV files.mkdir uploads
-
Run the server:
node src/app.js
The server will start and be available at
http://localhost:8000.
This application can be built and run using Docker, with no local setup required other than Docker itself.
-
Build the Docker image:
docker build -t streamoid-backend . -
Run the Docker container:
docker run -p 8000:8000 streamoid-backend
The application will be available at
http://localhost:8000.
The API provides three main endpoints to manage products.
- Endpoint:
GET / - Description: A simple welcome route to confirm that the API is running.
- Sample Request:
curl http://localhost:8000/
- Success Response:
{ "status": "success", "message": "Streamoid Product API is running." }
- [cite_start]Endpoint:
POST /upload[cite: 31] - Description: Uploads a CSV file of products. [cite_start]The file is parsed, each row is validated, and valid products are stored in the database[cite: 16, 17, 37].
- Request Body:
multipart/form-datawith a keyfileholding the CSV file. - Sample Request:
curl -X POST -F "file=@products.csv" http://localhost:8000/upload - Success Response:
{ "stored": 3, "failed": [ { "row": { "sku": "INVALID-ROW", "name": "Test Product", "brand": "Test Brand", "color": "Black", "size": "L", "mrp": "500", "price": "600", "quantity": "5" }, "reason": "Price cannot be greater than MRP." } ] }
- [cite_start]Endpoint:
GET /products[cite: 39] - [cite_start]Description: Returns a paginated list of all products stored in the database[cite: 40].
- Query Parameters:
page(optional): The page number to retrieve (default:1).limit(optional): The number of items per page (default:10).
- Sample Request:
curl "http://localhost:8000/products?page=1&limit=5" - Success Response:
{ "totalItems": 3, "totalPages": 1, "currentPage": 1, "products": [ { "sku": "TSHIRT-RED-001", "name": "Classic Cotton T-Shirt", "brand": "Stream Threads", "color": "Red", "size": "M", "mrp": 799, "price": 499, "quantity": 20, "createdAt": "2025-10-13T09:19:50.725Z", "updatedAt": "2025-10-13T09:19:50.725Z" } ] }
- [cite_start]Endpoint:
GET /products/search[cite: 42] - [cite_start]Description: Searches for products based on various filter criteria[cite: 43].
- Query Parameters:
- [cite_start]
brand(optional): Filter by brand name (e.g.,?brand=DenimWorks)[cite: 44]. - [cite_start]
color(optional): Filter by color (e.g.,?color=Red)[cite: 45]. - [cite_start]
minPrice&maxPrice(optional): Filter by a price range (e.g.,?minPrice=500&maxPrice=2000)[cite: 46].
- [cite_start]
- Sample Request:
curl "http://localhost:8000/products/search?brand=Stream+Threads" - Success Response:
[ { "sku": "TSHIRT-RED-001", "name": "Classic Cotton T-Shirt", "brand": "Stream Threads", "color": "Red", "size": "M", "mrp": 799, "price": 499, "quantity": 20, "createdAt": "2025-10-13T09:19:50.725Z", "updatedAt": "2025-10-13T09:19:50.725Z" } ]