Skip to main content

· 4 min read
Sivabharathy

JavaScript is often described as single-threaded, non-blocking, asynchronous, and concurrent. While these terms can seem daunting, the underlying concepts are straightforward when you understand how the Event Loop, Call Stack, Microtask Queue, and Macrotask Queue work together. In this article, we’ll demystify these concepts with explanations and code examples.


The Call Stack

The Call Stack is where JavaScript keeps track of function execution. It operates on the "last in, first out" (LIFO) principle. When a function is called, it’s added to the top of the stack. Once the function finishes execution, it’s removed from the stack.

· 4 min read
Sivabharathy

This article evaluates the performance of MongoDB, PostgreSQL (two versions), and CockroachDB in handling data insertion and querying tasks. The comparison is based on how these databases manage workloads, emphasizing time taken for data insertion and query execution.

Reference GitHub Repository: For further insights into BSON and JSON performance, refer to the BSON-JSON Bakeoff repository.


Test Overview

  1. Insertion Test:

    • 10,000 documents with a 4,000-byte (4KB) payload were inserted into an indexed field.
    • Two scenarios were tested:
      • Payload stored in a single attribute.
      • Payload distributed across 200 attributes.
  2. Query Test:

    • Queried 10,000 IDs from an indexed array.
  3. Metrics Measured:

    • Time taken for each operation.
    • Total items retrieved during queries.

· 5 min read
Sivabharathy

Explore an optimized Angular folder structure for large-scale applications using CSS. Learn best practices for modularization, lazy loading, state management, and component organization to ensure maintainability, scalability, and performance in your Angular projects.

1. Base Folder Structure

src/

├── app/
│ ├── core/ # Core module (singleton services, utility classes)
│ ├── shared/ # Shared module (components, directives, pipes, etc.)
│ ├── features/ # Feature modules (for specific domain functionality)
│ ├── assets/ # Static files (images, fonts, etc.)
│ ├── environments/ # Environment-specific configurations
│ ├── app.component.ts # Root component
│ ├── app.module.ts # Root module
│ └── app-routing.module.ts

├── assets/ # Global assets (images, styles)

├── environments/ # Environment configuration files (dev, prod, etc.)

└── styles/ # Global styles

· 5 min read
Sivabharathy

Message queues enable asynchronous communication in distributed systems, helping applications to scale, improve fault tolerance, and decouple components. Below is a comprehensive comparison of RabbitMQ, Kafka, ActiveMQ, IBM MQ, and NATS, along with their use cases, advantages, disadvantages, and guidance on when to choose each.

· 5 min read
Sivabharathy

Learn how to integrate Firestore with NestJS in this step-by-step guide. This example demonstrates setting up Firebase Admin SDK, creating services for CRUD operations, and exposing RESTful APIs to interact with Firestore in your NestJS application.

To integrate NestJS with Google Firestore, you will need to follow a few steps to set up and interact with Firestore within a NestJS application.

Here’s a simple example that demonstrates how to set up Firestore with NestJS, including the installation and usage of required dependencies, as well as an example service and controller to interact with Firestore.

· 5 min read
Sivabharathy

NestJS is a progressive framework for building scalable server-side applications. To enhance security, optimize performance, and streamline functionality, various middleware and libraries are integrated into NestJS projects. This guide explores essential tools and features such as CORS, Swagger, Mongoose, Rate Limiting, CSP, Helmet, Custom Logging, PM2 Logging, and Environment Variables Handling with .env, complete with examples.

· 7 min read
Sivabharathy

When deciding between Prisma and Mongoose for a MongoDB-based application, there are several factors to consider. Both are powerful tools, but they are designed with different paradigms and use cases in mind. Below is a breakdown to help you understand when you might prefer one over the other.

· 8 min read
Sivabharathy

Learn about TypeScript generics, including their use in functions, classes, interfaces, and type constraints. This guide covers key concepts like type variance, conditional types, and how to create reusable, type-safe code for flexible applications. Explore advanced topics such as reflection, the infer keyword, and more.

· 6 min read
Sivabharathy

In modern software systems, event-driven architectures are commonly used to handle asynchronous processes in a decoupled and efficient manner. One key tool to implement such architectures in Node.js is the EventEmitter class, which enables objects to emit and listen for events. In this article, we'll explore how to build a flexible, reusable, and generic event policy in Node.js using ES6 syntax.

· 4 min read
Sivabharathy

Adhering to a consistent coding style is essential for maintaining readability, reducing bugs, and facilitating collaboration in software development. Below are key coding standards for JavaScript, complete with examples.