Code Monkey home page Code Monkey logo

cosmverseflex's Introduction

███████╗██╗     ███████╗██╗  ██╗███╗   ██╗███████╗████████╗    ███████╗████████╗ █████╗  ██████╗██╗  ██╗
██╔════╝██║     ██╔════╝╚██╗██╔╝████╗  ██║██╔════╝╚══██╔══╝    ██╔════╝╚══██╔══╝██╔══██╗██╔════╝██║ ██╔╝
█████╗  ██║     █████╗   ╚███╔╝ ██╔██╗ ██║█████╗     ██║       ███████╗   ██║   ███████║██║     █████╔╝ 
██╔══╝  ██║     ██╔══╝   ██╔██╗ ██║╚██╗██║██╔══╝     ██║       ╚════██║   ██║   ██╔══██║██║     ██╔═██╗ 
██║     ███████╗███████╗██╔╝ ██╗██║ ╚████║███████╗   ██║       ███████║   ██║   ██║  ██║╚██████╗██║  ██╗
╚═╝     ╚══════╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═══╝╚══════╝   ╚═╝       ╚══════╝   ╚═╝   ╚═╝  ╚═╝ ╚═════╝╚═╝  ╚═╝
                                                                                                        

README.md

git clone --recurse-submodules [email protected]:cryptoversus-io/Stack-Config.git

==========

Introduction

Dapp Application is a robust web application leveraging Kotlin with Javalin for serving web content and handling backend logic, integrated with Rust for data processing and shell scripts for automation. The project's core lies in its ability to efficiently process data while offering a user-friendly interface.

  • This Dapp Application is a simple Kotlin-based web project using Javalin to serve a web page and handle backend logic.
  • The project includes a Dapp.kt Kotlin file as the main class and a home.html file for the frontend.

Prerequisites


Project Structure


  • Development/src/main/kotlin/com/base/: Contains Kotlin source files.
  • Development/src/main/resources/static: Houses static resources like HTML files for the frontend.
  • Development/src/main/rust/: Contains Rust source files for file processing tasks.
  • Development/scripts/indexing.sh: Bash script to automate file processing and deduplication tasks.
  • target/: Rust build artifacts are placed here by Cargo.
  • Cargo.toml: Configuration file for Rust project management.

Project Structure

=============

cosmverseflex.git
|
├── Development (cosmverse.git)
│   |
|   src/
│   ├── main/
│   │   ├── kotlin/
│   │   │   └── com/
│   │   │       └── base/
│   │   │           └── DappKt.kt  # Main Kotlin server file
│   │   │
│   │   ├── resources/
│   │   │   └── static/
│   │   │       └── home.html        # Main entry point for the frontend
│   │   │
│   │   └── rust/
│   │       ├── preprocess_file.rs  # Rust script for preprocessing data
│   │       └── deduplicate_file.rs # Rust script for deduplicating data
│   │
│   └── scripts/
│   |    └── indexing.sh             # Shell script for managing tasks
│   │
│   │
│   └──
│   
├── build.gradle.kts                # Gradle build configuration file
├── settings.gradle.kts             # Gradle settings file
└── gradlew                         # Gradle wrapper executable

Execution Flow

  • File Preprocessing:

    • Rust code in preprocess_file.rs cleans files in SOURCE_DIR. Processed files are stored in PROCESSED_DIR.
  • File Deduplication:

    • Rust code in deduplicate.rs removes duplicates from files in PROCESSED_DIR.
    • Deduplicated files are stored in DEDUP_DIR.
  • Script Automation:

    • indexing.sh shell script automates preprocessing and deduplication, triggerable manually or via cron job. Database Indexing (if applicable):
  • Include logic in Rust code or additional scripts to update databases using data from DEDUP_DIR.

Setup Instructions


  1. FORK then Clone your own forked repo.
  2. Open the project in your IDE aka VSCodium
  3. Ensure that the JDK is properly set up in your IDE.

FOR DOCKER IMAGE

  • Go to Dapp directory in terminal
# If you Don't have Docker
mkdir -p ~/.docker/cli-plugins/
curl -L "https://github.com/docker/buildx/releases/download/v0.13.1/buildx-v0.13.1.linux-amd64" -o ~/.docker/cli-plugins/docker-buildx
chmod a+x ~/.docker/cli-plugins/docker-buildx
export DOCKER_CLI_PLUGIN_DIR=~/.docker/cli-plugins
export DOCKER_BUILDKIT=1
 # Build the Docker image
DOCKER_BUILDKIT=1 docker build -t dapp-application .
 # Run the Docker container
