Skip to content

Full stack GraphQL web application that implements basic features of 9GAG. Built w/ TypeScript, Next.js, Apollo Server, Apollo Client, PostgreSQL

Notifications You must be signed in to change notification settings

onderonur/post-gallery

Repository files navigation

Post Gallery

Post Gallery is a fullstack GraphQL web application which started as a basic 9GAG clone. It implements the core features of 9GAG like creating posts, commenting and reactions. All the requests are handled by a GraphQL server built with Apollo. Only file uploads and authentication are excluded from GraphQL and implemented as simple REST endpoints.

It has no custom server setup. Only the serverless functions of Next.js are used. This has resulted in a very simple, yet powerful structure.

The project has changed a lot along the way. Trials were carried out with different ORMs like Sequelize, TypeORM, Prisma 2 and Objection/Knex. API and frontend were two separate projects at first, but they were combined after a while as an experiment. Even though it's much cleaner to create separate projects for various reasons, this structure also works pretty well.

It also has the settings for generating all the typings and custom @apollo/client hooks with graphql-code-generator based on the GraphQL schema. When this is used with VSCode Apollo extension which has features like autocompletion and showing warnings/errors based on the schema, it was just so easy to write all the queries/mutations/fragments.

You can find a list of recommended extensions in .vscode/extensions.json.

Features

  • Creating posts
  • Category based post listing
  • Comments (with linkifying URLs)
  • Reactions
  • Social logins (with Google and Facebook)
  • Linking social accounts to a single account
  • Simple session management
  • Social media share buttons
  • Basic SEO optimization
  • CSRF protection
  • GraphQL Query Depth Limit
  • Rate Limiter

Stack

Screenshots

Posts feed page

Post viewing page

Creating post

Session management page

Development

First, we need to install our dependencies:

npm install

After that, we need to set a value to all the empty keys (DB_HOST, DB_USER, DB_PASSWORD etc) in .env file. Then, we create a database named post_gallery in PostgreSQL. Lastly, we run the migrations:

npm run migrate:latest

When the migrations end, we can start the application in development mode with:

npm run dev

Application will start on http://localhost:3000.
GraphQL Playground is on http://localhost:3000/api/graphql.

Migrations

To create a new migration run:

npm run migrate:make -- <YOUR_MIGRATION_NAME>

After that, add your changes to the created migration file and run:

npm run migrate:latest

About

Full stack GraphQL web application that implements basic features of 9GAG. Built w/ TypeScript, Next.js, Apollo Server, Apollo Client, PostgreSQL

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages