Run the executable without installing dependencies
All you need to do is extract the 'Codester - Electron POS app' folder to any location, open it and run the 'Electron + React Sales & Inventory Setup 1.0.0' file to install the application. You should be ready to use the application right out of the box
Install dependencies and run in development
Install Node from nodejs.org
Extract the downloaded zip file and copy the 'Project' folder to your favourite directory
Open the Project folder in command prompt or terminal
Install all the dependencies with (This will install all the dependencies you will need to run the project):
To run in development mode, Open 2 command prompt windows (or terminals).
Run the react server in the first one with:
If any browser window opens, close it.
Then run the electron app in the second one with:
npm run electron:start
Using the source code
The Project folder in the extracted zip file is a React project.
All the react components for the different pages are in the 'src' folder
The public folder contains the root index.html file, the loading screen (splash.html), the electron main entry point (main.js), preload script (preload.js) where all Inter-process Communications (IPC) occurs, bootstrap files (bootstrap.min.css and bootstrap.bundle.min.js), and the images and logos. There are also 2 JSOn files for user and business profile settings in the public folder
There are files that are not used now but may be used during the course of updating the project (authenticatonWindow.html and authenticatonWindow.js)
The contents of the 'utilities' folder are not being used. But may be used during the course of updating the project.
Open the Project folder in a text editor
ENTRY POINT - public/main.js
The entry point of the application is main.js inside the public folder
All IPC rendering takes place here. The database class is defined and instantiated right after the imports
PRELOAD - public/preload.js
The preload.js in the public folder is where the context bridge, between the react frontend and the electron backend, is created. This allows safe IPC from the frontend without risk of Cross Site Scripting
FRONTEND - src/components
The frontend pages and components are in the 'components' folder inside the 'src' folder
There 3 main folders in the components folder:
SideNavigation, AppPages, AppContainer
AppContainer contains all components for the main component that contains all other components
SideNavigation contains components used for the side navigation
AppPages contains all components for each of the different pages of the application
In each of the components' folder, there is a styled component (components whose name ends with .style.js). That is where the CSS style of the corresponding component is written. Edit it as you see fit.
Some global styles have been specified in the index.css file outside the components folder. You can edit that too to your taste
React router was not used in this project. You can edit the components to use it.
All the wrapper components are built with class based components. You can re-write them into functional components if that is what you prefer
You can see the scripts I set up in the 'package.json' file
start - Starts the react frontend
electron:start - Starts the electron backend
electron:build - Builds the react application into the build folder,
and then uses electron-builder to pacjage the electron application into an installer for the OS you are using
Execute the scripts in the command prompt or terminal
npm start - To run the react frontend on port 3000 in dev mode
npm run electron:start - Waits for port 3000 to be active before running the electron backend
npm run electron:build - Builds the react application to a build folder and then bundles the electron application with the contents of the build folder into an installer for the platform on which the command was ran.