/nest2022

Primary LanguageTypeScriptMIT LicenseMIT

Nest-Pegasus

NestJs TypeScript TypeORM Elasticsearch Fastify BullMQ Redis MySQL License

Nest-Pegasus is an all-in-one full-stack backend framework that incorporates content management, user authentication, role-based access control, search, and file handling capabilities.

πŸ“š Directory Structure

Here's an overview of the project's directory structure:

    .
    β”œβ”€β”€ assets # Static files for populating data
    β”‚   β”œβ”€β”€ ...
    β”œβ”€β”€ cli.js # Command line tool entry
    β”œβ”€β”€ config # Configuration files for each module
    β”‚   β”œβ”€β”€ ...
    β”œβ”€β”€ creator.ts 
    β”œβ”€β”€ database # Database migration, seeding, etc.
    β”‚   β”œβ”€β”€ ...
    β”œβ”€β”€ main.ts
    β”œβ”€β”€ modules 
    β”‚   β”œβ”€β”€ content # Content module
    β”‚   β”‚   β”œβ”€β”€ ...
    β”‚   β”œβ”€β”€ core # Dynamic configuration system, global validation pipes, interceptors, and filters
    β”‚   β”‚   β”œβ”€β”€ ...
    β”‚   β”œβ”€β”€ database # Database module
    β”‚   β”‚   β”œβ”€β”€ ...
    β”‚   β”œβ”€β”€ elastic # ElasticSearch full-text search
    β”‚   β”‚   β”œβ”€β”€ ...
    β”‚   β”œβ”€β”€ media # File upload/download and cloud storage
    β”‚   β”‚   β”œβ”€β”€ ...
    β”‚   β”œβ”€β”€ queue # BullMQ asynchronous message queue
    β”‚   β”‚   β”œβ”€β”€ ...
    β”‚   β”œβ”€β”€ rbac # Dynamic permission module based on CASL
    β”‚   β”‚   β”œβ”€β”€ ...
    β”‚   β”œβ”€β”€ redis
    β”‚   β”‚   β”œβ”€β”€ ...
    β”‚   β”œβ”€β”€ restful # Configurable RESTful routing
    β”‚   β”‚   β”œβ”€β”€ ...
    β”‚   β”œβ”€β”€ sender # WebSocket message broadcasting
    β”‚   β”‚   β”œβ”€β”€ ...
    β”‚   └── user # User module
    β”‚       β”œβ”€β”€ ...
    └── routes # Open API document version configuration
        β”œβ”€β”€ index.ts
        └── v1.ts

πŸ“•Main Features and Functionality

Nest-Pegasus provides a comprehensive backend solution that covers content management, user authentication, role-based access control, search, and file handling capabilities. Here are the key features and functionality of the project:

  1. Powerful content management system, supporting creation, update, and deletion of various content types, including articles, media files, and more.
  2. Comprehensive user authentication and authorization, using JWT tokens and role-based access control (RBAC) to manage user access to resources.
  3. Elasticsearch integration for fast and efficient full-text search capabilities.
  4. File handling and storage, supporting both local and cloud-based storage solutions.
  5. Asynchronous message queue processing with BullMQ for handling background tasks and improving application performance.
  6. Redis integration for caching and session management.
  7. Extensive API support with OpenAPI documentation and versioning

β˜‘οΈPlanned Features (Todo List)

  • Implementation of third-party login using OAuth2.
  • Multilingual support.
  • API rate limiting and security measures.
  • Containerization and deployment.
  • GraphQL integration.
  • ...

πŸ› Technology Stack and Dependencies

Nest-Pegasus is built on top of a robust technology stack and relies on various libraries and tools to deliver its features. Here is a list of the main technologies and dependencies used in the project:

  1. Nest.js: A progressive Node.js framework for building efficient, reliable, and scalable server-side applications.
  2. TypeScript: A strongly-typed superset of JavaScript that enables better developer experience and improved code maintainability.
  3. TypeORM: A powerful Object Relational Mapping (ORM) library for TypeScript and JavaScript that supports multiple databases and advanced querying capabilities.
  4. MySQL: A popular open-source relational database management system used for storing and managing application data.
  5. Elasticsearch: A distributed, RESTful search and analytics engine for all types of data, including textual, numerical, geospatial, structured, and unstructured.
  6. Fastify: A high-performance web framework for Node.js that provides faster HTTP responses and lower overhead compared to other frameworks.
  7. BullMQ: A powerful and easy-to-use message queue library for Node.js built on top of Redis.
  8. Redis: An in-memory data structure store, used as a database, cache, and message broker.

In addition to these core technologies, Nest-Pegasus also utilizes various other libraries and tools to support its functionality. The full list of dependencies can be found in the package.json file of the project.

βš“Installation and Configuration

To get started with Nest-Pegasus, follow these steps:

  1. Clone and Install dependencies
git clone https://github.com/ksdaylight/Nest-Pegasus.git
cd nest-pegasus 
pnpm install
  1. Configure environment variables: Create a .env file in the root directory of the project and configure the necessary environment variables. You can use the provided .env.example file as a reference.
  2. Run database migrations: First, run the following command to generate the migration files:
pnpm dbmg

Next, run the following command to perform the database migrations and seed data:

pnpm dbmr -s

You can use pnpm cli -h to see the help for available commands. This command will perform the migrations and then seed the database with initial data.

πŸš€Running and Deployment

After completing the installation and configuration steps, you can now run and deploy Nest-Pegasus

pnpm start

πŸ“ˆVisual Illustrations and Result Demonstrations

To help you better understand the various processes and functionalities within Nest-Pegasus, we've provided a series of flowcharts and result demonstrations. These visual aids will help you comprehend the inner workings of the framework.

1. Basic Request Handling Process

Basic Request Handling Process

2. OpenAPI Swagger Documentation Integration

OpenAPI Swagger Documentation Integration0 OpenAPI Swagger Documentation Integration1 OpenAPI Swagger Documentation Integration2

3. JWT Guard Authentication Flowchart

JWT Guard Authentication Flowchart

4. Dynamic Permissions Flowchart

Dynamic Permissions Flowchart

5. Websocket Message Broadcasting Flowchart

Websocket Message Broadcasting Flowchart

6. SMS and Email Queue Flowchart

SMS and Email Queue Flowchart

LICENSE

MIT