All Projects → MatthieuSegret → Yummy Phoenix Graphql

MatthieuSegret / Yummy Phoenix Graphql

Cooking recipe sharing app built with Phoenix, React, GraphQL and Kubernetes

Programming Languages

javascript
184084 projects - #8 most used programming language
elixir
2628 projects

Projects that are alternatives of or similar to Yummy Phoenix Graphql

Graphql Rails Blog
Blog App built with Rails 5, React and GraphQL
Stars: ✭ 160 (+42.86%)
Mutual labels:  graphql, starter-kit
Graphql Starter
💥 Monorepo template (seed project) pre-configured with GraphQL API, PostgreSQL, React, Relay, and Material UI.
Stars: ✭ 3,377 (+2915.18%)
Mutual labels:  graphql, starter-kit
Express Graphql Typescript Boilerplate
A starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch
Stars: ✭ 163 (+45.54%)
Mutual labels:  graphql, starter-kit
Project Webcube
Continuously updated JS infrastructure for modern web dev
Stars: ✭ 141 (+25.89%)
Mutual labels:  graphql, starter-kit
K2
Koa2 API template with passport, GraphQL, flowtype, knex and more.
Stars: ✭ 44 (-60.71%)
Mutual labels:  graphql, starter-kit
Captain Fact Api
🔎 CaptainFact - API. The one that serves and process all the data for https://captainfact.io
Stars: ✭ 145 (+29.46%)
Mutual labels:  graphql, phoenix
react-phoenix-users-boilerplate
Elixir/Phoenix + React + users template/boilerplate.
Stars: ✭ 71 (-36.61%)
Mutual labels:  phoenix, starter-kit
Absinthe plug
Plug support for Absinthe, the GraphQL toolkit for Elixir
Stars: ✭ 209 (+86.61%)
Mutual labels:  graphql, phoenix
Niklick
Rails Versioned API solution template for hipsters! (Ruby, Ruby on Rails, REST API, GraphQL, Docker, RSpec, Devise, Postgress DB)
Stars: ✭ 39 (-65.18%)
Mutual labels:  graphql, starter-kit
Firebase Gcp Examples
🔥 Firebase app architectures, languages, tools & some GCP things! React w Next.js, Svelte w Sapper, Cloud Functions, Cloud Run.
Stars: ✭ 470 (+319.64%)
Mutual labels:  graphql, google-cloud-platform
Subzero Starter Kit
Starter Kit and tooling for authoring GraphQL/REST API backends with subZero
Stars: ✭ 136 (+21.43%)
Mutual labels:  graphql, starter-kit
Phoenix react playground
An example setup for a Phoenix+React project with sensible defaults.
Stars: ✭ 80 (-28.57%)
Mutual labels:  starter-kit, phoenix
Gatsby Blog Starter Kit
A simple starter kit for a static blog created with Gatsby
Stars: ✭ 131 (+16.96%)
Mutual labels:  graphql, starter-kit
Reactql
Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
Stars: ✭ 1,833 (+1536.61%)
Mutual labels:  graphql, starter-kit
React Starter Kit
React Starter Kit — front-end starter kit using React, Relay, GraphQL, and JAM stack architecture
Stars: ✭ 21,060 (+18703.57%)
Mutual labels:  graphql, starter-kit
Wertik Js
💪 A library that powers your app with GraphQL + Rest API
Stars: ✭ 56 (-50%)
Mutual labels:  graphql, starter-kit
Meteor Apollo Starter Kit
Meteor, Apollo, React, PWA, Styled-Components boilerplate
Stars: ✭ 91 (-18.75%)
Mutual labels:  graphql, starter-kit
Persianjsonplaceholder
Persian fake REST/GraphQL API for testing and prototyping.
Stars: ✭ 110 (-1.79%)
Mutual labels:  graphql
Next
Directus is a real-time API and App dashboard for managing SQL database content. 🐰
Stars: ✭ 111 (-0.89%)
Mutual labels:  graphql
Action policy Graphql
Action Policy integration for GraphQL
Stars: ✭ 110 (-1.79%)
Mutual labels:  graphql

Yummy Phoenix GraphQL

Build Status

This application can be used as starter kit if you want to get started building an app with Phoenix, React, and GraphQL. This is a simple cooking recipe sharing application using ordinary features which can be found in most web applications.

Technologies

Frontend

  • TypeScript - A superset of JavaScript that compiles to clean JavaScript output.
  • React - A JavaScript library for building user interfaces. It introduces many great concepts, such as, Virtual DOM, Data flow, etc.
  • Webpack 4 - A bundler for javascript and friends. Packs many modules into a few bundled assets.
  • Bulma - Bulma is a modern CSS framework based on Flexbox
  • Apollo 2 - A flexible, fully-featured GraphQL client for every platform.
  • React Final Form - High performance subscription-based form state management for React.

Backend

  • Elixir 1.6
  • Phoenix 1.3
  • Erlang 20.3
  • Absinthe - The GraphQL toolkit for Elixir.
  • Graphiql - Graphiql is an in-browser IDE for exploring GraphQL.
  • Arc - Flexible file upload and attachment library for Elixir.
  • ExAws - A flexible, easy to use set of clients AWS APIs for Elixir. Use to store attachments in Amazon S3.
  • PostgreSQL for database.

Features

  • CRUD (create / read / update / delete) on recipes
  • Creating comments on recipe page
  • Pagination on recipes listing
  • Searching on recipes
  • Authentication with token
  • Creating user account
  • Update user profile and changing password
  • Confirm user account with a code sends by email
  • Display comments and recipes in real-time
  • Application ready for production

