Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karanpratapsingh/fullstack-starterkit
GraphQL first full-stack starter kit with Node, React. Powered by TypeScript
https://github.com/karanpratapsingh/fullstack-starterkit
architecture graphql javascript react typescript
Last synced: about 11 hours ago
JSON representation
GraphQL first full-stack starter kit with Node, React. Powered by TypeScript
- Host: GitHub
- URL: https://github.com/karanpratapsingh/fullstack-starterkit
- Owner: karanpratapsingh
- License: mit
- Created: 2020-06-27T07:12:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-07T12:11:32.000Z (about 3 years ago)
- Last Synced: 2025-01-15T05:58:09.892Z (7 days ago)
- Topics: architecture, graphql, javascript, react, typescript
- Language: TypeScript
- Homepage:
- Size: 2.52 MB
- Stars: 1,176
- Watchers: 38
- Forks: 101
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![fullstack-starterkit](https://user-images.githubusercontent.com/29705703/86912939-7b0e7e00-c13b-11ea-950b-200a4529ae6b.png)
### Motivation :star:
Setting up boiler plates when starting new projects is tedious sometimes and I often found myself setting it up from scratch ๐ฅฑ
Hence I made this starterkit following some of the best patterns and practices I learnt from some of the larger codebase and fantastic developers I've had a chance to work with ๐
The main purpose of this repository is to provide a scalable "batteries included" full stack starterkit which follows good architecture patterns (might be opinionated) and code decoupling which becomes significant as the project grows or new developers are onboarded
#### Features
- **All in Typescript**
Because TypeScript is awesome, and types are important ๐- **GraphQL First**
This starterkit is built with graphql first approach using the [Apollo](https://www.apollographql.com/) platform- **Includes CI**
CI is integral part of any project. This starterkit includes `Github Actions` by default. PR's for integration with any other providers are welcome ๐- **Docker Support**
You can also use docker to develop and run your applications- **Testing Focused**
This project uses [Jest](https://jestjs.io/) for testing framework and comes with sample tests which are easy to extend
- **Prisma**
[Prisma](https://www.prisma.io/) is the ORM being used for [PostgreSQL](https://www.postgresql.org/). Feel free to submit a PR for any other ORM or drivers you'd like to see here ๐- **PWA Support**
This starterkit comes with out of the box PWA support**Please leave a :star: as motivation if you liked the idea :smile:**
### :rocket: Technologies Used
### ๐ Contents
- [Architecture](#architecture)
- [Backend](#backend)
- [Web](#web)
- [Getting started](#getting-started)
- [How to Contribute](#how-to-contribute)
- [License](#license)### Video Overview
Here's a brief video overview of this project, hope it helps.
[![Full Stack Starterkit Overview](http://img.youtube.com/vi/TgtUhEnW8O4/0.jpg)](http://www.youtube.com/watch?v=TgtUhEnW8O4 "Full Stack Starterkit Overview")
Big thanks to [@mikestaub](https://twitter.com/mikestaub) for mentoring me on the lot of the ideas you will come across in this repository. Checkout how he's changing social media with [Peapods](https://peapods.com)
### ๐ญ Architecture
#### Backend
Here is the folder structure for `backend`, it is using `yarn workspaces` which helps us split our monorepo into packages such as DB, GraphQL. Which if required can be made into their own micro services.
```
backend
โโโ build
โโโ config
โโโ logs
โโโ packages
โ โโโ db
โ โ โโโprisma
โ โโโ graphql
โ โ โโโ api
โ โ โโโ schema
โ โ โโโ types
โ โโโ utils
โโโ tests
โ โโโ db
โ โโโ graphql
โโโ index.ts
โโโ package.json
```##### DB
This workspace package contains the database abstractions. The database stack is [PostgreSQL](https://www.postgresql.org/) as relational database and [Prisma](https://www.prisma.io/) as an ORM, read more about DB package [here](./backend/packages/db/README.md)
##### GraphQL
The GraphQL package is organized as below:
```
graphql
โโโ schema
โ โโโ user <---- some entity
โ โโโ resolvers
โ โ โโโ types <---- type resolvers
โ โ โโโ queries <---- query resolvers
โ โ โโโ mutations <---- mutation resolvers
โ โโโ queries.graphql
โ โโโ mutations.graphql
โ โโโ types.graphql
โโโ api
โ โโโ queries
โ โโโ mutations
โโโ types <---- graphql types
โ โโโ schema
โ โโโ resolvers
โโโ index.json
```The schema splits each entity into it's own set of schema to modularize the codebase. The graphql package uses [schema stitching](https://www.apollographql.com/docs/apollo-server/features/schema-stitching) and [code generators](https://graphql-code-generator.com/) to construct the whole schema.
It is organized so because if you choose to split graphql into it's own set of microservices later, it should be relatively easier to do so as this should be easy to integrate with [Apollo Federation](https://www.apollographql.com/docs/apollo-server/federation/introduction)
Read more about GraphQL package [here](./backend/packages/graphql/README.md)
#### Web
Here is the folder structure for `web`, it is a standard [create-react-app](https://create-react-app.dev/) using [craco](https://github.com/gsoft-inc/craco) to override configs without ejectingWeb package uses [Material UI](https://material-ui.com/) heavily as it makes theming and customization very easy. PR's for any other UI kit are welcome ๐
```
web
โโโ build
โโโ public
โโโ src
โ โโโ assets
โ โโโ config
โ โโโ constants
โ โโโ global
โ โโโ tests
โ โโโ layout <---- controls, pure components
โ โโโ theme <---- theme config
โ โโโ graphql
โ โ โโโ operations.tsx <---- generated graphql operations and types
โ โโโ pages
โ โ โโโ Home <---- page component
โ โ โโโ components <---- page specific components
โ โ โโโ hooks <---- page specific custom hooks
โ โโโ utils
โโโ tests
โ โโโ db
โ โโโ graphql
โโโ index.ts
โโโ package.json
```### ๐ Getting Started
**Setting up environment variables**
Before getting started, create `.env` files at both `backend/.env` as well as `web/.env` following the `.env.template` files located in those directories.
**Install dependencies**
I recommend using `yarn` instead of `npm` as this project heavily uses `yarn workspaces`
Install [volta](https://docs.volta.sh/guide/getting-started), which should automatically install correct `node` and `yarn` version when you checkout the repository (check the root package.json for config)
```
yarn
```To install dependencies for `web` and `backend` automatically, a postinstall script has been added in the main `package.json`
**Running web**
- Docker (recommended)
```
$ cd web
$ yarn dev
```Once you're done working, use `yarn dev:down` command to stop the docker containers.
- Locally
```
$ cd web
$ yarn start:web
```**Running backend**
- Docker (recommended)
```
$ cd backend
$ yarn dev
```Once the container starts, you'll be inside the backend image. Now, simply migrate the db (only first time) and start the development server.
```
$ yarn migrate
$ yarn start
```Once you're done working, exit out from the container and use `yarn dev:down` command to stop the docker containers.
- Locally
```
$ cd backend
$ yarn start
```_Note: When running locally, you'll be required to run your own instance of postgres._
**Running backend-go**
If you don't have [`make`](https://en.wikipedia.org/wiki/Make_(software)) installed, commands are available in `Makefile`.
```
$ cd backend-go
$ make dev
```Now from inside the container, you can run the tests or application like below:
```
$ make test
$ make run
```
Feel free to open a new issue if you're facing any problem ๐**Codegen**
This starterkit uses [graphql-code-generator](https://github.com/dotansimha/graphql-code-generator) to codegen lot of things like TypeScript types, React Apollo hooks and queries, GraphQL Schema AST etc.
```
cd backend
yarn generate:graphql
```
Codegen is also executed in yarn postinstall hook### ๐ How to Contribute
Contributions are welcome as always, before submitting a new PR please make sure to open a new
issue so community members can discuss.Additionally you might find existing open issues which can helps with improvements.
This project follows standard [code of conduct](/CODE_OF_CONDUCT.md) so that you can understand what actions will and will not be tolerated.
### ๐ License
This project is MIT licensed, as found in the [LICENSE](/LICENSE)
Built and maintained with ๐ฎ by Karan