• Stars
    star
    290
  • Rank 142,981 (Top 3 %)
  • Language
    Elixir
  • License
    MIT License
  • Created over 5 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

A basic social media application to demonstrate Elixir + Phoenix + GraphQL + React + Apollo

CircleCI

Socializer

Socializer is a basic social media web application to demonstrate Elixir + Phoenix + GraphQL + React + Apollo. I also wrote an extensive blog post about building the application which you can read here.

Architecture

The backend is built on Elixir and Phoenix and exposes a GraphQL endpoint.

The client is bootstrapped with create-react-app. It uses React, React Router, and Apollo to query the Elixir GraphQL endpoint. It also uses server-side rendering (configuration largely lifted from cra-ssr).

Disclaimer

This is a toy app that I built to try out some technologies I found interesting. It is not suitable to be used in the real world -- for example, every user can message every other user without any limitations, which would obviously be ripe for spam and abuse.

Setup

Backend (GraphQL server powered by Phoenix)

  1. Install Elixir via the means of your choice (official docs).

  2. Install dependencies with mix deps.get

  3. Create and migrate the database with mix ecto.setup

  4. Start Phoenix GraphQL endpoint with mix phx.server

The backend does not serve any HTML; it's just a GraphQL endpoint that is consumed by the client. You can also visit localhost:4000/graphiql for the interactive GraphiQL interface where you can write and test out GraphQL queries against the backend.

Client

  1. Install node.js and yarn

  2. Install client dependencies: yarn install

  3. Start the development server: yarn start. (Also ensure the Phoenix server is running -- see above)

  4. Open localhost:3000 in your browser and you should see the application. It will automatically reload as you save changes to files.

Procfile

The codebase also has a Procfile.dev which will run both the Elixir backend and the React frontend in development -- you can run it with foreman -f Procfile.dev.

Deployment

A live demo is deployed to https://socializer-demo.herokuapp.com/; the database is reset every night. I've also exposed the GraphiQL interface on Gigalixir here if you want to play around with some queries. (You should not expose GraphiQL on a real production app.)

Backend

See the Phoenix docs for guidance on deploying a Phoenix app.

For the demo, the backend Phoenix/GraphQL app is running on Gigalixir.

To deploy to your own Gigalixir account, follow these steps:

  1. Install the Gigalixir CLI (if you don't have it already)

  2. If you don't already have a Gigalixir app set up, create one: gigalixir create.

  3. Create a free Postgres instance linked to your app: gigalixir pg:create --free

  4. Deploy: git push gigalixir master

  5. Run the database migrations (if this is the first deploy): gigalixir run mix ecto.migrate.

Client

  1. Create a production build: yarn build

  2. Start the SSR node server: yarn serve. This reads from the production build and serves fully hydrated HTML for each route.

For the demo, the client express server is running on Heroku. It is built and released as a Docker image.

To deploy to your own Heroku account, follow these steps:

  1. Install the Heroku CLI (if you don't have it already)

  2. cd client

  3. Log into the Heroku container service: heroku container:login

  4. If you don't already have a Heroku app set up, create one: heroku create

  5. Build the image and push to the container registry: heroku container:push web

  6. Release the image: heroku container:release web

You can also deploy the built Docker image to any other Docker hosting service of your choice.

More Repositories

1

gitreports.com

Git Reports is a free service that lets you set up a stable URL for anonymous users to submit bugs and other Issues to your GitHub repositories.
Ruby
134
star
2

sitemap-webpack-plugin

Webpack plugin to generate a sitemap.
TypeScript
73
star
3

action-cable-react

Use Rails 5 ActionCable channels with React for realtime magic.
CoffeeScript
51
star
4

eqn

A gem to evaluate mathematical equations.
Ruby
35
star
5

actioncable-modules

Fork of ActionCable client patched for proper module support
CoffeeScript
11
star
6

CircuitSimulator

An event-driven circuit simulator, written in C++ and designed to print to terminal output.
C++
8
star
7

react-bootstrap-maskedinput

react-maskedinput form element that works with react-bootstrap
JavaScript
7
star
8

RedditPoster

A Reddit bot to make scheduled subreddit posts, implemented in Ruby.
Ruby
5
star
9

debatevid.io

DebateVid.io is a centralized repository for parliamentary, policy, and Lincoln-Douglas debate videos.
JavaScript
5
star
10

rspec-blog-example

Rails blog application to show example code for my series on writing tests in rspec
Ruby
5
star
11

nginx-fancyindex-console

Old-school console theme for Nginx fancyindex.
JavaScript
3
star
12

react-coffee-and-friends

A highly opinionated starter kit for a standalone React frontend.
CoffeeScript
3
star
13

fluxxor-rails

Fluxxor is a set of Flux architecture tools for React. This gem makes it available for the Rails asset pipeline.
Ruby
3
star
14

action-cable-react-example-server

Example server application for action-cable-react
Ruby
2
star
15

coffee-relay

Handle Relay.QL fragments in CoffeeScript.
JavaScript
2
star
16

react-testing

Examples of various approaches and libraries for testing React applications. Written for a July 2019 talk at the Cleveland React meetup.
JavaScript
2
star
17

coffee-import

Transpile ES6 imports in CoffeeScript files.
JavaScript
2
star
18

SimpleCraft

Toy version of Minecraft written in three.js for SIU CS485 Computer Graphics, Spring 2015.
CoffeeScript
2
star
19

cap_rails

Execute Capistrano deployments and tasks for Rails projects within Sublime Text.
Python
1
star
20

react-testing-library-talk

Examples of various testing patterns with React Testing Library.
JavaScript
1
star
21

action-cable-react-example-client

Example client application for action-cable-react
JavaScript
1
star
22

skyjo

Web version of the Skyjo card game
Ruby
1
star
23

ruby-2.6-functional-examples

Ruby
1
star
24

schneider.dev

Personal website and blog
JavaScript
1
star
25

action-cable-react-example-coffee

Example client application for action-cable-react - with 100% more CoffeeScript
CoffeeScript
1
star
26

lerna-rollup-watch

Reproduction example for using lerna + rollup -w
JavaScript
1
star
27

coffee-import-loader

Webpack loader to transpile ES6 imports in CoffeeScript files
JavaScript
1
star