• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Angular Template App with a Router-first architecture

LemonMart LemonMart

LemonMart was implemented with a Route-first approach to designing SPAs.

See Changes section for important or breaking changes made to the project.

Angular Version CircleCI Coverage Status DeepScan grade

devs served lemons served As of December 2020

lemon-mart-login

Get the book & watch the talk

LemontMart has been developed in support of my book Angular for Enterprise-Ready Web Applications. You can get the book at any major bookstore or find the links at http://AngularForEnterprise.com.

Watch the talk on Architecture for Scalable Angular Apps on Pluralsight.

Check out the slides for Architecture for Scalable Angular Apps free at Slides.com.

Check out LocalCast Weather, to learn Angular, Material, RxJS fundemantals using OpenWeatherMap.org APIs, at https://github.com/duluca/local-weather-app.

Build, debug and publish Docker images with npm Scripts for Docker and achieve Blue-Green deployments on AWS Fargate with npm Scripts for AWS.

Router-first Approach

A router-first approach to SPA design will save development teams, large and small, significant waste in duplicative work, and re-architecting of the code base to enable better collaboration or achieve sub-second first meaningful paints in your application.

In order to pull off a router-first implementation, you need to:

  1. Define user roles and a site-map early on,
  2. Design with lazy loading in mind, leveraging router outlets, auxiliary paths and smart link tracking,
  3. Implement a walking-skeleton navigation experience and validate, allowing multiple teams to execute seamlessly,
  4. Design around major data components, using stateless data-driven components using RxJS/BehaviorSubjects,
  5. Be disciplined in sticking to a decoupled component architecture, allowing remixing the UX quickly to respond to changes in requirements without having to re-architect the codebase,
  6. Differentiate between user controls and components to appropriate use binding, resolve and auth guards,
  7. With TypeScript classes, interfaces, enums, validators and pipes maximize code reuse

Design Artifacts

Head over to the Wiki for user roles, site maps, data entity diagrams and user mock ups: https://github.com/duluca/lemon-mart/wiki.

Building Lemon Mart

  • npm run build:prod to build a production optimized version of the app.
  • npm run docker:debug to run tests and build a containerized version of the app.
  • integration.Dockerfile is a multi-stage Dockerfile that can be used to build and test the app in various CI environments in a consistent mannger. The optimized image generated in the last step, can then be deployed to any Docker host, including AWS, Heroku, Vercel and Azure.

Authentication

For demonstration purposes the login screen shows the Authentication Mode of the app. There are three modes:

The current mode can be adjusted in environment.ts. You can see how each mode is implemented in the link source files above.

This is covered in more detail in Angular for Enterprise, 2nd Edition.

Build Configurations

There are 3 build configurations that maps to authentication modes:

  1. Production:

Executing npm run build:prod or npx ng build --configuration production or npx ng build --configuration=production leverages InMemory authentication. Note that the fake credentials are documented on the Login screen.

  1. Firebase:

Executing npx ng build --configuration=firebase leverages Firebase authentication. For this to work, you must setup your own Firebase back-end and create a user in the Firebase console.

  1. Lemon-Mart-Server:

Executing npx ng build --configuration=lemon-mart-server leverages Custom authentication. Note that this is implemented by the example projects Lemon Mart Server, which is detailed below.

Lemon Mart Server

Lemon Mart Server is an easy to learn and use TypeScript Node.js server using Minimal MEAN for Lemon Mart.

In order to run Lemon Mart in a full-stack set up, visit https://github.com/duluca/lemon-mart-server.

Developers

This project is a sample implementation, which contains numerous recipes and design patterns useful to develop an Angular application.

If you'd like to use this project as a starter or a template project for your project, you can get a lot of benefit out of using a pre-configured project. Some the benefits are:

  • Optimized development experience for VS Code
  • Lazy loading feature module configuration
  • A responsive landing, login, and user profile experience
  • Angular Material and Angular Flex Layout configured for UI development
  • npm scripts for style and lint checks, building docker containers, testing, or deploying your app
  • CircleCI configuration for Continuous Integration
  • Pre-wired extensible authentication and authorization module
  • And many more.

Pre-requisites

  • Do NOT install @angular/cli or typescript globally to avoid version mismatch issues across multiple projects.
    • Note: When creating new projects in the future, execute npx @angular/cli new app-name --routing to create a new Angular app with basic routing wired.
    • If you have trouble with this command, try npx -p @angular/cli new app-name --routing
  • To run ng commands from within the project directory, preprend npx to commands, like npx ng build.
  • To continue using ng without having to prepend npx, configure shell autofallback as described here: https://www.npmjs.com/package/npx#shell-auto-fallback.

