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.
- Single Page Application;
- Pluggable service architecture;
- Customer data validation;
- Credit card and boleto as payment methods;
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.
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 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
andcity
related to the specifiedzipCode
. It is already implemented using the viacep service (Brasil only).
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
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)
First of all you need to install the application dependencies. Run:
npm install
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.
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
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)