Header image

Explore all articles in Knowledge

Knowledge

Software Development

+0

    From Raw Data to Perfect API Responses: Serialization in NestJS

    Hello, My name is Dzung. I am a developer who has been in this game for approximately 6 years. I've just started exploring NestJS and am excited about this framework's capabilities. In this blog, I want to share the knowledge I’ve gathered and practiced in NestJS. Today's topic is serialization! As you know, APIs are like the messengers of your application, delivering data from the backend to the client side. Without proper control, they might spill too much information, such as passwords or internal settings. This is where serialization in NestJS steps in, turning messy, raw data into polished, purposeful API responses. With the power of serialization, you can control exactly what your users see, hide sensitive fields, format nested objects, and deliver secure, efficient, and downright beautiful responses. In this blog, we’ll explore how serialization in NestJS works, why it’s a must-have skill for any developer, and how to implement it step by step. Your APIs will go from raw and unrefined to clean and professional by the end. Let’s dive in! What Happens Without Serialization? Let’s look at what happens when you don’t use serialization in your NestJS application. Imagine you’re building a user management system, and you create an API endpoint to fetch user details. Here’s your User entity: Now, you write a simple endpoint to fetch a user: What happens when you call this endpoint? The API sends the entire user object straight to the client—every single field included: The consequences of lacking Serialization in the NestJS application Security Risks: Sensitive data, like passwords, should never be exposed in API responses.Data Overload: Users and clients don’t need internal flags or timestamps—they just add noise.Lack of Professionalism: Messy, unfiltered responses make your API look unpolished and unreliable. Next, we’ll see how to clean up this mess and craft polished API responses using NestJS serialization techniques. The Differences in Applying Serialization By implementing serialization in your NestJS application, you can take full control over what data is exposed in your API responses. Let’s revisit the previous example and clean it up. Step 1: Install class-transformer To get started with serialization, you need the class-transformer package. Install it with: Step 2: Update the User Entity with Exposed or Excluded Decorator Use class-transformer decorators to specify which fields should be exposed or excluded. Only the ID and email fields will be included in the response. Step 3: Apply the Serializer Interceptor NestJS provides a built-in ClassSerializerInterceptor to handle serialization. You can apply it at different levels: Per-Controller Globally To apply serialization to all controllers, add the interceptor to the application setup: When the Get User Endpoint is called, this is what your API will now return: Why Serialization Makes a Difference Security: Sensitive fields are automatically excluded, keeping your data safe.Clarity: Only the necessary fields are sent, reducing noise and improving usability.Professionalism: Clean and consistent responses give your API a polished look. Dynamic Serialization with Group What if you want to show different data to users, such as admins versus regular users? The class-transformer package supports groups, allowing you to expose fields based on context. Example: In the controller, specify the group for the transformation: When the Get User Endpoint is called, this is what your API will now return: By incorporating serialization into your NestJS application, you not only improve security but also enhance the user experience by providing streamlined, predictable, and professional API responses. Now that you know how serialization works in NestJS, you can apply these techniques to your projects, creating safer, cleaner, and more maintainable APIs. SupremeTech has lots of experience and produces web or app services. Let’s schedule a call now if you want to work with us. Also, now we are hiring! Please check open positions for career opportunities.

    20/12/2024

    9

    Dung Nguyen Q.

    Knowledge

    +1

    • Software Development

    From Raw Data to Perfect API Responses: Serialization in NestJS

    20/12/2024

    9

    Dung Nguyen Q.

    Knowledge

    +0

      Atomic Design In Software Development

      Hello everyone! I'm Linh, a front-end developer passionate about discovering effective methods for system development. When I first entered the tech industry, I faced challenges organizing UI components logically and reusable. This experience motivated me to seek strategies to optimize my workflow while ensuring that the products I developed were easy to scale and maintain. Recently, I explored the concept of Atomic Design, which has become a guiding principle for me in tackling these challenges more systematically and scientifically. This approach has significantly influenced my design thinking. Through this article, I aim to inspire you and offer a fresh perspective if you're also looking for solutions for your systems. Taking Cues From Chemistry Looking for a way to build and create a design system reminds me of developments in other fields and industries. Many areas, such as design and architecture, have developed smart modular systems to produce incredibly complex things like airplanes, ships, and skyscrapers. These thoughts take me back to my school days in chemistry labs. The idea is that all matter—whether solid, liquid, gas, simple, or complex—is made up of atoms. These atoms bond to form molecules, which combine into more complex organisms, eventually creating everything in our universe. Similarly, systems built up from smaller components are more logical and connected. We can break the entire system into basic building blocks and work from there. That’s the core idea of atomic design. What Is Atomic Design? Atomic Design is an interface design methodology that focuses on creating a system of components rather than entire pages. Introduced by Brad Frost in 2013, this approach emphasizes using small, independent elements that can be reused and combined to form a cohesive whole. This strategy facilitates quicker product development, promotes a unified interface, and simplifies maintenance. “Atomic Design is a methodology where designers prioritize creating individual components and then combine them, rather than designing entire pages.” Atomic Design can enhance the design development process, promoting consistency, adaptability, and efficiency across projects. By applying the principles of Atomic Design, developers and designers can collaborate within a cohesive design system, ultimately delivering a scalable and high-quality user experience. Atomic Design organizes components into five levels, progressing from simple to complex, as illustrated above: Atoms: These are the most basic components, such as HTML tags like buttons, inputs, labels, and icons.Molecules are combinations of two or more atoms that create more complex components. For example, a form group consists of an input and a label.Organisms are more complex UI components of multiple molecules and/or atoms. For instance, a form can comprise several form groups and buttons.Templates are layout frameworks created from organisms and molecules. They define how these components are arranged on a page but do not contain actual data or content; they represent an abstract structure.Pages: These are specific instances of templates where real content is added to create complete web pages or applications. Pages include all necessary components—atoms, molecules, organisms, and templates—along with specific content for end users to interact with. In the following sections, we will explore each level of Atomic Design in detail. Atoms Similar to atoms in nature, these elements may seem abstract, but they are the foundational building blocks of all our user interfaces. In web interfaces, atoms are the fundamental HTML elements, such as labels, inputs, and buttons. As the smallest components, they cannot be broken down any further. Atoms can also be abstract concepts, including colors, fonts, and even more intangible UI aspects, like animations. Molecules When we combine atoms, things become more interesting and tangible. Molecules are groups of atoms that bond together and serve as the minor basic units of a compound. They possess unique properties and act as core elements within our design system. For example, when atoms like labels, inputs, or buttons stand alone, they are useless. However, when combined into a form, they can work effectively together. Molecules can be simple or complex and designed for reuse or one-time use. A molecule can have multiple variants (similar to components in a Variant in Figma) intended for different contexts or interactions (such as hover, pressing, or after a delay). Organisms Molecules provide us with building blocks to combine to create organisms. Organisms are groups of molecules that come together to form a more complex and complete structure. Organisms can consist of similar or different elements. For instance, a website header might include a logo, menu, and search box. When you visit the category page of most e-commerce websites, you'll see product listings displayed in a grid format, composed of smaller components like images, titles, captions, etc. Templates Templates are combinations of organisms that create complete pages. They focus on the basic content structure rather than the final content. Templates help clearly define important properties such as image sizes and text lengths, thereby establishing an effective system for managing dynamic content and ensuring alignment with the design. “You can create good experiences without knowing the content. What you can’t do is create good experiences without knowing your content structure. What is your content made from, not what your content is?” Pages Pages are specific instances of templates. Placeholder content is replaced with representative content to depict what end users will see accurately. In simpler terms, pages are templates filled with real data for presentation purposes, offering the most realistic view of the design. Developers and designers will test how templates work with actual content, allowing designers to return and adjust to molecules, organisms, and templates as needed. Benefits Of Applying Atomic Design In User Interface (UI) Design Consistency Atomic Design utilizes a modular approach, ensuring each interface element adheres to a consistent design language. When a component, such as a button or color, is modified or updated, these changes are automatically reflected across all pages, maintaining uniformity throughout the product. This consistency is crucial for large and complex design teams, where smooth and synchronized updates are essential. Reusability Reusability is one of the most significant advantages of Atomic Design. By defining basic components in a standardized way, you can reuse them throughout different contexts and parts of the product. Due to this reusability, designers and developers can quickly integrate complex interfaces from standardized small components. For example, a button designed according to the standards can be used on various pages, from the homepage to product pages and forms, without needing to be recreated. This not only minimizes repetitive work but also ensures consistency across the entire design system. Atomic Design's reusability also promotes flexibility. It allows for easy updates or replacements of a component across the system without changing every detail on each page. Maintainability Atomic Design enables designers and developers to efficiently monitor and modify specific interface parts without impacting the entire system. The team can directly adjust the associated atoms or molecules when updates are required for a component, such as a button or color. These changes will automatically be reflected across all instances of that component. This approach reduces errors, minimizes repetitive tasks, and ensures that updates are consistently applied throughout the system. Scalability Like maintainability, Atomic Design allows designers and developers to expand the system by adding new components at the appropriate levels without disrupting the overall structure. For instance, if a new type of button or content combination is needed, the team can create new atoms or molecules and seamlessly integrate them into existing organisms and templates. This method enables a system to quickly scale from a small application to larger, more complex products with many new pages and features while maintaining structural integrity. Atomic Design's scalability ensures that products can evolve continuously and improve while minimizing the effort required for updates or adjustments to meet new demands. This helps products quickly adapt to changing user needs and market conditions. A prime example of successfully implementing Atomic Design principles in UI design is the Shopee UI Design System. Shopee is building its interface systems based on Atomic Design principles to maintain consistency across its entire product range. By applying Atomic Design to fundamental components such as buttons, colors, and font families (Atoms), as well as groups of components like product lists (Molecules) and elements like navigation bars or product carousels (Organisms), Shopee enhances development speed through the reuse of standardized components, ensuring a consistent interface across multiple platforms. Reality Use-Cases Atomic Design is a robust methodology for creating user interfaces (UI) that has been extensively utilized in various open-source projects. Below are some notable systems that SupremeTech has adopted and incorporated into its client solutions: Shopify Polaris Design System Shopify uses Polaris to create a consistent interface for all applications related to Shopify. Similar to Shopee UI, Shopify Polaris applies the levels of Atoms, Molecules, and Organisms from Atomic Design into its design system. This helps Shopify enhance development efficiency and maintain long-term product quality. MedusaJS As an open-source e-commerce platform, MedusaJS implements atomic design to organize the UI components for its Storefront and Admin Dashboard. Storefront UI: When building the Shopify Storefront interface for Medusa.js projects, Atomic Design helps organize UI components hierarchically. 1. Atoms: Button:  Add to Cart button, View Product button.Text: Product title, price.Icon: Shopping cart icon, search icon. 2. Molecules: Product Card: Includes an image, title, price, and Add to Cart button.Navbar: Contains the logo, menu links, and search bar. 3. Organisms: Product Grid: A grid of product cards.Header: Combines the logo, navigation bar, and mini cart. 4. Templates: Product detail pages or product category pages. 5. Pages: Homepage, checkout page. Admin Dashboard: Medusa.js also requires an admin UI to manage products, orders, and customers. Atomic Design helps organize the admin interface. 1. Atoms: Input: Input fields (product name, price).Button: Save, Delete, or Add product buttons.Badge: Displays order status (completed, processing). 2. Molecules: Search Bar: Search input field with a button and icon.Table Row: A row in a data table (product, order). 3. Organisms: Data Table: Displays a list of products or orders.Sidebar: Navigation menu for sections like Products and Orders. 4. Templates: Product list page with sidebar and data table. 5. Pages: Product management page, order management page. By applying Atomic Design, MedusaJS achieves: Component reusability: UI components like buttons, forms, or cards can be reused in both the storefront and admin dashboard.Easy expansion: When adding new features (e.g., wishlist or promotional modules), you can combine existing Atoms, Molecules, and Organisms.Consistency assurance: Atomic Design ensures that components are uniformly designed from the admin interface to the storefront.Facilitated collaboration: Design and development teams can collaborate on a transparent hierarchical system. Wrapping Up Atomic Design is a valuable method in design and development; fundamentally, it serves as a framework for building user interfaces. The immediate benefits include time and cost savings, improved product consistency, enhanced team collaboration, support for accessibility efforts, and strategic long-term initiatives. These reasons drive organizations to adopt design systems. Mastering the core principles of modern design systems will help you grow as a designer or developer.

      16/12/2024

      39

      Linh Nguyen D. Q.

      Knowledge

      +0

        Atomic Design In Software Development

        16/12/2024

        39

        Linh Nguyen D. Q.

        Knowledge

        +0

          The Ultimate Guide to JMeter Performance Testing Tool

          At SupremeTech, we are dedicated to creating technology products that provide the best user experience. In this article, I will introduce you to JMeter performance testing, a powerful and flexible tool that significantly enhances the quality of technology products. With its ability to support various protocols, JMeter allows you to test the performance of a wide range of applications, from web services to APIs and even real-time applications. Let’s explore the types of applications JMeter can be applied to and the outstanding features it offers! For more insights into Performance Testing, check out our blogs below: The Process of Performance Testing at SupremeTech Applications Suitable for JMeter Web Applications For applications using HTTP/HTTPS protocols, such as e-commerce sites, blogs, or corporate websites, JMeter can help assess response times and system performance. RESTful APIs JMeter supports load testing for APIs, measuring response times, and checking stability. Real-Time Applications (WebSocket Applications) For applications that require real-time communication, such as chat applications or online games, JMeter offers performance testing with the WebSocket Sampler Plugin, ideal for messaging systems or online monitoring. Mobile Applications JMeter can simulate requests from mobile applications to their backend APIs, such as food delivery apps or digital banking services. Database-Driven Applications For applications that rely on database queries, like CRM or ERP systems, JMeter supports performance testing using the JDBC Request Plugin to evaluate database efficiency. Custom Protocol Applications For applications using unique protocols like TCP or UDP, JMeter allows for performance simulation and testing using the TCP Sampler, which benefits  IoT applications or data transmission over local networks. Why Should Use JMeter Performance Testing Tool? Advantages Free and open source: JMeter is a cost-free tool that is easy to use.Multi-protocol support: It supports protocols like HTTP, FTP, SOAP, REST, etc.User-friendly interface: It provides an intuitive graphical interface suitable for beginners.Scalability: Supports plugins and can integrate with CI/CD tools like Jenkins.Detailed measurement: Offers comprehensive reports on performance metrics such as latency, error rates, and response times.Distributed testing: Allows load testing across multiple servers to simulate high traffic volumes. Disadvantages    Performance limitations under heavy load: JMeter may struggle with extremely high loads due to resource consumption.Not optimized for UI testing: JMeter might not be the best choice if you need to test complex user interfaces.Limited scripting flexibility: While it uses BeanShell and Groovy scripts, it lacks the flexibility of some other tools.Complex result analysis: Default reports from JMeter may not be intuitive and require external tools for advanced analysis.Learning curve: The complex features of JMeter can take time to master. What You Should Know About JMeter Plugins Plugins are an integral part of JMeter that significantly enhance its testing capabilities. Some notable plugins include: JMeter Plugins Manager: Easily manage plugins without manual configuration.PerfMon Metrics Collector: Monitors system resources like CPU, RAM, Disk, and Network during tests.JDBC Request Plugin: Tests database performance through JDBC.WebSocket Sampler: Supports WebSocket protocol testing for real-time applications.Throughput Shaping Timer: Adjusts request rates to achieve desired throughput.ElasticSearch Backend Listener: Integrates with ElasticSearch and Kibana for data analysis and visualization. Types of Reports Provided by JMeter JMeter offers various reports to help analyze and evaluate system performance: Dashboard Report: Provides an overview with graphs and data tables to track throughput, response times, and error rates.Aggregate Report: Supplies detailed aggregated data about each sampler or group of requests.Graph Results: Displays graphs showing changes in response times and throughput over time.Response Time Distribution: Shows response time distribution to identify acceptable thresholds. JMeter is a necessary tool for testers performing performance testing across various applications and protocols. Despite some limitations, its support for plugins and detailed reporting makes monitoring and analyzing system performance easy. Best of all, it is completely free! Make the most of JMeter to ensure your application runs smoothly in testing and production environments.

          10/12/2024

          67

          Vu Nguyen Q.

          Knowledge

          +0

            The Ultimate Guide to JMeter Performance Testing Tool

            10/12/2024

            67

            Vu Nguyen Q.

            Knowledge

            +0

              SupremeTech’s Expertise in the Process of Performance Testing

              In the previous article discussing The Importance of Performance Testing and SupremeTech's Expertise, we understood the overview of performance testing and its significance for businesses. Let me introduce how SupremeTech manages performance and the process of performance testing to ensure our products are always ready to face real-world challenges. At SupremeTech, product performance is not just a priority but a commitment. So how to do performance testing? Below is a detailed process of performance testing that we implement to ensure applications operate stably and efficiently under any usage conditions. For more insights into Performance Testing, check out our blogs below: The Ultimate Guide to an Essential JMeter Performance Testing Tool Step 1: Application Optimization   1.1 Optimizing OPCache Infrastructure Team Responsible for configuring and fine-tuning OPCache on the server.Ensures that JIT (Just-In-Time) caching is enabled and that parameters align with system resources. 1.2 Database Optimization Back End Team Designs composite indexes to enhance query speed.Rewrites or optimizes SQL queries to improve efficiency and reduce execution time.Analyzes common queries and data flows. 1.3 Optimizing Laravel During Deployment Back End Team Considers activating Production Mode in Laravel.Executes the command php artisan optimize to optimize application configurations. Infrastructure Team Manages caching for configurations, routes, and views.Supports the deployment and integration of queues or jobs on the server system. Step 2: Preparing for Performance Testing Collaboration among teams is crucial to ensure that every preparation step is accurate and ready for the performance testing process. 2.1 Developing a Plan and Initial Estimates QC Team, Back-End Team Creates a detailed plan for each phase of performance testing.Proposes resource, time, and data requirements. Project Technical Leader (PTL) Reviews and approves the testing plan.Coordinates appropriate resources based on preliminary estimates. 2.2 Security Checklist Project Technical Leader (PTL) Develops a checklist of security factors to protect the system during testing. QC Team, Back End Team Review the checklist to ensure completeness and accuracy. 2.3 Preparing Test Data QC Team Creates accounts, test data, and detailed test scenarios.Writes test scripts to automate testing steps. Back End Team Assists in building complex test data or necessary APIs.Reviews and tests scripts to ensure logic aligns with the actual system. Step 3: Setting Up the Testing Environment Coordination between the QC and Infrastructure teams is essential to ensure an optimized testing environment is ready for subsequent phases. 3.1 Estimating Server Specifications Infrastructure Team Determines appropriate server configurations based on application needs and testing requirements.Provides optimal specifications based on available resources and product scale.Supplies information about physical resources and infrastructure to support testing. 3.2 Establishing the Testing Environment Infrastructure Team Installs and configures virtual machines for performance testing.Adjusts server parameters (CPU, RAM, Disk I/O) to meet testing criteria. QC Team Confirms that the environment is ready for testing based on established criteria. 3.3 Adjusting Parameters According to Testing Requirements Infrastructure Team Modifies server configurations based on optimal parameters suggested after initial tests.Ensures configuration changes do not affect system stability. Step 4: Conducting Tests 4.1 Performing Performance Tests QC Team Executes load tests on APIs and key functionalities.Utilizes testing tools (JMeter, k6, Postman, etc.) to measure performance. Infrastructure Team Supports environment management and monitors system resources during testing. 4.2 Reporting Results QC Team, Infrastructure Team Compiles test results (response times, CPU load, RAM usage, etc.) from various tools.Compares results against established performance targets.Sends detailed reports to stakeholders (PTL, Backend Team). 4.3 Post-Test Optimization Backend Team Analyzes test results and fixes bugs or optimizes source code and application logic. Infrastructure Team Adjusts server configurations or optimizes system resources based on test outcomes. QC Team Re-run tests after optimization to ensure improved performance is achieved.Compiles final test results and confirms with stakeholders. Step 5: Clearing Test Data 5.1 Restoring Server Configuration to Initial State Infrastructure Team Resets server configurations to their original state to reduce unnecessary resource consumption.Deletes or powers down virtual machines used during testing.Ensures no temporary configurations or unnecessary test environments remain in the system. 5.2 Removing All Test Data from Databases QC Team Identifies test data that needs deletion to prevent junk data from affecting the live system. Back End Team Safely deletes test data from the database while ensuring no production data is mistakenly removed.Verifies that the database is clean after deletion. This process of performance testing enables SupremeTech to optimize each stage effectively, ensuring our products achieve optimal performance before delivery to partners. With our experienced workforce, we consistently prioritize product efficiency and quality.

              10/12/2024

              64

              Vu Nguyen Q.

              Knowledge

              +0

                SupremeTech’s Expertise in the Process of Performance Testing

                10/12/2024

                64

                Vu Nguyen Q.

                Knowledge

                +0

                  The Importance of Performance Testing and SupremeTech’s Expertise

                  Hello everyone, I’m Vu, a dedicated Quality Control professional committed to delivering software and applications that provide the best user experience. With over 12 years of experience in the industry, I am excited to share valuable insights on Performance Testing—an essential step to ensure that software functions smoothly and effectively before it reaches users. Even a slight delay can lead to customer loss in today's fast-paced era, making performance testing crucial for all businesses. How can systems maintain smooth operation during unexpected traffic spikes? How can we prevent crashes during peak times? The solution lies in performance testing. At SupremeTech, we provide high-quality performance testing solutions that guarantee your systems remain stable and efficient. 6 Notable Technology Incidents From the Past Healthcare.gov (2013): This insurance website crashed completely when it launched, leading to significant confusion among American citizens.Amazon Prime Day (2018): The e-commerce giant lost substantial revenue on the epic sale because the platform had crashed.Google Cloud (2019): A configuration issue caused Google Cloud to crash, affecting numerous primary services and highlighting the importance of performance testing.Zoom During the Covid Pandemic (2020): To meet the surge in online work demand, Zoom had to build its infrastructure rapidly.Facebook Outage (2021): A configuration error caused the entire Meta ecosystem to go down for 6 hours, resulting in significant reputational and financial losses.PlayStation Network (2023): Shortly after launching a new game on PlayStation 5, Sony was unprepared for gamers' inability to download it. These incidents serve as a wake-up call for all businesses. No system is immune to performance issues if it hasn't been thoroughly tested and optimized. Here are some key reasons why companies should prioritize Performance Testing for their products: Prevent Revenue Loss: A slow or crashing system can drive customers away, leading to lost revenue.Protect Brand Reputation: Major performance incidents often leave a negative impression, damaging credibility.Prepare for Growth: Performance testing allows you to scale operations confidently without worrying about system issues. What is Performance Testing? Performance testing is a method of testing, measuring, and evaluating a system's speed, stability, and load capacity to ensure it operates effectively under various conditions. Overview of Performance Testing: Load Capacity Assessment: Determining the maximum load limit that the system can handle.Identifying Bottlenecks: Finding weaknesses as a way to enhance performance.Improving User Experience: Ensuring users have a smooth experience while protecting brand reputation. Types of Performance Testing Load Testing: Evaluating load capacity by simulating large numbers of concurrent users. We identify the system's load threshold and address weaknesses before issues arise.Stress Testing: Pushing the system to its maximum limits to test its response in worst-case scenarios, ensuring safety.Endurance Testing: Assessing system durability when operating continuously over long periods to ensure stable performance.Spike Testing: Simulating sudden spikes in traffic, such as during major sales campaigns, helping businesses prepare for peak hours. SupremeTech's Exceptional Capabilities Flexible Integration with Various Platforms: We can conduct tests across diverse platforms, from mobile applications and websites to complex systems, ensuring optimal performance for all platforms.Detailed Data Analysis: We not only identify bugs but also provide detailed reports with optimization recommendations based on real data.  This helps you effectively address performance issues.Flexible Automated Updates: SupremeTech's automated systems allow businesses to adjust and optimize their processes easily as they grow.Dedicated Consulting Team: SupremeTech's experienced experts are ready to support you from planning through implementation and maintain high efficiency. SupremeTech - Your Partner for Optimal Performance At SupremeTech, we are committed to researching advanced technologies, maintaining professional workflows, and employing a passionate team to deliver exceptional value in all our products and services. Performance testing is more than just a technical task; it is essential for maintaining your reputation and achieving market success. Allow SupremeTech to enhance your products for today and the future. For more insights into Performance Testing, check out our blogs below: The Process of Performance Testing at SupremeTechThe Ultimate Guide to an Essential JMeter Performance Testing Tool

                  10/12/2024

                  48

                  Vu Nguyen Q.

                  Knowledge

                  +0

                    The Importance of Performance Testing and SupremeTech’s Expertise

                    10/12/2024

                    48

                    Vu Nguyen Q.

                    How-to

                    Knowledge

                    Software Development

                    +0

                      How to Undo Commits Safely in Git: Git Reset and Git Revert Explained

                      Introduction In software development, mistakes in commits happen more frequently than we would prefer. Imagine you are working on a feature branch and accidentally commit sensitive information, like an API key, or commit in the wrong branch. You quickly realize the need to undo these changes, but as you search for solutions, you come across two common commands: git reset and git revert. Each offers a way to return, but which is right for your situation? In this article, SupremeTech will explore both commands, how they work, when to use them, and how to decide which approach best addresses your specific needs. Three trees in Git Before getting started, it’s important to understand Git's internal state management systems, called “Git’s three-tree”: Working Directory: This is the workspace on your local machine, it reflects the current state of your files and any changes made that have not yet been staged or committed. You can see changes in the Working Directory with git status.Staging Index: This space holds a snapshot of changes ready to be committed. After you’ve made changes in the Working Directory, you can add them to the Staging Index with git add.Commit History: This is the timeline of saved changes in your project. When you use the git commit command, it takes the changes from the Staging Index and adds them to this history as a new commit. Figure 1. The Git’s three-tree The animation above demonstrates Git's three-tree structure by showing the creation of file1.js and committing it as C1. We add two more examples: file2.js as a C2 commit and file3.js as a C3 commit. These three commits will be used throughout the article as we explore git reset and git revert commands. Figure 2. Visualizing Git's three-tree with three commits Undoing commits with git reset The git reset command allows you to undo changes in your working directory by moving the branch tip back to a specific commit and discarding all commits made after that point. Figure 3. Visualizing the git reset command After running the command git reset HEAD~1, you’ll notice two changes: The branch tip has moved to the commit C2.The latest commit (C3) has been discarded from the commit history. The HEAD~1 is a way to reference the commit before the current HEAD. You can use similar syntax to go back further, like HEAD~2 to go back two commits from HEAD. Alternatively, you can specify a particular commit using its hash ID. The next question is where did the changes from C3 commit go? (the file3.js in this example). Did it delete permanently, or is it saved somewhere? This is where the git reset flags come into play. Bypassing one of the following flags, you can control the changes: --soft: It undoes the commits in the history and places the changes back in the Staging Index, ready to be committed again if needed. Figure 4. Visualizing git reset command with --soft flag -—mixed (this is the default option): It is similar to—-soft but also clears the Staging Index. This means any changes from the discarded commits are left unstaged in the Working Directory, requiring you to re-add them before re-committing. Figure 5. Visualizing git reset command with --mixed flag --hard: This option clears all changes from both the Staging Index and Working Directory and resets the codebase to match the specified commit without making any modifications. Figure 6. Visualizing git reset command with --hard flag By using git reset, you've successfully undone a specific commit. However, try to push these changes to the remote repository with a regular git push. You’ll get an error because the local commit history no longer matches the remote. To push these changes, you need to use a force push (git push --force). While this command will update the remote branch, it comes with risks - it can overwrite the remote history, creating potential issues for other developers. To avoid these problems, let’s explore a safer alternative: Undoing public commits with git revert The git revert command is an undo command, but it doesn’t work like the git reset. Instead of removing a commit from the project history, it creates a new one containing the inverse of the original changes. Figure 7. Visualizing the git revert command The result of running the command git revert HEAD is a new commit that undoes the changes made in the C3 commit. Since the C3 commit added file3.js, the revert will effectively delete this file. In short, running git revert HEAD will bring your code back to its state at the C2 commit. You can prevent git revert from automatically creating a new commit by using the -n or --no-commit flag. With this option, the inverse changes are placed in the Staging Index and Working Directory, allowing you to review or modify them before committing. Figure 8. Visualizing git revert command with --no-commit flag The git revert command allows you to go back to previous commits without removing any mistake commits. It doesn’t re-write the project history. Because of this, this command should be used to undo changes on a public branch. What is the difference between Git Reset vs. Git Revert? The difference between git reset and git revert is that git reset should be used to undo changes in your local history, while git revert should be recommended for undoing changes on a shared or public branch. Both git reset and git revert are commands for undoing changes, but they work differently in key ways: git resetgit revertHow it worksReverts to a previous state by removing the specified commit.Reverts to a previous state by creating a new commit with inverse changes.OptionsOffers --mixed, --soft, and --hard flags to control how changes are handled.Offers --no-commit to add inverse changes without automatically committing them.UsageRecommended for undoing changes in your local history.Recommended for undoing changes on a shared or public branch. Conclusion By now, you should clearly understand how to undo changes in a Git repository using git reset and git revert. In short, use git reset for local-only history changes, and use git revert to undo changes on a shared branch safely. Choosing the right command for your situation lets you keep your project history clean and ensures smoother collaboration with your teammates.

                      25/11/2024

                      170

                      Huy Nguyen K.

                      How-to

                      +2

                      • Knowledge
                      • Software Development

                      How to Undo Commits Safely in Git: Git Reset and Git Revert Explained

                      25/11/2024

                      170

                      Huy Nguyen K.

                      backend for react native apps

                      Knowledge

                      Software Development

                      +0

                        Choosing A Good Backend For React Native Apps

                        As a business owner looking to develop a React Native app, it’s natural to focus on the front end-the design, layout, and user experience. However, there’s another critical part: the backend. The backend powers the app’s functionality. It processes, stores, and delivers data behind the scenes. Think of it as the “engine” of your app. Therefore, choosing a good backend for React Native apps is no less important to foster your app performance. While the front end decides how the app looks, the backend controls what it can do. If you want dynamic features—like user accounts, order processing, or real-time updates—the backend is essential. Understanding the backend basics helps you make better development decisions. It influences costs, timelines, security, performance, and scalability. Do you need a backend for thousands or millions of users? Should the app integrate with your existing CRM or ERP systems? How will the app securely store customer data and meet privacy laws? All these questions depend on the backend. This guide explains the backend essentials from a business owner’s perspective. With this knowledge, you’ll make informed decisions about your app’s backend. Whether choosing a simple Backend-as-a-Service (BaaS) or a custom-built solution, understanding these points will help you pick the right approach. How To Choose A Suitable Backend for React Native Apps A good backend option depends greatly on the purpose of your React Native Apps. However, there are some key things to keep in mind. Choosing Between a Custom Backend or Backend-as-a-Service (BaaS) First of all, there are two main paths: a custom-built backend or using a Backend-as-a-Service (BaaS) like Firebase, AWS Amplify, or Supabase. A Custom Backend will allow more control and customization. You can build every feature to meet your exact needs, making it easy to handle unique workflows, custom data models, or complex business logic. However, it takes more time and resources to set up and maintain. In addition, a custom backend offers cost efficiency over time. Although upfront development costs are higher, a custom backend can reduce long-term costs by eliminating the need for ongoing subscription fees or third-party limitations. While a custom backed requires initial financial investment, Backend-as-a-Service (BaaS) can provide instant outcomes for business in early stage. It is faster and easier to set up, with out-of-the-box solutions for common needs (like user management and notifications). A lot of existing BaaS is designed to handle spikes in traffic automatically, so your app can grow without worrying about server capacity. Additionally, BaaS platforms typically offer strong security features and follow industry standards, which is beneficial for apps handling user data. Since the BaaS provider handles backend infrastructure, your team can focus on building and enhancing the app’s front end. BaaS is also ideal for prototypes or MVPs, where you need fast deployment without the commitment to a custom solution. However, customization might be limited, and costs can add up if the app scales quickly. It cannot be denied that BaaS gains its popularity due to many advantages. Which one is more popular? The choice between a custom backend and BaaS depends on the type of project, its complexity, and long-term goals. BaaS is more popular among startups, small businesses, or projects focused on getting to market quickly. Custom backends are more popular with enterprises, businesses with complex requirements, and apps with high customization needs. They’re common in industries where data control, security, and integration flexibility are paramount, such as finance, healthcare, and e-commerce. Some Common Backend Choices for React Native Apps Here are some common backend choices for React Native apps. Node.js with Express Why: Node.js is popular for mobile backends due to its non-blocking, event-driven architecture, which is great for handling multiple requests. Paired with Express, a flexible framework, it allows easy setup of RESTful APIs. Good for: Apps needing real-time data, like chat or collaborative tools. Firebase Why: Firebase, a Backend-as-a-Service (BaaS) by Google, provides pre-built features like authentication, real-time database, cloud storage, and analytics without needing custom server infrastructure. Good for: Quick prototypes, simple apps, or apps that need real-time data synchronization. AWS Amplify Why: AWS Amplify provides a BaaS-like approach, with cloud storage, authentication, APIs, and even machine learning integration, all managed by AWS services. Good for: Apps needing scalable infrastructure with support for advanced AWS services. GraphQL with Apollo Server Why: Unlike REST, GraphQL allows clients to request only the data they need, making it efficient and flexible for mobile apps. Apollo Server makes it easy to build a GraphQL API. Good for: Apps needing highly customized data queries, minimizing over-fetching or under-fetching of data. Strapi (Headless CMS) Why: Strapi is a customizable, open-source headless CMS that uses Node.js. It provides an easy interface to manage and serve content. Good for: Apps needing flexible content management, such as e-commerce or blogs. Each backend choice has its strengths depending on the app’s data needs, real-time requirements, and development speed. React Native apps commonly communicate with these backends via REST APIs or GraphQL, depending on the data structure and interaction required. Conclusion In conclusion, the decision comes down to your app’s goals, budget, and the complexity of features you need. BaaS solutions can be a quick, cost-effective option for businesses aiming to launch an MVP or a simple app with limited backend demands. However, for apps that require high customization, seamless integrations, or handle sensitive data, a custom backend offers the control, flexibility, and scalability needed for long-term success. If you’re ready to discuss your app’s backend needs, book a free consultation with SupremeTech. With extensive experience in building high-performance systems for applications serving millions of users, our team can guide you toward a backend solution designed to meet your unique goals.

                        09/11/2024

                        221

                        Linh Le

                        Knowledge

                        +1

                        • Software Development

                        Choosing A Good Backend For React Native Apps

                        09/11/2024

                        221

                        Linh Le

                        what is customer data integration and why it is important for omo retail

                        Knowledge

                        Online-Merge-Offline Retail

                        +0

                          What is Customer Data Integration (CDI) and why it is important for OMO retail?

                          Hi business operators, having a unified view of customer base across various channels can make all the difference. By leveraging customer data integration, businesses can improve customer satisfaction, boost sales, and stay ahead in a rapidly evolving marketplace. This procedure is even more important for OMO retail because of the complexity of customer data the business needs to handle across online and offline sales channels. In this article, we will give answer to the question What is Customer Data Integration and its role for OMO retail. What is Customer Data Integration (CDI)? In short, customer data integration (CDI) involves consolidating information from in-store purchases, online transactions, social media interactions, and more into a single database. This streamlined approach not only enhances customer experiences by enabling personalized marketing and efficient service. It also provides valuable insights that drive strategic decision-making. Most Common Types of Customer Data Integration Customer Data Integration (CDI) can be categorized into several types based on the methods of integration, data sources, and the technology used. Here are some primary types of customer data integration: Batch Data Integration The first type involves collecting and processing data at scheduled intervals rather than in real-time. This method is commonly used for large volumes of data that do not require immediate processing. Data is extracted from various sources, transformed into a consistent format, and then loaded into a target database or data warehouse during off-peak hours to minimize system impact. This type is ideal for routine tasks such as nightly data backups, end-of-day transaction processing, and periodic data synchronization between systems. Key benefits of Batch Data Integration Efficient for processing large datasetsReduces load on systems during business hoursSimplifies data management by handling updates in bulk. Real-Time Data Integration The second type involves integrating data during generation, providing up-to-the-minute information. This method is essential for applications that require immediate data updates and insights. Data is captured and transmitted instantly from various sources to a central system using real-time processing technologies such as message queues, streaming platforms, or APIs. Real-time integration is crucial for applications like live customer support, fraud detection, personalized marketing, and dynamic pricing. Key benefits of Real-Time Data Integration Ensures timely and accurate data availabilityEnhances decision-making with current dataImproves customer experience by enabling immediate responses and interactions API-Based Data Integration The third type, API-based data integration, uses Application Programming Interfaces (APIs) to enable data sharing and integration between different systems and applications. This method supports both real-time and on-demand data exchanges. APIs allow applications to communicate and exchange data directly. Developers can create, manage, and consume APIs to facilitate seamless data flow between disparate systems. API-based integration is widely used for connecting cloud services, integrating third-party applications, enabling mobile apps to access backend data, and synchronizing data between enterprise systems. Key benefits of API-Based Data Integration Provides flexibility and scalabilitySupports real-time data accessSimplifies integration with various systems and platformsAllows for modular and maintainable integration solutions In general, each type of customer data integration has its own advantages and use cases, and organizations often use a combination of these methods to meet their specific needs and goals. Key components of Customer Data Integration (CDI) Data Collection In the early stage of business, customer data is fragmented and not well-synchronized across sales platforms. It's stored in the database of each sale channel and those channels operate independently. Therefore, the first component of CDI process is to gather the pieces of information. Customer data includes transaction records, social media interactions, customer service interactions, loyalty programs, website visits, and mobile app usage. Data Cleaning and Standardization Then, the second thing is ensuring that the data collected is accurate, complete, and consistent. This involves removing duplicates, correcting errors, filling in missing values, and standardizing data formats. Data Integration Data integration involves merging data from disparate sources into a unified database or data warehouse. This involves using data integration tools and technologies that can handle diverse data formats and large volumes of data. Data Storage and Enrichment Storing the integrated data in a centralized repository, such as a data warehouse or a customer relationship management (CRM) system, to facilitate easy access and analysis. Enhancing the integrated data by adding additional information, such as demographic details, psychographic data, and third-party data, to gain a more complete view of the customer. Data Analysis and Insights This component acts as the foundation of data-based decision making for business. From a huge amount of organized data, data readers can uncover patterns, trends, and insights about customer behavior, preferences, and needs. This can involve using analytics tools and techniques such as machine learning, data mining, and predictive analytics. Customer Segmentation Dividing the customer base into distinct segments based on characteristics such as demographics, purchasing behavior, and preferences. This enables more targeted marketing and personalized customer interactions. Why Customer Data Integration is crucial for Online-Merge-Offline business Customer Data Integration is particularly important for Online-Merge-Offline (OMO) retail because it helps to create a seamless and cohesive shopping experience. Here are key reasons why CDI is essential for OMO retail: Unified Customer Experience First and foremost, CDI ensures the consolidation of customer information from online and offline channels. Customers often switch between online and offline channels during their shopping journey. Regardless of that, they will experience the consistent care whether he is shopping in-store, online, or through a mobile app. CDI helps track these transitions seamlessly. Improved Inventory Management Secondly, CDI provides real-time insights into inventory levels across all channels, helping retailers manage stock more efficiently and meet customer demand promptly. Data-Driven Decision Making By integrating data from both online and offline sources, retailers can gain a holistic view of customer behavior and preferences, enabling better decision-making. Integrated data allows for the analysis of trends and patterns across all channels, informing strategies for marketing, product development, and sales. Conclusion In conclusion, Customer Data Integration (CDI) is a vital strategy for businesses seeking to optimize their operations, enhance customer experiences, and drive growth in today’s competitive market. For retailers, particularly those operating in the F&B sector and OMO environments, the importance of CDI cannot be overlooked. It not only ensures consistency and accuracy across multiple channels but also empowers businesses to respond swiftly to customer needs and market trends. Effective CDI enhances operational efficiency, optimizes inventory management, and supports the development of targeted marketing strategies. Ultimately, CDI leads to increased customer satisfaction and loyalty. Embracing CDI is not just about technology implementation; it’s about creating a customer-centric approach that aligns with the dynamic landscape of modern commerce. SupremeTech has experience in handling data integration for businesses with millions of customers. If you're looking for integration services for large-scale system, book a free consultation with us!

                          11/07/2024

                          539

                          Linh Le

                          Knowledge

                          +1

                          • Online-Merge-Offline Retail

                          What is Customer Data Integration (CDI) and why it is important for OMO retail?

                          11/07/2024

                          539

                          Linh Le

                          what is react native tab view

                          Knowledge

                          Software Development

                          +0

                            An Overview of React Native Tab View

                            Hi tech fellows, it's been a while since our last blog. June is usually among the busiest times of the year as we spent time reviewing and planning for the second half of the year. With all the exciting plans ahead, we hope the rest of 2024 will be both challenging and inspiring. We'll keep you posted in the upcoming articles. But for now, let's dive in the next blog series about React Native Tab View. An Overview of React Native Tab View What is React Native Tab View? React Native Tab View is a powerful component for creating tabbed interfaces in React Native applications. It provides a highly customizable and performant solution for adding tab navigation, which is a common requirement in mobile apps. Here's an overview of its key features and components. Key Features of React Native Tab View Smooth Transitions refers to the seamless and fluid animation that occurs when switching between different tabs. This feature offers smooth and customizable transitions between tabs, enhancing user experience. Customization provides highly customizable solutions with support for styling tabs and the tab bar, allowing developers to match the look and feel of their application. Swipeable Tabs allows users to swipe between tabs, which is a common and intuitive navigation pattern on mobile devices. Lazy Loading supports lazy loading of tab content, which can improve performance by only rendering the tab content when it becomes active. This feature is crucial for apps that prioritize high performance and loading speed. Integration with React Navigation can be easily integrated with React Navigation, providing a seamless navigation experience within the app. Accessibility includes all kinds of accessibility-support features. Key Components of React Native Tab View TabView: The main component that holds the tab navigator. It manages the state and renders the appropriate tab content based on the current index. TabBar: A customizable tab bar component that displays the tab labels and handles the user interaction for changing tabs. TabBarIndicator: A component that renders an indicator under the currently active tab, providing visual feedback to the user. SceneMap: A utility function for mapping routes to their corresponding components. It helps in defining the content for each tab. Basic Usage Example import * as React from 'react'; import { View, Text, StyleSheet } from 'react-native'; import { TabView, SceneMap } from 'react-native-tab-view'; const FirstRoute = () => ( <View style={[styles.scene, { backgroundColor: '#ff4081' }]}> <Text>First Tab</Text> </View> ); const SecondRoute = () => ( <View style={[styles.scene, { backgroundColor: '#673ab7' }]}> <Text>Second Tab</Text> </View> ); export default function TabViewExample() { const [index, setIndex] = React.useState(0); const [routes] = React.useState([ { key: 'first', title: 'First' }, { key: 'second', title: 'Second' }, ]); const renderScene = SceneMap({ first: FirstRoute, second: SecondRoute, }); return ( <TabView navigationState={{ index, routes }} renderScene={renderScene} onIndexChange={setIndex} initialLayout={{ width: Dimensions.get('window').width }} /> ); } const styles = StyleSheet.create({ scene: { flex: 1, justifyContent: 'center', alignItems: 'center', }, }); Customization Tab View can be customized extensively through props and styles. You can style the tab bar, change the indicator color, customize the transition animations, and more. Here are a few common customizations: Tab Bar Styling renderTabBar={props => ( <TabBar {...props} indicatorStyle={{ backgroundColor: 'blue' }} style={{ backgroundColor: 'white' }} labelStyle={{ color: 'black' }} /> )} Custom Transitions renderScene={SceneMap({ first: FirstRoute, second: SecondRoute, })} transitionSpec={{ duration: 250, easing: Easing.out(Easing.exp), timing: Animated.timing, }} Conclusion React Native Tab View is a versatile and efficient component for implementing tab navigation in mobile apps. Its flexibility, ease of integration, and support for various customizations make it a popular choice among React Native developers. Whether you need basic tab functionality or advanced features like lazy loading and custom transitions, it provides the tools to create a polished and user-friendly tabbed interface. Contact us if you want an optimized native apps for your company!

                            10/07/2024

                            848

                            Linh Le

                            Knowledge

                            +1

                            • Software Development

                            An Overview of React Native Tab View

                            10/07/2024

                            848

                            Linh Le

                            best practices for react native iap

                            Knowledge

                            Software Development

                            +0

                              Best Practices for React Native IAP (In-App Purchases)

                              Hi coders, this is the second article in a series about React Native IAP (In-App Purchases). In the first article, we've gone through how to implement IAP in a React Native App. It's essential to implement IAP carefully to ensure a seamless user experience and maintain compliance with platform guidelines. In this article, we will explore the best practices for React Native IAP, covering aspects such as user experience, security, compliance, and optimization strategies to help you get the most out of your in-app purchase implementation. By following these guidelines, you can create a robust and effective IAP system for your app. Choose the Right Library Choosing a reliable library is the first step in implementing IAP in your React Native app. The react-native-iap library is a popular choice due to its comprehensive features and support for both iOS and Android platforms. This library simplifies the process of adding in-app purchases, managing subscriptions, and handling transactions. User Experience and Flow A seamless user experience is vital for successful in-app purchases. Here are some best practices to ensure a smooth purchase flow: Clear and Concise UI: Design a straightforward and intuitive purchase interface. Use clear labels and descriptions for each product, and make sure users understand what they are buying.Pre-Purchase Information: Provide all necessary information before the purchase. This includes the price, benefits, and any recurring charges for subscriptions. Transparency helps build trust with users.Error Handling: Handle errors gracefully. Inform users if something goes wrong during the purchase process and provide steps to retry or contact support. Compliance with App Store Guidelines Both the Apple App Store and Google Play Store have strict guidelines for in-app purchases. Here’s how to ensure compliance: Product Approval: Ensure all products and subscriptions are approved by the respective app stores before making them available for purchase. Unapproved products can lead to app rejections.Subscription Management: Allow users to manage their subscriptions easily. Include options to view, cancel, or modify subscriptions directly within the app or through links to the app stores.Consistent Pricing: Ensure that the pricing of products and subscriptions is consistent with what is listed in the app stores. Any discrepancies can lead to user dissatisfaction and potential compliance issues. Security Considerations Security is paramount when dealing with financial transactions. Implementing secure practices protects both your app and its users. Receipt Validation: Validate purchase receipts to ensure they are legitimate. This can be done on the client-side for initial verification and on the server-side for additional security.javascript Secure Storage: Store sensitive information, such as receipts and purchase tokens, securely. Use secure storage solutions provided by React Native or third-party libraries.Handle Fraud: Implement measures to detect and prevent fraudulent purchases. Monitor purchase patterns and use server-side validation to verify transactions. Handling Edge Cases Edge cases can occur due to various reasons, such as network issues, interrupted purchases, or device compatibility problems. Here’s how to handle them: Network Issues: Ensure your app can handle network disruptions. Implement retry mechanisms for failed purchases and inform users about the issue.Interrupted Purchases: Handle cases where a purchase is interrupted, such as app crashes or user cancellations. Check the purchase status upon app restart and complete any pending transactions. Device Compatibility: Test your IAP implementation on various devices and operating system versions to ensure compatibility and a smooth user experience. Optimizing Monetization To maximize revenue, optimize your in-app purchase offerings and strategies. Product Variety: Offer a range of products and subscriptions to cater to different user needs and budgets. Include consumables, non-consumables, and subscription options.Promotions and Discounts: Run promotional campaigns and offer discounts to attract new users and retain existing ones. Use the app store’s promotional tools to manage these offers.Analytics: Use analytics to track purchase behavior and user engagement. This data helps you understand what works and allows you to refine your offerings and strategies. Regular Updates and Testing Regular updates and thorough testing are crucial for maintaining a robust IAP system. Frequent Updates: Keep your IAP implementation up to date with the latest versions of the react-native-iap library and other dependencies. Regular updates ensure compatibility and security.Testing: Test your IAP functionality thoroughly in a sandbox environment before releasing it to users. This helps catch and fix any issues early on. What's more after best practices for React Native IAP? Implementing React Native IAP effectively requires careful attention to user experience, security, compliance, and monetization strategies. By following best practices, you can ensure a smooth purchase process for users and boost your app's revenue. To further enhance your app, explore advanced features and customizations, such as promotional offers and branded purchase flows. Focus on security to prevent fraud and validate receipts securely. Troubleshooting common issues can improve user satisfaction. Address bugs, use debugging tools, and leverage community solutions. Also, consider localization to support multiple currencies and languages, comply with regional regulations, and tailor offerings to local preferences. Stick around! We will be back soon for the next episode in this series.

                              23/05/2024

                              793

                              Linh Le

                              Knowledge

                              +1

                              • Software Development

                              Best Practices for React Native IAP (In-App Purchases)

                              23/05/2024

                              793

                              Linh Le

                              Customize software background

                              Want to customize a software for your business?

                              Meet with us! Schedule a meeting with us!