Git Product home page Git Product logo

sample-pie-shop's Introduction

Online store PWA sample

Build Status

This sample demonstrates best practices for e-commerce websites.

It also demonstrates some useful features enabled by new technologies and APIs on the web.

Development

Create a fork of the original project GoogleChromeLabs/sample-pie-shop and clone to your development environment.

Install dependencies

Change to the top level project directory run the following:

cd sample-pie-shop
npm ci

Note: This will install the dependencies as per the package-lock.json whereas npm install will update them. If you need to update the dependencies, submit the updated package-lock.json as a new PR.

Run the development server

The project uses Firebase Cloud Firestore for product data. You will need to create a project and download the JSON configuration for the Admin SDK. You can do this in the Firebase console using the Generate new private key button. Save this to src/data/firebase-admin-key.json.

The start:dev target will build the site and serve it locally while watching for any changes. Once the script completes the initial build, the site should be available at localhost:3000.

npm run start:dev

Note: You can override the default location for the config file by specifying a path in the FB_KEYS environment variable.

FB_KEYS=/path/to/alternative-key.json npm run start:dev

Check package.json for the other build targets.

Import data to the database

Sample data for products, product categories and homepage content is stored as JSON in the /src/data directory.

You can import (upload) this data to your remote Firestore database by running the following Node scripts from the /tools directory:

cd tools
node --experimental-modules import_home.mjs
node --experimental-modules import_products.mjs

This project uses ECMAScript Modules, which currently require the --experimental-modules flag.

Check your version of Node using node -v and update to the LTS or Current version if necessary. The import code above has been tested in versions 10.15.3 and 11.14.0.

Create a search index from your own data

This demo uses the Algolia search engine. This is free for open source projects with up to 100k records and 200k operations monthly.

The search functionality provided by this sample will work as-is for the product data in /src/data/products.json. In other words, if you're happy to use the sample product data as it is, you don't need to do anything!

However, if you want to use different product data, you will need to create your own Algolia application, then build a search index from your data. The index.js application in the /tools/algolia directory enables you to create an Algolia search index from a Firebase data source. It can also be used to monitor updates to your data, and update the Algolia search index in response.

Follow these steps to build a search index if you want to use your own data:

  1. Follow the Algolia tutorial to create a search application.
  2. Follow the tutorial instructions to create a .env configuration file in the /tools/algolia directory.
  3. Run node index.js in the same directory to get data from Firebase and create the index for the Algolia app.
  4. Update the APP_ID (Algolia app) and API_KEY (search key) values in /src/services/algolia.js.

Images

Images are served from Cloudinary and displayed responsively using the srcset and sizes attributes in combination with lazy-img for lazy loading.

Deploying

See DEPLOY.md.

sample-pie-shop's People

Contributors

devnook avatar rowan-m avatar samdutton avatar sgomes avatar tomayac avatar yoavweiss avatar agektmr avatar thomasdarimont avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.