GithubHelp home page GithubHelp logo

sanogotech / zennestjsprimagraphqlstarter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zensoftware/zen

0.0 1.0 0.0 25.49 MB

โ›ฉ Nest + Prisma + Angular ๐Ÿฎ Full Stack GraphQL Starter Kit โ›ฉ

Shell 0.09% JavaScript 4.35% PowerShell 0.38% TypeScript 75.43% HTML 8.15% Handlebars 5.65% Dockerfile 0.11% SCSS 5.83%
angular graphql nestjs prisma typescript

zennestjsprimagraphqlstarter's Introduction

โ›ฉ Zen โ›ฉ

Nest + Prisma + Angular ๐Ÿฎ Full Stack GraphQL Starter Kit


๐Ÿฏ Project Founder's Notes

What is really nice about Nest and Angular is that their programming idioms carry over seamlessly between the two, allowing for front-end devs to contribute to the back-end. Though, there are complexities in creating the GraphQL endpoint that exposes the various CRUD operations over the Prisma data model on the back-end. A combination between Nest + Prisma + Angular has provided for new capabilities that the industry has not really seen before. This project code generates all the boilerplate required in bridging these 3 technologies together.

There is a tremendous amount of value to be gained by treating the schema.prisma file as the single source of truth, and then code generating everything else from that. It guarantees consistency between the front-end and back-end. It also centralizes the CRUD operations over all the Prisma models via a single import endpoint.

This project also provides solutions for the hardest parts of user authentication as well. I have strictly kept to the Angular and Nest best practices that are being utilized within the ecosystem. This project is an attempt to package the sum total of all the lessons I have learned, and making it publicly available to the community. All the services being generated should be fairly self explanatory, and lots of useful NPM scripts have been provided for the various stages of development to deployment. Better documentation will come with time. ๐Ÿœ

New contributors are welcome!

๐ŸŽ "Give more than you take" ~ Peter Hoang


๐Ÿฃ Project Setup Instructions - GitHub Repo

Requirements

# Project setup steps
git clone https://github.com/ZenSoftware/zen.git --depth=1
cd zen
cp .env.example .env
npm i
docker-compose up -d
npm run prisma:migrate
# Start the Nest API
npm run start:api

# Start the Angular site at localhost:4200
npm start
# Reload Apollo VSCode extension via command palette
>Apollo: Reload schema

๐Ÿฅข GraphQL Features

  • Nest GraphQL resolvers as a gateway to Prisma Client.
  • Apollo GraphQL SDL bindings to Prisma generated via Pal.js CLI! Thank you @AhmedElywa ๐ŸŽŽ
  • PrismaSelect to solve the GraphQL N+1 problem for all queries for free.
  • Custom npm scripts to code generate the Nest GraphQL gateway on Prisma schema changes.
  • Code generation of apollo-angular services to enable simple, type safe access to the GraphQL API within Angular. ๐ŸŽ€ Modern dev tooling configured for the project, allowing for Apollo extension for VS Code to provide auto-completion within gql tags for all .ts files.
  • An Angular GraphQLModule to simplify the configuration of the ApolloClient to enable/disable the varying ApolloLink features.
    • HttpBatchLink for batching several GraphQL requests that occur within a short debounce interval. This really helps to alleviate network congestion.
    • UploadLink to give ApolloClient HTTP multi-part form requests capabilities. Enabling the uploading of files via GraphQLUpload.
    • GraphQLWsLink for GraphQL subscriptions over websockets.

๐Ÿฑ API Authentication, Performance & Scaling

  • Nest authentication, user registration, and login system designed specifically to work for an Angular SPA (single page application). This project provides responsive, "mobile first" interfaces for the standard set of authentication features.
  • New account component
  • Login component with remember me option.
  • Sign in with Google via OpenID Connect.
  • Forgot password component and full password reset flow.
  • Password change component for user dashboards.
  • Angular route guards and Angular directives to show/hide content depending on user's roles.
  • Nest authorization directives for both RBAC & ABAC authorization schemes. ABAC is the default authorization scheme and is implemented with @casl/prisma & @casl/angular. All @casl/prisma subjects are code generated for you. The user's Casl rules are sent from the server to the client and updates the @casl/angular ability. This unifies the permissions across both the server and the client, fully exploiting Casl's isomorphic capabilities.

๐Ÿต Modern Web Components and Responsive UIs

  • SASS chosen as the CSS transpiler of choice.
  • Angular Material components & theme.
  • Mobile first approach to build the framework's core components (login form, etc).
  • Directly import Bootstrap reset, utilities, & grid features through SCSS imports, and exclude the Bootstrap theme and conflicting component styles. These features are missing from Angular Material, and greatly simplify the creation of responsive, mobile first applications.
  • Bootswatch SCSS variables integrated for a large assortment of high quality color themes to choose from.

๐ŸŽ Optional Tech Integrations

  • Electron branch with new npm script npm run start:electron to launch the app within Electron.
  • Capacitor branch - planned
  • Kendo UI branch - which includes @zen/grid. <zen-grid> renders robust and reliable data grids over all of the Prisma models within the project, with minimal configuration needed.
  • OpenTelemetry branch demonstrates how to integrate and expose telemetry data for the API server.

๐Ÿก Developer Operations

  • Nx for project management to allow for the use of Nx Console extensions for VSCode. Nx Console is a GUI interface for monorepos that adds a lot of modern developer conveniences. It also helps to simplify the use of the various Angular & Nest code generation schematics available in the ecosystem.
  • Strict typings with Typescript for everything. Even the code generation tools are written in Typescript.
  • Angular Language Service for VSCode for modern IDE tooling.
  • NPM scripts for versioned releases of the Nest api server as a containerized Docker image. node:16-alpine is used as the Docker container base image, and the appropriate tsconfig.app.json configurations are being applied for the Nest app.
  • Example Kubernetes deployment scripts.
  • Enforced code formatting via Prettier & import-sort, guaranteeing all contributions to the project are standardized with predictable structure, and clear legibility.
  • Commitizen for standardizing git commits.
  • @nestjs-modules/mailer for automated emailing, and pre-configured Handlebars e-mail templates for the various web portal's emailing needs. Handlebars has similar double bracket {{contextField}} template interpolation, akin to Angular templates. Custom HTML e-mail triggers within Nest are made very simple by simply passing a JSON context and the template's file name as parameters to the class injectable MailService.
  • Compodoc to generate Nest & Angular documentation.

zennestjsprimagraphqlstarter's People

Contributors

github-actions[bot] avatar zensoftware avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.