Adapting the template

  • Fork and clone this repo.
  • Rename the repo on GitHub to match the name of your project.
  • Search and replace references to lemon-mart with your project name and git repo.
  • Remove manager, pos, and inventory folders and references to them from app-routing.module.ts.
  • You may modify profile.component.ts and view-user.component.ts under the user folder to fit your needs.
  • Edit lemonmart-theme.scss to match your desired color scheme.
  • Now you may begin implementing your own feature modules.

During Development

  • Run npm start for a developmenet web server.
  • Navigate to http://localhost:5000/. The app will automatically reload if you change any of the source files.
    • Note that the port is different than the default Angular port of 4200 intentionally, so you can run test projects or proof of concepts side-by-side without the hassle of specifiying a new port.
  • Run npm test to execute the unit tests via Karma.
  • Run npm run e2e to execute the end-to-end tests via Protractor.

Code scaffolding

  • Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Further help with Angular CLI

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

Full-Stack Setup with Docker Compose and Deploying to AWS

See the example project here https://github.com/duluca/lemon-mart-server

Changes

Changes are inevitable to keep the project up-to-date with libraries, tools, patterns and practices. Below are some notable changes that differ from the 1st and 2nd edition of my book.

Angular 12 configuration changes

  • Enabled bundle budgets
  • Introduction development configuration
  • Made production configuration the default one
  • Added npm run watch command
  • Strict settings on by default
  • When using mat-table the [dataSource] property should NOT be set using an async pipe. Correct use is [dataSource]="items$". See user-table.component.html.
  • Use of FormGroupName in profile.component.html

Renamed master branch to main

If you already have a master branch locally, then execute the following commands:

git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a

Augury

More Repositories

1

local-weather-app

Learn Angular, Material, RxJS fundemantals using OpenWeatherMap.org APIs
TypeScript
102
star
2

minimal-mean

Easy to learn and use full-stack MEAN implementation using TypeScript & Angular
TypeScript
65
star
3

web-dev-environment-setup

Scripts for Windows 10 and macOS X to install web development tools
PowerShell
43
star
4

angular1.5-starter

A batteries-included Mobile-First Angular 1.5+ and Angular Material Seed Project
JavaScript
18
star
5

minimal-mongo

Dockerfile and scripts to setup a production ready Mongo container
Shell
16
star
6

lemon-mart-server

Node.js server using Minimal MEAN for LemonMart
TypeScript
12
star
7

minimal-node-web-server

Containerized Express Node Web Server -- Perfect for cheap hosting on AWS ECS, Digital Ocean, now.sh
JavaScript
11
star
8

OneApi

The "One Api" Example Project for your .NET Back-end Enterprise Projects, Mobile & Web Clients
C#
8
star
9

angular-for-enterprise-ready-web-apps

Supplemental Scripts and Code for Angular for Enterprise Ready Web Apps
TypeScript
8
star
10

dev-norms

A sensible starter list of team norms and PR template for development teams
JavaScript
5
star
11

document-ts

A very thin TypeScript-based async MongoDB helper with optional ODM convenience features
TypeScript
5
star
12

angular-unit-test-helper

Helper functions to help write unit tests in Angular using mocks and spies
TypeScript
4
star
13

lemon-mart-swagger-server

Mock Swagger Server for Lemon Mart
JavaScript
3
star
14

angular4-material2-starter

A batteries-included Mobile-First Angular 4+ and Angular Material 2 Seed Project
TypeScript
3
star
15

ng6-material-auth-app-starter

Angular 6 Starter with Material and Auth UX
TypeScript
2
star
16

duluca.github.io

Doguhan Uluca
2
star
17

babel-camo-test

A proof of concept app, showing async/await support with Babel working with Camo
JavaScript
2
star
18

angular-starter

Use Angular 1.4 + New Router + Browserfiy + Gulp to serve single js file (including html)
JavaScript
2
star
19

fake-jwt-sign

A basic JWT sign method, meant for browser-side testing and dummy implementations
JavaScript
1
star
20

angular-build-env

Angular CLI and Docker multi-stage compatible Alpine Node Build Environment
1
star
21

node-test-spies-mocking-demo

Demo for Spies and mocking with Node test runner (node:test) post
JavaScript
1
star
22

init-dev-env

Automatically create .env files from a template file
JavaScript
1
star
23

hapi-web-server

Route and controller definitions to use Hapi.JS to serve content (html, css, js, images, etc) over the web.
JavaScript
1
star
24

react15-starter

A starter Single Page Application (SPA) project for using React with Redux and Router
HTML
1
star