/content-management-system

an upcoming CMS backend system created using Typescript, NodeJs, MySQL.

Primary LanguageTypeScript

content-management-system

an upcoming CMS backend system created using Typescript, NodeJs, MySQL.

CMS System Documentation

Table of Contents

  1. Introduction
  2. Getting Started
  3. Technology Stack
  4. Authentication and Authorization
  5. API Reference
  6. Database Diagram

Introduction

The CMS System is a powerful content management system that enables users to manage job listings, educational institutions, user profiles, and social interactions. It provides a robust platform for companies, educational institutions, and users to connect and engage in a seamless manner.

Getting Started

1. Project Setup

To set up the CMS System, follow these steps:

  1. Clone the project repository from GitHub.
  2. Install the required dependencies using npm install.
  3. Configure the environment variables by creating a .env file.
  4. Set up the database connection by configuring the sequelize.config.js file.

2. Running the Project

To run the CMS System locally, use the following command:

  npm run dev

3. Database Migrations

The CMS System utilizes Sequelize migrations for managing the database schema. To run the migrations, use the following command:

  npm run db:migrate

4. Environment Configuration

The CMS System relies on environment variables for configuration. Ensure that you have a .env file in the project root directory and specify the required variables.

.env sample:

DATABASE_NAME = ""
DATABASE_PASSWORD = ""
DATABASE_HOST = ""
DATABASE_USER = ""
DATABASE_DRIVER = ""
PORT = 
DATABASE_PORT = 
SALT_ROUNDS = 
TOKEN_SECRET = ""

Technology Stack

The CMS System is built using the following technologies:

  • Node.js
  • Express.js
  • Sequelize (ORM)
  • MySQL (Database)

Authentication and Authorization

1. Authentication

The authentication system relies on JWT (JSON Web Tokens) for secure and stateless authentication. Users receive a JWT upon login, which they include in their requests authorization header to access protected resources. The JWT is verified by the authentication/authorization middleware to ensure the user's identity and authorization.

2. Authorization Middlewares

  1. verifyAccessToken:

his middleware is responsible for verifying the validity and authenticity of an access token provided by the client. It checks if the access token is properly signed and has not expired.

  1. validateAccessToken:

This middleware validates the access token and extracts the relevant user information from it. It ensures that the access token is valid and associated with an existing user.

  1. adminMiddleware:

It checks if the authenticated user has administrative privileges. 4. #### checkOwnership: This middleware is used to verify the ownership of a resource, such as a post. It ensures that only the user who owns the post has permission to delete or edit it.

API Reference

For the API Documentation, Enter the following url in your browser: http://localhost:{your_port}/api-docs to interact with the APIs within your browser.

Sample: a. APIs: image

b. Model Definitions:

Image 1 Image 2

Database Diagram:

Flowcharts