docker run -p 8080:8080 dapp-application

Building the Project


  • For Kotlin components:

    • Build: ./gradlew build
    • Run: ./gradlew run
  • For Rust components:

    • Build: cargo build
    • Run: cargo run --bin my_binary
  1. Navigate to the root directory of the project via the terminal or command prompt.
  2. Run the following command to build the project: 'gradle clean build'
  • To use the Gradle Wrapper use ./gradlew clean build
  • If ./gradlew permission is denied run chmod +x gradlew
  1. If the build is successful, you should see a BUILD SUCCESSFUL message in the terminal.

                                  _                     
     )|(           +++           ((_           \|/      
    (o o)         (o o)         (o o)         (o o)     
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Running the Application


To clean Rust artifacts

./gradlew cleanRust

To build Rust code

./gradlew buildRust

To copy the built binaries to the specified directory

./gradlew copyRustBinaries

To build your entire project, including Rust components

./gradlew build

  1. To run the application, execute: gradle run

    • or ./gradlew run
  2. Once the application starts, it will be accessible at http://localhost:8080.

  3. Open a web browser and navigate to http://localhost:8080 to view the home.html page.

Running File Processing and Deduplication

Execute the indexing.sh script to start the file processing and deduplication. This script will look for files in the specified source directory and perform operations.

  • Edit your directories you wish to use
./scripts/indexing.sh [source_directory] [processed_directory] [dedup_directory]

How Each Component Works


Kotlin/Javalin Server (DappKt.kt):

This is the core of your server application. It initializes a Javalin server which listens on port 8080.

The server configures static file handling to serve home.html directly from the /static directory. This setup ensures that users can access the web interface by navigating to http://localhost:8080/home.html in their browser. The server also defines endpoints for API operations which might interact with the Rust scripts or handle other backend logic. HTML Frontend (home.html):

  • Located in the /static directory, this file acts as the main interface for user interaction. It includes forms and scripts to communicate with the backend via AJAX requests, handling tasks such as user verification or data processing. This file uses JavaScript to make asynchronous requests to the server endpoints defined in the Kotlin application, facilitating dynamic content updates without page reloads.

Rust Scripts:

  • preprocess_file.rs and deduplicate_file.rs located in the /rust directory are designed to perform data processing tasks. These scripts can be invoked from the Kotlin server using ProcessBuilder or through the shell script for batch processing.

Shell Script (manage.sh):

  • This script in the /scripts directory helps in managing routine tasks like starting the server or processing files through Rust binaries. It can be manually executed or scheduled via cron jobs to automate batch processing tasks.

Gradle Configuration (build.gradle.kts and settings.gradle.kts):

  • These files configure how the project is built and run. They ensure that all dependencies are properly managed and compile the Kotlin application correctly.

User Interaction Flow

Accessing the Website:

  • Users access the Dapp application by visiting http://localhost:8080/home.html after the server has been started using the Gradle wrapper command ./gradlew run. The home.html page serves as the user interface, allowing them to interact with the application through forms and buttons that trigger AJAX calls.

Backend Interaction:

  • When a user submits data via the frontend (for instance, uploading a file for processing), the AJAX calls hit the endpoints defined in the Kotlin application. Depending on the functionality, these endpoints might process data immediately using Rust scripts or queue tasks for later processing.

File Usage:

  • HTML, CSS, JavaScript, and images are served statically from the /static directory, ensuring quick loading and separation of static content from server logic. Changes or Confirmations Needed

To finalize your setup and ensure everything functions as expected, you should:

  • Test all endpoints to confirm that they correctly handle requests and interact with the Rust scripts as intended. Review static file paths in both the server setup and HTML references to ensure they align and are accessible via the web browser. Ensure error handling is robust in both frontend and backend to gracefully manage any issues during operation. By following these guidelines and setups, your Dapp application should provide a seamless and efficient user experience, leveraging the strengths of Kotlin, Rust, and shell scripting within a well-organized project structure.
***************************************************
*  ____  ___   ___  ____    _    _   _  ____ _  __*
* / ___|/ _ \ / _ \|  _ \  | |  | | | |/ ___| |/ /*
*| |  _| | | | | | | | | | | |  | | | | |   | ' / *
*| |_| | |_| | |_| | |_| | | |__| |_| | |___| . \ *
* \____|\___/ \___/|____/  |_____\___/ \____|_|\_\*
*************************************************** 

Contributions and Contact

  • For contributions, please open a pull request or an issue.
  • For questions or support, contact @NinjaAssPirate | @KitBaroness

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.