imbrn / ebook-store

πŸ“š Simple e-book shop application easy to plug into custom services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

E-book Store

Web client for an e-book store application. This client was developed with React and it's easy to be connected to a back-end service.

Features

  • Single Page Application;
  • Pluggable service architecture;
  • Customer data validation;
  • Credit card and boleto as payment methods;

Application architecture

The application architecture works the following way:

  • This application client is a web application developed with React. It uses a default architecture for fetching e-books and requesting purchase from a configured service.

  • An Single Page Application is provided for customers access. The customers can select e-books from a list of available e-books and request purchases.

  • The client application talks with the current service to provide a real application workflow.

How to use?

It has a mock service already implemented for testing purpose. You can run it right now to see it working. Look at the Development section to see how you can start a local server.

For you to use this application with your application back-end service, you first need to have an application back-end ready to be connected. Then you have to edit the src/main.js file and point to your service implementation by using the setService function.

Look at the service section to get more information about how to provide a service connector.

The service object

The service object must supply two main functions, and an optional one:

  • fetchAllEbooks: it must return a promise which resolves to a list of e-books available to sell.

  • requestBuy: it receives a list of e-books an the customer data ready to be processed by a back-end service.

  • searchZipCode: it receives a zip code and returns a promise with resolves to an object containing a state and city related to the specified zipCode. It is already implemented using the viacep service (Brasil only).

E-book data structure

An e-book is composed by the following data:

  • ID: unique identifier for the e-book in the system;
  • title: the title for the e-book (minimum 1 character)
  • description: a description of the e-book (optional, minimum 1 character)
  • price: price of the e-book in cents (number)

The application searches for e-book thumbs at the URL: public/images/ebooks/{ebook-id}.png

Customer data

The customer data are composed by the following:

  • personal data: (personal information about the customer)

    • name: the customer's full name (minimum 2 characters)
    • email: the customer e-mail address (valid email address)
    • cpf: brazilian valid CPF (valid CPF)
  • billing address:

    • zipCode: brazilian CEP (valid CEP)
    • state: the address state (minimum 2 characters)
    • city: city (minimum 2 characters)
    • address: the full address with street, number and optionals (minimum 1 character)
  • payment:

    • method: "boleto" or "creditCard"

    when "creditCard":

    • cardholderName: the name as in the card (minimum 2 characters)
    • cardNumber: the number of the credit card (valid VISA or MASTER card number)
    • dueDate: expiration date of the card (month/year)
    • cvv: cvv of the card (minimum 3, maximum 4 characters)

Building

First of all you need to install the application dependencies. Run:

npm install

Testing

To run tests for the application code to guarantee that it works properly, you should run:

  • To test this application client in watching mode, run:

    npm test -- --watch

    this will fire up a jest instance in watch mode.

  • or you can just run:

    npm test

    and this is going to run your test once.

Development mode

To run this application in development mode, run:

npm run dev

this is going to launch a local server with hot-reload for you to test your application.

So you can access it at: http://localhost:3000

Building application

When the application is ready to be deployed, you should run this command:

npm run build

this is going to build your application for production. A dist folder will be created with your application ready to be deployed.


Developed with ❀ by Bruno C. Couto (imbrn)

About

πŸ“š Simple e-book shop application easy to plug into custom services


Languages

Language:JavaScript 95.9%Language:CSS 3.7%Language:HTML 0.5%