Code Monkey home page Code Monkey logo

specialdna's Introduction

Special DNA Detector

This project is an application developed in Node.js that detects if a human has "special" DNA. Special DNA is defined as a DNA sequence that contains more than one sequence of four identical letters, whether diagonally, horizontally, or vertically.

Prerequisites

Before running this project, make sure you have the following components installed:

  • Nodejs >= 18.0
  • npm >= 10.0
  • MySQL
  • GIT

Project Setup

  1. Clone the project repository:

    git clone <URL_DE_TU_REPOSITORIO>
  2. Navigate to the project directory:

    cd <NOMBRE_DEL_DIRECTORIO>
  3. Install the packages listed in the package.json file:

    npm install

Installing Redis Server

Redis is required to handle the project's cache. To install it, run the following commands:

sudo apt install redis-server
sudo nohup redis-server &

Installing Kafka

Kafka is a distributed data streaming platform used for building real-time applications.

  1. Install JDK, required to run Kafka:

    sudo apt install default-jdk
  2. Download the latest version of Kafka:

    wget https://dlcdn.apache.org/kafka/3.8.0/kafka_2.13-3.8.0.tgz
  3. Extract the downloaded file:

    tar -xzf kafka_2.13-3.8.0.tgz
  4. Change to the Kafka directory:

    cd kafka_2.13-3.8.0
  5. Start Zookeeper:

    sudo nohup bin/zookeeper-server-start.sh config/zookeeper.properties &
  6. Start Kafka:

    sudo nohup bin/kafka-server-start.sh config/server.properties &
  7. Verify that Kafka is running:

    bin/kafka-topics.sh --list --bootstrap-server localhost:9092

Installing K6 (Optional)

K6 is a tool used for performing load testing on the API. Follow these steps to install it:

sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys   C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6

Running the Application

After installing all the necessary dependencies and services, you can run the application using:

  npm start

Running Tests

You can run the unit tests with the following command:

  npm test

Running Load and Stress Tests

You can run load and stress tests with the following command:

  k6 run stressTest.js

Running The Application Without Docker

  1. Make sure you have the following prerequisites installed before getting started:

  2. Set up environment variables

    Create a .env file in the root of the project with the necessary environment variables.

  3. Build and run the containers

    Run the following command to build the Docker images and start the containers:

    docker-compose up

    This command will start the services defined in the docker-compose.yml file, including the MySQL database, Redis, Kafka, and the Node.js application.

  4. Verify the application is running

    Once the containers are up and running, you can access the application at http://localhost:3000.

  5. Stress testing with K6

    To run the stress test, use the following command:

    docker-compose up k6

    Replace with the name of the K6 container that is running.

  6. Stop the containers

    To stop and remove the containers, you can run:

    docker-compose down
  7. Common Issues

    • Error connecting to Redis/Kafka/MySQL: Ensure that the services are running correctly and that the environment variables in the .env file are properly configured.

    • Ports in use: If you encounter port conflicts, make sure that the ports defined in docker-compose.yml are not being used by other services on your local machine.

API Documentation

The API documentation was generated using Swagger and can be accessed via the GET /api-docs route at the URL where the application is deployed.

specialdna's People

Contributors

carlosma22 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.