DEV Community

Cover image for Integrate Daytona into a Machine Learning Project with React, Node, and Python
Subash-Lamichhane
Subash-Lamichhane

Posted on

Integrate Daytona into a Machine Learning Project with React, Node, and Python

Being a Developer, You Know the Struggle

If you’ve ever spent hours just setting up someone else’s project from github then you’re not alone. It’s frustrating, tedious, and downright unproductive for both the project creator and anyone trying to use it. Many developers give up midway because the setup process feels like wading through quicksand. So, what’s the solution?

Meet Daytona, the hero you didn’t know you needed! 🦸‍♂️


Introduction to Daytona

Daytona is a self-hosted development environment manager that simplifies and makes setting up projects lightning-fast ⚡. It’s designed to simplify and accelerate workflows, whether you’re working on remote development or managing environments as code. Daytona takes the hassle out of complex setups, letting you focus on what truly matters—building and creating.

As Daytona puts it:
“Your team should spend less time configuring and more time creating.”

This image from Daytona clearly explains how you can save your time and hassle with Daytona.

GitHub logo daytonaio / daytona

The Open Source Dev Environment Manager.


Daytona logo

Documentation License Go Report Card Issues - daytona GitHub Release
Open Bounties Rewarded Bounties


Daytona - Dev environment manager that makes you 2x more productive | Product Hunt Daytona - Dev environment manager that makes you 2x more productive | Product Hunt

The Open Source Development Environment Manager

Set up a development environment on any infrastructure, with a single command

Documentation · Report Bug · Request Feature · Join Our Slack · Twitter

Features

  • Single Command: Activate a fully configured development environment with a single command.
  • Runs everywhere: spin up your development environment on any machine — whether it's local, remote, cloud-based, physical server, or a VM & any architecture x86 or ARM.
  • Configuration File Support: Initially support for dev container, ability to expand to DevFile, Nix & Flox (Contributions welcome here!).
  • Prebuilds System: Drastically improve environment setup times (Contributions welcome here!).
  • IDE Support : Seamlessly supports VS Code & JetBrains locally, ready to use without configuration. Includes a built-in Web IDE for added convenience.
  • Git Provider Integration: GitHub, GitLab, Bitbucket, Bitbucket Server, Gitea, Gitness, Azure DevOps, AWS CodeCommit, Gogs & Gitee can be connected, allowing…

Why Daytona? 🤔

Let’s address the elephant in the room: Why should you use Daytona? The better question is, why shouldn’t you? Here’s what makes Daytona a developer’s best friend:

1. Speed and Agility: Daytona’s architecture is all about getting things done quickly and adapting to challenges on the fly. 🏎️
2. Commitment to Execution: It ensures every project, no matter how complex, is executed with precision and excellence. 🛠️
3. Proactivity: Daytona anticipates your needs, making it a proactive partner in your development process. 🔮
Key Features of Daytona:

  • Security: Securely connects your local machine and remote environments without manual port forwarding. 🔒
  • IDE Support: Works seamlessly with Visual Studio Code and JetBrains IDEs, giving you a local-like development experience. 💻
  • SCM Integration: Pull repositories from GitHub, GitLab, Bitbucket, or Gitea directly into Daytona workspaces. 🔗
  • Multi-Project Workspaces: Perfect for working on microservices or multi-repository projects within a single workspace. 🗂️
  • Reverse Proxy Support: Access workspaces on public or restricted networks with ease. 🌐
  • Extensible Core: Customize Daytona with plugins written in Go, adding functionality tailored to your needs. 🛡️

How I Integrated Daytona into TerraGrow (my project):

What is TerraGrow? 🌱

TerraGrow is an intelligent web app that uses a Random Forest model for crop recommendations and the Llama3-8b-8192 model from Groq to suggest yield improvement strategies. By analyzing factors like nitrogen (N), phosphorus (P), potassium (K), temperature, humidity, and pH, it helps farmers make smarter planting decisions.

TerraGrow

The Challenge: 🤯 Integrating Python with Node.js and machine learning models made TerraGrow’s project structure complex. I wanted other developers to run it effortlessly, but the setup process was daunting. That’s when I discovered Daytona (thanks to Quira’s Quest 23—shoutout to Quira!).

Here’s how I did it, and how you can do it too:

Step 1: Setting Up Daytona 🚀
I installed Daytona on my Linux machine using its straightforward installation guide. With Docker pre-installed, the setup was a breeze:

(curl -sf -L https://download.daytona.io/daytona/install.sh | sudo bash) && daytona server -y && daytona
Enter fullscreen mode Exit fullscreen mode

For detailed instructions, check out Daytona’s installation guide.

Step 2: Adding devcontainer.json 🛠️
Next, I created a devcontainer.json file inside the .devcontainer folder.
For this, Devcontainer.ai helped me generate the initial file, though I had to tweak it for my needs.
Here’s the final version:

{
    "name": "React + Node.js Dev Container",
    "image": "mcr.microsoft.com/devcontainers/javascript-node:18",
    "features": {
      "python": "3.10"
    },
    "forwardPorts": [
      3000,
      5000
    ],
    "postCreateCommand": "cd frontend && npm install && cd ../backend && pip install -r requirements.txt && npm install"
}

Enter fullscreen mode Exit fullscreen mode

I then pushed these updates to the GitHub repository.

Step 3: Creating a Workspace 🖥️
To run the daytona you can run

daytona serve
Enter fullscreen mode Exit fullscreen mode

You can also access available options using command daytona through your terminal.

Daytona

Once Daytona was up and running, I launched it with the daytona command. The interface was sleek and intuitive. To create a workspace, I used:

daytona create https://github.com/Subash-Lamichhane/TerraGrow-daytona
Enter fullscreen mode Exit fullscreen mode

This command pulled my repository and set up the workspace. Boom—everything was ready to go! 🎉
Note: If you are using vite for creating react project then you must change "dev": "vite ",section in package.json to "dev": "vite --host 0.0.0.0",to run the frontend in the workspace.


Conclusion 🎯

Integrating Daytona into TerraGrow made my project more accessible, streamlined, and developer-friendly. The once-complicated setup became a breeze, allowing others to run it effortlessly.
So, whether you’re working on a small website or a large-scale project, Daytona can save you time, headaches, and frustration.
Trust me, it’s a game-changer. Try it out, and let the coding fun begin!


Here are some helpful links:

My Project: Check out TerraGrow on GitHub to see the code and learn how it all works.
Demo Video: Watch the TerraGrow demo video to see it in action.
Daytona: Discover more about Daytona on their GitHub page.
Quira: Learn about Quira, the platform that introduced me to Daytona, by visiting their website.

Top comments (2)

Collapse
 
sujankoirala021 profile image
Sujan Koirala

Thank you so much for introducing me to this wonderful product! Now I have plenty of time aside from setting up the project.

Collapse
 
elite123 profile image
Elite

Working with daytona was breeze.