Express Graphql Clean Architecture

Overview

Express Graphql Clean Architecture

The following is a folder pattern for express graphql starterkit structure pattern that I usually use, so if you are interested in the pattern I made, you can use it if you think it's good.

Table Of Content

What Are The Benefits ?

  • Easy to maintance
  • Easy to scalable
  • Readable code
  • Suitable for large projects or small projects
  • Easy to understand for junior or senior
  • And more

Folder Structure Pattern

├── tests
│   └── test.user.spec.ts
├── dao
│   └── dao.user.ts
├── dto
│   └── dto.user.ts
└── helpers
│   └── helper.gqlResponse.ts
└── middlewares
│   └── middleware.auth.ts
└── interfaces
│   └── interface.user.ts
└── models
│   └── model.user.ts
└── resolvers
│   └── resolver.user.ts
└── typedefs
│   └── type.user.ts
└── services
│   └── service.user.ts
└── libs
│   └── lib.jwt.ts
└── configs
│   └── pm2.config.js
└── databases
│   └── migrations
│   │     └── user_20210913.go // generate auto by cli using third party library
│   └── seeds
│   │     └── user_20210913.go // generate auto by cli using third party library

Folder Status And Description

  • Tests

Folder Name Folder Status Description
Tests Optional A collection of functions used to create a series of tests or run a test, be it unit testing or integration testing, which will later be used for the application itself.
  • Configs

Folder Name Folder Status Description
Configs Optional A collection of functions that contains all the configurations related to the application needs, such as .env or serverless.yml, which will later be used for the application itself.
  • Dao

Folder Name Folder Status Description
Dao Optional A collection of functions used to define a name for a service so that resolvers can access it.
  • Dto

Folder Name Folder Status Description
Dto Required A collection of functions used to handle all requests body passed from the client.
  • Helpers

Folder Name Folder Status Description
Helpers Optional A collection of functions used to create utilities for application purposes, such as customError or customResponse, which will later be used for the application itself.
  • Interfaces

Folder Name Folder Status Description
Interfaces Required A collection of functions used to definition field property for model.
  • Libs

Folder Name Folder Status Description
Libs Required A collection of functions that are used for the purpose of customizing a library into a separate function, which will later be used for the application itself.
  • Middlewares

Folder Name Folder Status Description
Middlewares Required A collection of functions that are used as a service for HTTP Requests such as authJWt, authRole, customLogger whether used per-route or used globally without the need to use them in each route, which will later be used for the application itself.
  • Models

Folder Name Folder Status Description
Models Required A collection of functions used to represent the table structure in a database, which will later be used for the application itself.
  • Resolvers

Folder Name Folder Status Description
Resolvers Required A collection of functions that are used to forward requests given by handlers to services, which will later be used for the application itself.
  • Typedefs

Folder Name Folder Status Description
Typedefs Optional A collection of functions used to pass the response you provide to the client from the service, which will later be used for the application itself, but if you are not use custom response.
  • Services

Folder Name Folder Status Description
Services Required A collection of functions that are used to interact with the database, which will later be used for the application itself.
  • Crons

Folder Name Folder Status Description
Crons Optional A collection of functions that are used to trigger a desired function, according to the time specified by the user, which will later be used for the application itself.
  • Databases

Folder Name Folder Status Description
Databases required A collection of functions used to create migrations or seeds for the database, which will later be used for the application itself.

Command

  • Application Lifecycle

    • Install node modules
    $ npm install
    • Build application
    $ npm run build || make build
    • Start application in development
    $ npm run dev | make dev
    • Start application in production
    $ npm run start || make start
  • Docker Lifecycle

    • Build container
    $ docker-compose build | make dcb
    • Run container with flags
    $ docker-compose up -d --<flags name> | make dcu f=<flags name>
    • Run container build with flags
    $ docker-compose up -d --build --<flags name> | make dcubf f=<flags name>
    • Run container
    $ docker-compose up -d --build | make dcu
    • Stop container
    $ docker-compose down | make dcd

BACK TO TOP

You might also like...

A boilerplate for building production-ready RESTful APIs using Node.js, Express, and Mongoose

By running a single command, you will get a production-ready Node.js app installed and fully configured on your machine. The app comes with many built-in features, such as authentication using JWT, request validation, unit and integration tests, continuous integration, docker support, API documentation, pagination, etc. For more details, check the features list below.

Dec 31, 2022

korrijs is a backend framework that built on express.js

körri-backend this is not a fork of any project. please support. -features: -automatic routing from file system "/routers" directory for eg.: you have

Aug 22, 2022

Very minimalistic boilerplate to start most Typescript Express projects. Includes Mongodb connection via Mongoose with a sample post model.