GraphQL Using

  • Queries et mutations
  • FetchMore for pagination
  • Using apollo-cache-inmemory
  • Apollo Link (dedup, onError, auth)
  • Subscription
  • Managing local state with Apollo Link
  • Optimistic UI
  • Static GraphQL queries
  • Validation management and integration with Final Form
  • Authentication and authorizations
  • Protect queries and mutations on GraphQL API
  • Batching of SQL queries backend side

Prerequisites

Getting Started

  • Checkout the yummy git tree from Github

        $ git clone https://github.com/MatthieuSegret/yummy-phoenix-graphql.git
        $ cd yummy-phoenix-graphql
        yummy-phoenix-graphql$
    
  • Install dependencies :

        yummy-phoenix-graphql$ mix deps.get
    
  • Create and migrate your database :

        yummy-phoenix-graphql$ mix ecto.create && mix ecto.migrate
    
  • Load sample records:

        yummy-phoenix-graphql$ mix run priv/repo/seeds.exs
    
  • Start Phoenix endpoint

        yummy-phoenix-graphql$ mix phx.server
    
  • Run npm to install javascript package in other terminal:

        yummy-phoenix-graphql$ cd client
        yummy-phoenix-graphql/client$ npm install
    
  • Start client in development mode. You should be able to go to http://localhost:3000 :

          yummy-phoenix-graphql/client$ npm start
    

Testing

Integration tests with Wallaby and ChromeDriver. Instructions:

  1. Install ChromeDriver
  2. Install FakeS3 with gem install fakes3. Fake S3 simulate Amazon S3. It minimize runtime dependencies and be more of a development tool to test S3 calls.
  3. Run FakeS3 in a new terminal window with fakes3 -r $HOME/.s3bucket -p 4567
  4. Build frontend with API_HOST=localhost:4000 npm run build
  5. Start frontend test server npm run test.server
  6. Run tests with mix test

Production with Kubernetes

This example explains how to deploy the application on Google Kubernetes Engine.

Preparing environment

  1. Create account on Google Cloud and create the project yummy-phoenix-graphql
  2. Install gcloud
  3. Initialize gcloud with gcloud init
  4. Install kubectl with gcloud : gcloud components install kubectl
  5. Install jq to parse json in command-line : https://stedolan.github.io/jq
  6. Install only the Helm client (helm) : https://docs.helm.sh/using_helm/#installing-helm
  7. Set execute permissions on scripts chmod +x kubernetes/script/*

Preparing for the istio installation

  1. Move to kubernetes/istio/charts : cd kubernetes/istio/charts
  2. You can run the following command to download and extract the latest release automatically : curl -L https://git.io/getLatestIstio | sh -
  3. Move to istio-1.x.y, for example : cd istio-1.0.2
  4. Add the istioctl client to your PATH with : printf "export PATH=%s:\$PATH\n" $PWD/bin >> ~/.bashrc && source ~/.bashrc (or .zshrc, .bash_profile)
  5. Check istio version : istioctl version
  6. Back to root path of the project cd <root-project>

Building and pushing docker images to Google Container Registry

  1. Install Docker
  2. Read Quickstart for Google Container Registry
  3. Login to docker registry gcloud auth configure-docker
  4. Build frontend image : docker build -t gcr.io/yummy-phoenix-graphql/frontend:latest -f dockerfiles/frontend.dockerfile .
  5. Build api backend image : docker build -t gcr.io/yummy-phoenix-graphql/api:latest -f dockerfiles/api.dockerfile .
  6. Push images to registry : docker push gcr.io/yummy-phoenix-graphql/frontend:latest && docker push gcr.io/yummy-phoenix-graphql/api:latest

Creating Kubernetes cluster

  1. Create account on Sendgrid to send emails
  2. Create account on AWS S3 to upload images
  3. Set environement variables :
export SENDGRID_API_KEY=<your-sendgrid-api-key>
export S3_KEY=<your-s3-key>
export S3_SECRET=<your-s3-secret>
export S3_BUCKET=<your-s3-bucket>
  1. Create cluster with ./kubernetes/script/create-cluster.sh

Upgrading yummy chart

You can edit or append to the existing customized values and templates, then apply the changes with :

helm upgrade yummy ./kubernetes/yummy

Querying Metrics from Prometheus

  1. Verify that the prometheus service is running in your cluster:
kubectl -n istio-system get svc prometheus
  1. In Kubernetes environments, execute the following command:
$ kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=prometheus -o jsonpath='{.items[0].metadata.name}') 9090:9090 &
  1. To open the Prometheus UI, visit http://localhost:9090/graph in your web browser.

Visualizing Metrics with Grafana

  1. Verify that the prometheus service is running in your cluster:
kubectl -n istio-system get svc prometheus
  1. Verify that the Grafana service is running in your cluster:
kubectl -n istio-system get svc grafana
  1. In Kubernetes environments, execute the following command:
$ kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') 3001:3000 &
  1. To open the Grafana UI, visit http://localhost:3001 in your web browser. Username and password is admin. You can change the password.
Resources dashboard

Clean up

To avoid incurring charges to your Google Cloud Platform account for the resources used, delete cluster with :

$ ./kubernetes/script/destroy-cluster.sh

Next step

  • [ ] Setup k8s_traffic_plug : Traffic endpoint and graceful shutdown for Elixir Plug apps
  • [ ] Migrate from S3 to Google CDN
  • [ ] Connect Erlang nodes between them on Kubernetes cluster with Libcluster
  • [ ] Migrate frontend from TypeScript to ReasonML

Screens

Listing recipes

Listing recipes

Editing recipe

Editing recipe

Recipe page

Recipe page

Account confirmation

Account confirmation

License

MIT © Matthieu Segret

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].