{"id":16802482,"url":"https://github.com/sanjai0py/mirrar-backend-assignment","last_synced_at":"2026-04-29T21:04:53.394Z","repository":{"id":219946236,"uuid":"750288724","full_name":"sanjai0py/mirrAR-backend-assignment","owner":"sanjai0py","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-02T04:50:38.000Z","size":116,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T06:17:45.059Z","etag":null,"topics":["backend","expressjs","nodejs","rest-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sanjai0py.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-30T11:02:01.000Z","updated_at":"2024-03-06T01:39:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"657b23c3-6237-4913-8c1a-9a9d4b3479e9","html_url":"https://github.com/sanjai0py/mirrAR-backend-assignment","commit_stats":null,"previous_names":["sanjai0py/mirrar-backend-assignment"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sanjai0py/mirrAR-backend-assignment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjai0py%2FmirrAR-backend-assignment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjai0py%2FmirrAR-backend-assignment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjai0py%2FmirrAR-backend-assignment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjai0py%2FmirrAR-backend-assignment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sanjai0py","download_url":"https://codeload.github.com/sanjai0py/mirrAR-backend-assignment/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjai0py%2FmirrAR-backend-assignment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32443591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T20:22:27.477Z","status":"ssl_error","status_checked_at":"2026-04-29T20:22:26.507Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","expressjs","nodejs","rest-api"],"created_at":"2024-10-13T09:39:44.511Z","updated_at":"2026-04-29T21:04:53.366Z","avatar_url":"https://github.com/sanjai0py.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# E-commerce system\n\n## Description\n\nA simple e-commerce system built using PE~~R~~N stack\n\n## Table of Contents\n\n- [Technologies used](#technologies)\n- [Features](#features)\n- [Database Models and ERD](#database-models-and-erd)\n- [Improved Search Feature](#improved-search-feature)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Testing](#testing)\n- [API Endpoints](#api-endpoints)\n- [Resources and Useful links](#resources)\n- [Deployment Links](#deployed-link)\n\n## Technologies\n\n- [Node.js](https://nodejs.org/)\n- [Express](https://expressjs.com/)\n- [PostgreSQL](https://www.postgresql.org/docs/)\n- [Sequelize](https://sequelize.org/docs/v6/getting-started/)\n\n## Features\n\n- [x] Product Creation\n- [x] Product Retrivel\n- [x] Product Updation\n- [x] Product Deletion\n- [x] Product Searching\n\n## Database Models and ERD:\n\n**Database Models:**\n\nOur application involves two main entities: `Product` and `Variant`.\n\n1. **Product Model:**\n\n   - `id` (Primary Key)\n   - `name` (String, required)\n   - `description` (Text)\n   - `price` (Decimal, required)\n   - `image` (String, URL)\n   - `createdAt` and `updatedAt` (Auto-generated timestamps)\n\n2. **Variant Model:**\n   - `id` (Primary Key)\n   - `name` (String, required)\n   - `sku` (String, required)\n   - `additional_cost` (Decimal, required)\n   - `stock_count` (Integer, required)\n   - `productId` (Foreign Key referencing Product)\n   - `createdAt` and `updatedAt` (Auto-generated timestamps)\n\n**Entity Relationship Diagram (ERD):**\n\n![Alt text](https://i.ibb.co/vmGVkVS/mirrar-public.png)\n\nIn this ERD:\n\n- The `Product` entity has a one-to-many relationship with the `Variant` entity. Each product can have multiple variants, while each variant belongs to only one product.\n- The `productId` in the `Variant` entity is a foreign key referencing the `id` of the associated `Product`.\n\n## Improved Search Feature\n\nThe search functionality on my API was slow when I used Sequelize ORM's `Op.ilike` operations, taking about 20-30 ms for a table of 200 rows. Upon digging through the documentation, I found out that Postgres has an in-built full-text search feature that is specifically made for this functionality, and is much faster. To improve the search feature, I created a new branch called `improved-search` and implemented a basic version of the search using Postgres's full-text search feature, even though it was buggy because it was already time to submit the assignment. I plan to learn more about this feature of Postgres and implement it in the `improved-search` branch to avoid breaking the `main` branch.\n\n## Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/sanjai0py/mirrAR-backend-assignment.git\n\n# Populate .env variables\ncp .env.example .env\n\n# Navigate to the project directory\ncd mirrar-backend-assignment\n\n# Install dependencies\nnpm install\n```\n\n## Usage\n\n```bash\n# change directory\ncd server\n\n# Start the application\nnpm start\n```\n\nVisit [http://localhost:5000/](http://localhost:5000/) in your web browser. The server started successfully if you are greated with the message `Hello World!`\n\n## Testing\n\n```bash\n# Run tests\nnpm test\n```\n\n## API Endpoints\n\n- **`GET api/v1/docs`**: Get the swagger documentation.\n- **`GET api/v1/products`**: Get a list of all products.\n- **`POST api/v1/products`**: Create a new product.\n- **`GET api/v1/products/:id`**: Get details of a specific product.\n- **`PUT api/v1/products/:id`**: Update a product.\n- **`DELETE api/v1/products/:id`**: Delete a product.\n- **`GET api/v1/search`**: Search for a product.\n\n## Resources\n\n\u003e The best books are on the Internet. The best peers are on the Internet. The tools for learning are abundant. It's the desire to learn that's scarce. -Naval Ravikant\n\nThanks to the amazing internet, which provides a wealth of knowledge. Here are a few resources that helped me learn some advanced concepts in my field:\n\n- [Readme.md driven development](https://tom.preston-werner.com/2010/08/23/readme-driven-development.html)\n- [REST-API best design practices](https://stackoverflow.blog/2020/03/02/best-practices-for-rest-api-design/)\n\n## Deployed Link\n\nThe API is deployed on [Render](https://render.com/). **The API might take some time to respond as it is hoisted on a free plan.**\n\n- [API](https://e-commerce-backend-vn3u.onrender.com)\n- [Documentation](https://e-commerce-backend-vn3u.onrender.com/api/v1/docs/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanjai0py%2Fmirrar-backend-assignment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsanjai0py%2Fmirrar-backend-assignment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanjai0py%2Fmirrar-backend-assignment/lists"}