Very minimalistic boilerplate to start most Typescript Express projects. Includes Mongodb connection via Mongoose with a sample post model.

Minimalist express-typescript-boilerplate Available Scripts - `tsc' - builds the tsc project to the dist folder - `build` - cleans the previous build

Dec 13, 2022

This is a template project demonstrating how the MERN stack(Mongo, Express, React, Node) can be used, here we have the back end implementation and there is the React implementation as the front end

This is a template project demonstrating how the MERN stack(Mongo, Express, React, Node) can be used, here we have the back end implementation and there is the React implementation as the front end

Versão em português MERN stack This is a template project demonstrating how the MERN stack(Mongo, Express, React, Node) can be used, here we have the

Jan 22, 2022

A NodeJS Express server that uses Prisma ORM.

Express - Prisma Template (Typescript) A NodeJS Express server that uses Prisma ORM. Stack NodeJS Express Prisma TypeScript File Structure src/config

Feb 4, 2022

Node Express Template (NET.ts) - a small template project which help you to speed up the process of building RESTful API

Node Express Template (NET.ts) - a small template project which help you to speed up the process of building RESTful API

Jan 4, 2023

A simple Fast CLI that create Express+Mongoose MVC pattern

express-schema-generator Site | Docs | Contributing | Code of Conduct | Twitter | Chat Bored Writing and Creating the Same Express MVC Folders Again a

Aug 15, 2022

Apollo Server Express Boilerplate

Boilerplate for graphql and graphql-ws using Apollo Server Express and powered by TypeORM and TypeGraphQL to make your work is quicker and easier.

Dec 14, 2022

Postgres Node.js Express TypeScript application boilerplate with best practices for API development.

Node TypeScript Boilerplate Postgres Developer Ready: A comprehensive template. Works out of the box for most Node.js projects. This project is intend

Aug 28, 2022
Comments
  • changes typo on docs README

    changes typo on docs README

    I has been read your docs and found a few typo at Folder Structure Pattern section.

    I just fixed these typo that i noticed while reading through the docs.

    I hope this PR is useful, thanks.

    opened by bakunya 1
Owner
Restu Wahyu Saputra
A bright future will come, just waiting times, someday I will definitely become a software engineer
Restu Wahyu Saputra
DDD/Clean Architecture inspired boilerplate for Node web APIs

Node API boilerplate An opinionated boilerplate for Node web APIs focused on separation of concerns and scalability. Features Multilayer folder struct

Talysson de Oliveira Cassiano 3k Dec 30, 2022
A Node template that follows the Clean Architecture principles and encourages established practices.

Clean Architecture Template A Node template that follows the Clean Architecture principles and encourages established practices. Features TypeScript f

Jamie Livingstone 91 Dec 25, 2022
React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)

React Starter Kit — "isomorphic" web app boilerplate React Starter Kit is an opinionated boilerplate for web development built on top of Node.js, Expr

Kriasoft 21.7k Jan 1, 2023
Express typescript boilerplate using @types/node, @types/express

Express framework boilerplate in typescript.

Harris Gurung 3 Sep 21, 2022
Component-based node server architecture that is dockerized and ready for deployment

Introduction Component based node server architecture that is dockerized and ready for deployment Installation clone the repo and then cd NODE-SERVER

Ahmed Mashhour 2 Jan 24, 2022
React Native Boilerplate - The Boilerplate contains all the basic packages, common components and, prebuilt code architecture

The Boilerplate contains all the basic packages, common components and, prebuilt code architecture. It will save developer's project setup time.

MindInventory 36 Dec 26, 2022
Stepzen-sveltekit - An Example Blog with SvelteKit, the DEV API, and a StepZen GraphQL Backend.

Building a Serverless Blog with StepZen, SvelteKit, and the DEV API SvelteKit is a serverless first Svelte metaframework for building web applications

Anthony Campolo 0 Jan 17, 2022
A template repository for Deno, GraphQL, and Svelte projects

Svelte is an innovative approach to frontend software development, the component model, and reactivity features creates simplistic approach to some hard problems. Svelte runs on the front end and is known as a Single Page Application.

hyper 15 Dec 20, 2022
Nestjs boilerplate template (mongodb, typeorm, graphql - code first, i18n, global exception handling etc.)

Description City-Library-Demo project for boilerplate. (node version: 16.14.0, npm version: 8.5.2) First Steps Create .env file in root directory. (Th

Mert Kaygusuz 7 Nov 21, 2022
A starter for nextjs that pulls in tailwindui, graphql

NextJS TypeScript TailwindUI GraphQL Boilerplate Demonstrates a NextJS application with TypeScript and TailwindUI with a ASP.Net Core GraphQL based AP

RDA Corporation 5 Nov 17, 2022