Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/borjapazr/angular-skeleton

๐Ÿ…ฐ๏ธ๐Ÿฆธ Template to start developing a Progressive Web Application with Angular, Transloco, Angular Universal, SSR/ISR, TailwindCSS, Jest, Cypress, ESLint, Prettier, Husky, etc.
https://github.com/borjapazr/angular-skeleton

angular angular-universal angular14 cypress eslint hacktoberfest husky isr jest prerender prettier pwa seo ssr tailwindcss transloco

Last synced: 3 months ago
JSON representation

๐Ÿ…ฐ๏ธ๐Ÿฆธ Template to start developing a Progressive Web Application with Angular, Transloco, Angular Universal, SSR/ISR, TailwindCSS, Jest, Cypress, ESLint, Prettier, Husky, etc.

Awesome Lists containing this project

README

        


Node.js, Typescript and Express template


Node.js, Typescript and Express template


![GitHub package.json version](https://img.shields.io/github/package-json/v/borjapazr/angular-skeleton?style=flat-square)
![GitHub CI Workflow Status](https://img.shields.io/github/actions/workflow/status/borjapazr/angular-skeleton/ci.yml?branch=main&style=flat-square&logo=github&label=CI)
![GitHub CD Workflow Status](https://img.shields.io/github/actions/workflow/status/borjapazr/angular-skeleton/cd.yml?branch=main&style=flat-square&logo=github&label=CD)
![GitHub LICENSE](https://img.shields.io/github/license/borjapazr/angular-skeleton?style=flat-square)
[![Demo](https://img.shields.io/badge/demo-๐ŸŽฎ-yellow.svg?style=flat-square)](https://angular-skeleton.marsmachine.space/)
[![Documentation](https://img.shields.io/badge/documentation-80%25-orange?style=flat-square)](https://img.shields.io/badge/documentation-80%25-orange?style=flat-square)


๐Ÿ…ฐ๏ธ๐Ÿฆธ Production-ready template for Progressive Web Applications implemented with Angular, TailwindCSS, Transloco, ngx-isr, etc.

โ„น๏ธ About โ€ข
๐Ÿ“‹ Features โ€ข
๐Ÿค Contributing โ€ข
๐Ÿ›ฃ๏ธ Roadmap โ€ข
๐ŸŽฏ Credits โ€ข
๐Ÿšฉ License

---

## โ„น๏ธ About

The main goal of this project is to provide a base template for the generation of a production-ready web application made with `Angular`. The idea is to avoid having to configure all the tools involved in a project every time it is started and thus be able to focus on the definition and implementation of the business logic.

> ๐Ÿ“ฃ This is an opinionated template. The architecture of the code base and the configuration of the different tools used has been based on best practices and personal preferences.

### ๐Ÿš€ Quick start

- Start project in development mode:

```bash
npm run start:dev
```

- Start project in production mode:

```bash
npm run start:prod
```

## ๐Ÿ“‹ Features

- [Angular](https://angular.io/): Angular is a platform for building mobile and desktop web applications.
- [Angular Universal](https://angular.io/guide/universal): Server-side rendering (SSR) with Angular Universal.
- [TailwindCSS](https://tailwindcss.com/): A utility-first CSS framework packed with classes like flex, pt-4, text-center and rotate-90 that can be composed to build any design, directly in your markup.
- [ng-lazyload-image](https://www.npmjs.com/package/ng-lazyload-image): A super small libary for lazy loading images for Angular apps with zero dependencies
- [ngx-isr](https://www.npmjs.com/package/ngx-isr): Incremental Static Regeneration (ISR) enables developers and content editors to use static-generation on a per-page basis, without needing to rebuild the entire site. With ISR, you can retain the benefits of static while scaling to millions of pages.
- i18n using [Transloco](https://ngneat.github.io/transloco/)
- Unit tests using [Jest](https://github.com/facebook/jest)
- e2e tests using [Cypress](https://www.cypress.io/)
- [Spell check](https://github.com/streetsidesoftware/cspell)
- Linting with [ESLint](https://github.com/eslint/eslint)
- Formatting with [Prettier](https://github.com/prettier/prettier)
- [Stylelint](https://stylelint.io/): A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.
- [HTMLHint](https://htmlhint.com/): A linter for HTML that helps you avoid errors and enforce conventions in your HTML.
- Commit messages must meet conventional commits format
- Git hooks with [Husky](https://github.com/typicode/husky) and [lint-staged](https://github.com/okonet/lint-staged)
- Containerised using [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/)
- GitHub Actions
- Makefile as project entrypoint
- A lot of emojis ๐Ÿ›ธ

### ๐Ÿ—‚ Codebase structure

```txt
angular-skeleton/
โ”œโ”€โ”€ .github/
โ”œโ”€โ”€ .husky/
โ”œโ”€โ”€ .vscode/
โ”œโ”€โ”€ cypress/
โ”‚ โ”œโ”€โ”€ e2e/
โ”‚ โ”œโ”€โ”€ fixtures/
โ”‚ โ”œโ”€โ”€ support/
โ”‚ โ”œโ”€โ”€ coverage.webpack.js
โ”‚ โ””โ”€โ”€ tsconfig.json
โ”œโ”€โ”€ docker/
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ app/
โ”‚ โ”‚ โ”œโ”€โ”€ core/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ components/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ constants/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ enums/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ guards/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ handlers/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ interceptors/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ loaders/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ models/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ resolvers/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ services/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ strategies/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ tokens/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ utils/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ...
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ core.module.ts
โ”‚ โ”‚ โ”œโ”€โ”€ features
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ feature-a
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ components/
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ models/
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ pages/
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ services/
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ...
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ home-routing.module.ts
โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ home.module.ts
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ feature-b
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ ...
โ”‚ โ”‚ โ”œโ”€โ”€ shared/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ components/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ directives/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ modules/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ pipes/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ services/
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ shared.module.ts
โ”‚ โ”‚ โ”œโ”€โ”€ app-routing.module.ts
โ”‚ โ”‚ โ”œโ”€โ”€ app.browser.module.ts
โ”‚ โ”‚ โ”œโ”€โ”€ app.component.html
โ”‚ โ”‚ โ”œโ”€โ”€ app.component.scss
โ”‚ โ”‚ โ”œโ”€โ”€ app.component.ts
โ”‚ โ”‚ โ”œโ”€โ”€ app.module.ts
โ”‚ โ”‚ โ””โ”€โ”€ app.server.module.ts
โ”‚ โ”œโ”€โ”€ assets/
โ”‚ โ”‚ โ”œโ”€โ”€ i18n/
โ”‚ โ”‚ โ”œโ”€โ”€ icons/
โ”‚ โ”‚ โ””โ”€โ”€ images/
โ”‚ โ”œโ”€โ”€ environments/
โ”‚ โ”œโ”€โ”€ styles/
โ”‚ โ”‚ โ”œโ”€โ”€ abstracts/
โ”‚ โ”‚ โ”œโ”€โ”€ base/
โ”‚ โ”‚ โ”œโ”€โ”€ components/
โ”‚ โ”‚ โ”œโ”€โ”€ layout/
โ”‚ โ”‚ โ”œโ”€โ”€ vendors/
โ”‚ โ”‚ โ””โ”€โ”€ main.scss
โ”‚ โ”œโ”€โ”€ types/
โ”‚ โ”œโ”€โ”€ favicon.ico
โ”‚ โ”œโ”€โ”€ favicon.png
โ”‚ โ”œโ”€โ”€ index.html
โ”‚ โ”œโ”€โ”€ jest.mocks.ts
โ”‚ โ”œโ”€โ”€ jest.setup.ts
โ”‚ โ”œโ”€โ”€ main.browser.ts
โ”‚ โ”œโ”€โ”€ main.server.ts
โ”‚ โ”œโ”€โ”€ manifest.webmanifest
โ”‚ โ”œโ”€โ”€ polyfills.ts
โ”‚ โ”œโ”€โ”€ robots.txt
โ”‚ โ””โ”€โ”€ styles.scss
โ”œโ”€โ”€ .browserslistrc
โ”œโ”€โ”€ .commitlintrc.js
โ”œโ”€โ”€ .cspell.json
โ”œโ”€โ”€ .czrc
โ”œโ”€โ”€ .dockerignore
โ”œโ”€โ”€ .editorconfig
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ .eslintcache
โ”œโ”€โ”€ .eslintignore
โ”œโ”€โ”€ .eslintrc.js
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .htmlhintrc
โ”œโ”€โ”€ .lintstagedrc.js
โ”œโ”€โ”€ .ncurc.js
โ”œโ”€โ”€ .npmignore
โ”œโ”€โ”€ .prettierignore
โ”œโ”€โ”€ .prettierrc.js
โ”œโ”€โ”€ .stylelintcache
โ”œโ”€โ”€ .stylelintignore
โ”œโ”€โ”€ .tool-versions
โ”œโ”€โ”€ .versionrc.js
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ TODO.md
โ”œโ”€โ”€ angular.json
โ”œโ”€โ”€ cypress.config.ts
โ”œโ”€โ”€ jest.config.js
โ”œโ”€โ”€ ngsw-config.json
โ”œโ”€โ”€ nyc.config.js
โ”œโ”€โ”€ package-lock.json
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ routes.txt
โ”œโ”€โ”€ server.ts
โ”œโ”€โ”€ stylelint.config.js
โ”œโ”€โ”€ tailwind.config.js
โ”œโ”€โ”€ transloco.config.js
โ”œโ”€โ”€ tsconfig.app.json
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ tsconfig.server.json
โ””โ”€โ”€ tsconfig.spec.json
```

### ๐ŸŽ›๏ธ Code style and best practices

> โš ๏ธ This section has yet to be fully documented.

- Prettier
- ESLint
- Stylelint
- HTMLHint
- commitlint

### ๐Ÿ›ข Barrel files

Barrel files are used to organize exports. This significantly reduces the size of the import blocks.

### ๐Ÿž Application layout

> โš ๏ธ This section has yet to be fully documented.

- Flexbox layout
- TailwindCSS
- Dark theme
- Styles (SCSS) folder structure

### ๐ŸŒ Internationalization (i18n)

> โš ๏ธ This section has yet to be fully documented.

- Transloco
- Route language prefixing

### ๐ŸŽ Server Side Rendering (SSR) and Incremental Static Rendering (ISR)

> โš ๏ธ This section has yet to be fully documented.

- Angular Universal
- Domino
- ngx-isr

### ๐Ÿ“‡ Prerendering

> โš ๏ธ This section has yet to be fully documented.

- Angular Universal

### ๐Ÿ“ˆ SEO

> โš ๏ธ This section has yet to be fully documented.

- CustomPageTitleStrategy

### ๐Ÿ”ฐ Progressive Web Application (PWA)

> โš ๏ธ This section has yet to be fully documented.

- Service Worker configuration
- Stale while revalidate strategy
- Offline support

### ๐ŸŒ  Image lazy-loading

> โš ๏ธ This section has yet to be fully documented.

- ng-lazyload-image

### ๐Ÿ’จ Module preloading strategies

> โš ๏ธ This section has yet to be fully documented.

- [NoPreloading](https://angular.io/api/router/NoPreloading) (default)
- [PreloadAllModules](https://angular.io/api/router/PreloadAllModules)
- [CustomRoutePreloadStrategy](src/app/core/strategies/custom-route-preload.strategy.ts)
- [NetworkAwareRoutePreloadingStrategy](src/app/core/strategies/network-aware-route-preload.strategy.ts)
- [HoverPreloadStrategy](https://github.com/mgechev/ngx-hover-preload/blob/master/projects/ngx-hover-preload/src/lib/hover-preload.strategy.ts)
- [QuicklinkStrategy](https://github.com/mgechev/ngx-quicklink/blob/master/src/quicklink-strategy.service.ts)

### ๐Ÿ›ฃ Route reusability

- RouteReuseStrategy

### ๐Ÿ’ Pipes

> โš ๏ธ This section has yet to be fully documented.

### ๐Ÿงช Testing

> โš ๏ธ This section has yet to be fully documented.

#### Unit and integration tests

- Jest
- jest-extended

#### e2e tests

- Cypress

### ๐Ÿ Makefile rules

The main actions on this project are managed using a [Makefile](Makefile) as an entrypoint.

```bash
Usage: make TARGET [ARGUMENTS]

Targets:
build/csr Build csr image
build/ssr Build ssr image
clean/csr Clean CSR application
clean/ssr Clean SSR application
help Show this help
start/csr Start application in Client Side Rendering mode
start/ssr Start application in Server Side Rendering mode
stop/csr Stop application in Client Side Rendering mode
stop/ssr Stop application in Server Side Rendering mode
```

### โšก Scripts

[package.json](package.json) scripts:

```json
...
"scripts": {
"start:dev": "ng serve --configuration development --port 4200 --open",
"start:prod": "ng serve --configuration production --port 4300 --open",
"start:ssr:dev": "ng run angular-skeleton:serve-ssr:development --port 4201 --open",
"start:ssr:prod": "ng run angular-skeleton:serve-ssr:production --port 4301 --open",
"build:dev": "rimraf dist && ng build --configuration development",
"build:prod": "rimraf dist && ng build --configuration production && npm run build:optimize",
"build:ssr:dev": "rimraf dist && ng build --configuration development && ng run angular-skeleton:server:development",
"build:ssr:prod": "rimraf dist && ng build --configuration production && ng run angular-skeleton:server:production && npm run build:optimize",
"build:prerender:dev": "rimraf dist && ng run angular-skeleton:prerender:development",
"build:prerender:prod": "rimraf dist && ng run angular-skeleton:prerender:production && npm run build:optimize",
"build:optimize": "run-s optimize:* && ngsw-config dist/browser ./ngsw-config.json",
"optimize:i18n": "transloco-optimize dist/browser/assets/i18n",
"serve:pwa": "http-server -p 4400 -P http://localhost:4400? dist/browser -o",
"serve:ssr": "node dist/server/main.js",
"i18n:extract": "transloco-keys-manager extract",
"i18n:find": "transloco-keys-manager find",
"check:types": "tsc --pretty --noEmit && tsc --project cypress/tsconfig.json --pretty --noEmit",
"check:format": "prettier --check .",
"check:lint": "eslint . --ext .js,.ts --color",
"check:html": "htmlhint .",
"check:scss": "stylelint 'src/**/*.{css,scss}' --color",
"check:spelling": "cspell --config=.cspell.json \"{README.md,TODO.md,.github/*.md,src/**/*.ts,src/**/*.json}\"",
"check:i18n": "transloco-validator src/assets/i18n/*.json src/assets/i18n/**/*.json",
"check:staged": "lint-staged",
"fix:format": "prettier --check --write --ignore-unknown .",
"fix:lint": "npm run check:lint -- --fix",
"fix:scss": "npm run check:scss -- --fix",
"test": "cross-env NODE_ENV=test jest --verbose --colors --runInBand",
"test:spec": "npm run test -- --testPathPattern=spec",
"test:unit": "npm run test -- --testPathPattern=unit",
"test:int": "npm run test -- --testPathPattern=integration",
"e2e": "ng e2e",
"e2e:run": "ng run angular-skeleton:cypress-run",
"e2e:open": "ng run angular-skeleton:cypress-open",
"e2e:coverage:view": "http-server -p 9004 ./coverage-e2e/lcov-report -o",
"test:watch": "npm run test -- --watch",
"test:coverage": "npm run test -- --coverage --silent",
"test:coverage:view": "http-server -p 9003 ./coverage/lcov-report -o",
"reset-hard": "git clean -dfx && git reset --hard && npm install",
"version": "standard-version -t",
"prepare-release": "run-s reset-hard version",
"commit": "cz",
"update-deps": "npm-check-updates -u",
"prepare": "husky install"
},
...
```

## ๐Ÿค Contributing

Just fork and open a pull request. All contributions are welcome ๐Ÿค—

## ๐Ÿ›ฃ๏ธ Roadmap

Please, check [TODO](TODO.md) for the current roadmap.

## ๐ŸŽฏ Credits

To implement this project I have based myself on many similar projects. There were countless of them and I gave them all a star.

๐Ÿ™ Thank you very much for these wonderful creations.

### โญ Stargazers

[![Stargazers repo roster for @borjapazr/angular-skeleton](https://reporoster.com/stars/borjapazr/angular-skeleton)](https://github.com/borjapazr/angular-skeleton/stargazers)

## ๐Ÿšฉ License

MIT @ [borjapazr](https://bpaz.dev). Please see [License](LICENSE) for more information.