A single-page web application that acts as the main frontend for the Trébol eCommerce software project.
Originally written using Angular 9, and over the years migrated up to Angular 15.
Please see CHANGELOG.md for a detailed overview of the latest changes & additions to the codebase.
Visit the application live demo in this link.
To access the administration panel, access the login dialog by click on the button with an user icon in the top right corner of the screen.
With the login dialog open, type admin
as both username and password in it.
The dialog will close itself, and the aforementioned button should
become a dropdown menu with an option to navigate to the admin panel.
This demo feeds on a feature module that provides data stored in hard-coded JS arrays; thus, your browser's working memory acts as a fake persistence layer. You can try all the CRUD-related functionality, but once you force a reload or leave the web application, all changes in the data will be lost.
This is interchangeably called the "fake API" as well the "local-memory module". In this project they mean the same thing.
Most of the data itself was generated using Mockaroo.
Placeholder images are served from Fake Images Please.
The application itself is divided into modules in the /src/app/
directory,
and its structure is as follows:
store/
- The eCommerce components and pages, such as the frontpage, the product catalog, the checkout wizard page, and the receipt page.management/
- The administration (PoS) area of the app. Authorized users may be able to review all the sales; query all products and their categories; create accounts for other users; list customers; upload images for products, among other things.shared/
- Exports Angular components, directives, and general elements that are used by other modules and/or the application as a whole.api/
- Contains interfaces, modules, and dependency injection tokens to interact with the backend REST API.local-memory/
- Serves a fake API as explained above. It's the default option to build and serve the webapp with.http/
- Serves access to a real, running backend server with an exposed REST API compliant to the specification linked above. The Spring Boot monolith is exactly that.
The api
module is imported through
an environment file which makes it painless to switch between implementations.
Unit tests use Jasmine and run on top of Karma.
Execute ng t --no-watch --browsers={browser}
in the root directory
to test the entire application immediately, only once.
Supported browsers are Chrome
, Edge
, Firefox
, Safari
,
and you can add more to the karma.conf.js
file.
There's also ChromeHeadless
which is useful for CI pipelines
such as the one setup here.
- Execute
ng t
orng test
in the root directory to start the Karma server. - Connect to its listening address (e.g.
localhost:9876
) with the browser(s) of your preference to prepare them for parallel testing. - In the root directory, under a different terminal process, trigger the tests
anytime by executing
karma run
. Alternatively, in the browser window, you can press theDEBUG
button, to initiate the test suites in debug mode.
This project uses
Angular i18n features;
this means you can build the app using different languages.
Currently bundled locales reside in /src/locales
.
There are three:
en-US
es
es-CL
If you wish to translate this frontend to another language, check out this Angular guide on working with translation files.
- v15-compatible installation for Node.JS.
- Angular CLI v15 or higher (view v15 docs here).
- Clone this repo.
- Execute
npm ci
in the root directory (where thepackage.json
file is). - Execute
ng s
orng serve
in the root directory to preview-run the application. This is equivalent to visiting the live demo linked above. - To work with a backend, you should set up your working environment.
See
Quick setup
below.
- Make yourself comfortable with the official Angular guide on Building and Serving Apps.
- Default environment files already exist in
/src/environments/
environment.ts
defines application-wide constants.environment-modules.ts
defines module dependencies.
- The
/angular.json
file contains some additional configs; I mostly usestaging
,localhost
andproduction
. The latter two require you to define environment files as specified by theirfileReplacements
definitions.- There's also a configuration for
each bundled locale other than default
en-US
. - While Angular supports using more than one configuration at the same time, things may break. Only try this when you know what you're doing.
- There's also a configuration for
each bundled locale other than default
- This project also declares the plugin for angular-cli-ghpages as a devDependency, which you may find useful to deploy to a GitHub Pages environment, like the live demo here does.
-
Create a copy of the two environment files and rename them accordingly from your desired configuration e.g.
environment.localhost.ts
andenvironment-modules.localhost.ts
. -
Call
ng s
orng b
Angular CLI command using the-c
option to target said configuration e.g.ng b -c production
. You can target more than one, separating them by commas,
. -
If you used
ng b
, serve the files from your preferred webserver. I used to runphp -S localhost:80
from the resulting./dist/ngx-trebol-frontend/
directory. To use any of the locales mentioned above you'll have to either:- Mind the corresponding locale subdirectory, or
- Remove, comment or change the value of the
<base>
tag in the generatedindex.html
file.
I accept all kinds of contributions! However, please review the contribution guidelines before proceeding.
I also accept help writing better contribution guidelines, wink wink.
Thanks goes to these wonderful people (emoji key):
eLeontev 💻 |
Douglas Modena 💡 |
Chirag 💻 |
Aamir Bakhtiar 💻 |
Naz Islam 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!