angular-10-node-express-mysql-example-feature-image

Angular 10 + Node.js Express + MySQL example: CRUD Application

In this tutorial, I will show you how to build a full-stack (Angular 10 + Node.js + Express + MySQL) example with a CRUD Application. The back-end server uses Node.js + Express for REST APIs, front-end side is an Angular App with HTTPClient.

Related Posts:
Server side Pagination with Node.js and Angular
Angular 10 + Node.js Express: JWT Authentication & Authorization example

Serverless with Firebase:
Angular 10 Firebase CRUD Realtime Database
Angular 10 Firestore CRUD with AngularFireStore


Angular 10 + Node.js + Express + MySQL example

We will build a full-stack Tutorial Application in that:

  • Tutorial has id, title, description, published status.
  • User can create, retrieve, update, delete Tutorials.
  • There is a search box for finding Tutorials by title.

Here are screenshots of the example.

– Add an object:

angular-10-node-express-mysql-create

– Retrieve all Tutorials:

angular-10-node-express-mysql-retrieve-all

– Click on Edit button to update a Tutorial:

angular-10-node-express-mysql-update

On this Page, you can:

  • change status to Published using Publish button
  • delete the Tutorial using Delete button
  • update the Tutorial details with Update button

– Search Tutorials by title:

angular-10-node-express-mysql-search

Full-stack CRUD App Architecture

We’re gonna build the application with following architecture:

angular-10-node-express-mysql-crud-example-architecture

– Node.js Express exports REST APIs & interacts with MySQL Database using Sequelize ORM.
– Angular Client sends HTTP Requests and retrieves HTTP Responses using HTTPClient, consume data on the components. Angular Router is used for navigating to pages.

Video

This is our Angular 10 Node.js Express Sequelize application demo and brief instruction, running with MySQL database:

Node.js Express Back-end

Overview

These are APIs that Node.js Express App will export:

MethodsUrlsActions
GETapi/tutorialsget all Tutorials
GETapi/tutorials/:idget Tutorial by id
POSTapi/tutorialsadd new Tutorial
PUTapi/tutorials/:idupdate Tutorial by id
DELETEapi/tutorials/:idremove Tutorial by id
DELETEapi/tutorialsremove all Tutorials
GETapi/tutorials?title=[kw]find all Tutorials which title contains 'kw'

Project Structure

angular-10-node-js-express-sequelize-mysql-example-project-structure

db.config.js exports configuring parameters for MySQL connection & Sequelize.
Express web server in server.js where we configure CORS, initialize & run Express REST APIs.
– Next, we add configuration for MySQL database in models/index.js, create Sequelize data model in models/tutorial.model.js.
– Tutorial controller in controllers.
– Routes for handling all CRUD operations (including custom finder) in tutorial.routes.js.

Implementation

You can find step by step to implement this Node.js Express App in the post:
Node.js Rest APIs example with Express, Sequelize & MySQL

Angular 10 Front-end

Overview

angular-10-node-express-mysql-crud-example-front-end-overview

– The App component is a container with router-outlet. It has navbar that links to routes paths via routerLink.

TutorialsList component gets and displays Tutorials.
Tutorial component has form for editing Tutorial’s details based on :id.
AddTutorial component has form for submission new Tutorial.

– These Components call TutorialService methods which use Angular HTTPClient to make HTTP requests and receive responses.

Project Structure

angular-10-node-express-mysql-client-project-structure

– There are 3 components: tutorials-list, tutorial-details, add-tutorial.
tutorial.service has methods for sending HTTP requests to the Apis.
app-routing.module.ts defines routes for each component.
app component contains router view and navigation bar.
app.module.ts declares Angular components and import necessary modules.

Implementation

You can find step by step to implement this Angular 10 App in the post:
Angular 10 CRUD Application example with Web API

Older Version: Angular 8 CRUD Application example with Web API

Conclusion

Now we have an overview of Angular 10 + Node.js Express + MySQL example when building a full-stack CRUD App.

We also take a look at client-server architecture for REST API using Express & Sequelize ORM, as well as Angular 10 project structure for building a front-end app to make HTTP requests and consume responses.

Next tutorials show you more details about how to implement the system:

You may want to know:
Server side Pagination with Node.js and Angular
Angular 10 + Node.js Express: JWT Authentication & Authorization example

Serverless with Firebase:
Angular 10 Firebase CRUD Realtime Database
Angular 10 Firestore CRUD with AngularFireStore

Happy learning, see you again!

One thought to “Angular 10 + Node.js Express + MySQL example: CRUD Application”

  1. hi thank you , for your tutorial ,
    thanks to you i learn a lot of on express js but i have one request please,
    how can i do to insert two or many tables in one request
    for example one table customers and customers_adress tables ,
    how can i insert the both in one create function ?

    sorry for my bad english

Leave a Reply

Your email address will not be published. Required fields are marked *