GithubHelp home page GithubHelp logo

photo-album's Introduction

NodeJS, Sequelize, Express Project in Clean-Code Architecture

Supported version of nodejs >= 12, Supported version of sequelize >= 6

About

  • This is a Node application, developed using Clean-Code Architecture with Node.js, ExpressJS, and Sequelize ORM.
  • A Sql database is used for data storage, with object modeling provided by Sequelize.
  • Supported SQL Databases are - MSSQL, MySql, PostgreSQL

Initial

  1. $ npm install

  2. $ npm start

  3. Credentials

    - One user with User role,
    # Default User credentials
    **username** : Neva.Parisian
    **password** : Tv13D1DJPuuIiDl
    

How to use generated APIs:

Click here to visit documentation

How to run with Docker ? :

  • if you have docker file you can execute following command

  • build the image $ docker build --pull --rm -f "Dockerfile" -t <imageName>:latest "."

  • execute the command $ docker run -p 3000:3000 <imageName>

Folder structure:

├── app.js              			- starting point of the application
├── constants         				- contains commonly used constants
├── controller         				- contains execution logic for a single web route only
├── data-access         			- contains model wise dbService specification
	├── db                			- contains database related information
		├── sequelize             	- folder created as per ORM
			├── models              - model schemas
			├── dbService.js        - contains database related functions
			├── connection.js      	- contains database connection
├── entities                		- contains entity files for each folder
├── jobs                 			- contains file of CRON jobs/Schedulers
├── middleware                		- contains middleware files
├── postman                			- contains postman collection, environment files and swagger file.
├── routes                			- contains all routes of application
├── seeders                			- contains file which seeds data when application starts
├── services                		- contains common files for services like sending Email/SMS, etc.
├── use-case                		- contains pure business logic
├── utils                			- contains common files
	├── response                	- contains files work with usecase responses
├── validation                		- contains validation related files
	├── schema                		- contains joi validation files for models
├── view                			- contains all views file

Detail Description of Files and folders

  1. app.js

    • entry point of application.
  2. constants

    • constants used across application.
  3. controller

    • Controller files contains execution logic for a single web route only.
	├── controller
		└── platform
			└── model  - contains files for model
				├── model.js  	- contains business logic
				└── index.js  	- contains dependency injection
  1. data-access

    • This folder contains model wise dbService specification
  2. db

    • Contains file needed to work with database
    ├── db
    	└── sequelize
    		├── model  				- contains schema file of model
    		├── connection.js  		- contains connections of database
    		└── dbService.js  		- contains functions related to work with database
    

6. entities
	- These are the business objects of your application. These should not be affected by any change external to them, and these should be the most stable code within your application. These can be POJOs, objects with methods, or even data structures.
7. jobs
	- this contains file created for each CRON job/Scheduler.

8. middleware
	- Middleware files for authentication, authorization and role-access.

9. postman
	- Contains Postman API file, environment file, swagger file and HTML doc of generated APIs.
	- Import postman-collection.json file into postman application to run and test generated APIs.

10. routes
	- index.js file, exports platform routes, imported into app.js to access all the routes.
├── routes
	├── platform
		├── modelNameRoutes.js   - contains CRUD operation routes
		└── index.js             - exports model routes
	└── index.js                 - exports platform routes

11. seeders
	- Contains file which seeds data into collection.

12. services
├── services
	├── jobs             - CRON job/scheduler service files
	├── email            - service file for sending email
	├── fileUpload       - service file for uploading file
	└── sms              - service file for sending sms

13. use-case
	- Contains pure business logic which is unaware of the framework/platform(web,cli,etc) and database (mongo,mysql,etc)

14. utils
	- contains common utility files used in application
├── utils
	├── response     - files to handle response

15. validation
	- Joi validations files for each model
	```
	├── validation
		├── schema      - joi  validation schema for each model
  1. env files
    • You can add credentials and port, database values as per your environment(Development/Production).
    • If you are running test environment then test cases will run using test database,and its configuration is there inside app.js

photo-album's People

Contributors

mustang7s avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.