user7760: I'm from ETH's ecosystem and recently just decided to get into Cardano development, specifically Plutus dev work thanks to Demeter.Run, and after going through the Plutus starters on there, I noticed there weren't any guides on how to start a fresh project from scratch. I did a speedrun through the latest iteration of the Plutus Pioneer course and found out that most of the work was either done in the Playground, the Repl, or built from the top of an existing project(which still doesn't add up to me).
Tried moving some sample .hs code from Plutus-apps and Alonzo-testnet repos hoping to compile and submit them for my own experience and only ended up fighting with GHC and Cabal errors because the sample code used other dependencies and structures different from the secondhand project I was guided to build on top of.
I don't want to start a project by piggybacking on some already existing files and .cabal and .project configs with specs I don't know/understand.
If I was starting a NodeJs project I'd begin with npm init then go from there
My question is, how can I start a new Plutus project from scratch such that I know

how to setup my .cabal file dependencies
how to setup what's needed for the .project file
where to input my fresh code (or borrowed code from Plutus-apps samples to test) because there's the "main.hs" in the app folder which I learned from Haskell but Plutus samples put their .hs code files in the "src" folder, the "main.hs" in the app folder contains something completely different.
how to compile my .hs to .plutus

Everything that comes after these 4 steps i.e. submitting that new .plutus file to the chain (serialised) and building Tx's I know how to do.
I am using Demeter.Run and working from the Terminal and Cardano-CLI from the workspaces, I am under the impression every dependency from IOHK/IOG is setup. I don't know nix and the plutus starter samples didn't need that so hope to progress that way.
I have very minimal Haskell but learning the basics hasn't been tough but I'm good with front-end Javascript and some Solidity.
Please be as detailed/technical as you like, thank you.
Note: I went through the previous questions posed in the links below but still did not get it.
Starting a new Plutus Project
How to Start a New Project

user7460: Since this question was posted Plutus-alternatives have been developed by the community that allow doing DApp development in JavaScript only. One such library is https://github.com/hyperion-bt/Helios
https://www.hyperion-bt.org/Helios-Book/api/picoswap/index.html is a step-by-step guide on how to implement a simple marketplace. The example code can be found here, and a demo is hosted here

user2335: A well formatted question deserves a well formatted answer! I will go into some depths, but also keep some things at a “magical” level. This is a long read so take your time!
Before we start, it is good to note that most of the Cardano stack is written in Haskell, and thus, managing a Plutus project is just managing a Haskell project. There are multiple ways of doing this, just a plain Cabal project or one of the many Nix ways of building (cabal2nix, Haskell.nix and many others). Now there are good reason to use these Nixs ways (most notably reproducibility and caching), but in this answer I will focus on a more understandable way of just using GHC + cabal on Ubuntu 22.04 (not the minimal install).
A disclaimer, building everything yourself requires lots of ram (you can also re-run the cabal run command if you run out of memory mid-process). The good thing, however, once build you have these Haskell artifact locally prebuilt in your ~/.cabal/ folder.
The dependencies
Before we can even build a general all-purpose Haskell/plutus project, we need some basic building tools necessary to even start compiling! These mainly consist of the following tools,

OS dependent dependencies
GHC and Cabal
A special version of libsodium
A special version of libsecp256k1

OS dependent dependencies
To build everything, you at least need these dependencies
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 curl libtool postgresql libpq-dev autoconf -y

Note that translating these OS dependent dependencies to other operating systems is hard and out of the scope of this post (this is why you might want nix). They may also change in the future as the project might add new dependencies.
GHC and Cabal
It is recommended by IOG to use GHC version 8.10.7 and Cabal version 3.6.2.0. These can be installed via GHCUP via,
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

You can press enter for all question the installer asks. Then reload your terminal (to make ghcup appear in your path) and,
ghcup install ghc 8.10.7
ghcup set ghc 8.10.7
ghcup install cabal 3.6.2.0
ghcup set cabal 3.6.2.0

Reload your terminal again to make these appear in your path and set
cabal configure --with-compiler=ghc-8.10.7

A special version of libsodium
Libsodium is a tool chain (written for performance) for cryptographic derivatives, for example you can create signatures and hashes with it. We require a particular version of it that adds VRF cryptography to it (used for the Cardano consensus mechanism). Installing this can be done via,
git clone https://github.com/input-output-hk/libsodium
cd libsodium
git checkout 66f017f1
./autogen.sh
./configure
make
sudo make install

In addition to this add the following to your ~/.bashrc and reload your terminal again to add it to your path
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"

A special version of libsecp256k1
Since the Vasil hard fork Cardano has the secp256K1 signature scheme available in plutus. This allows for the validation of Bitcoin signatures and will make it easier to build bridges. Bitcoin is not the only blockchain that use this signature scheme, many others do. So to install this library (again a particular audited version) you use,
git clone https://github.com/bitcoin-core/secp256k1
cd secp256k1
git checkout ac83be33
./autogen.sh
./configure --enable-module-schnorrsig --enable-experimental
make
make check
sudo make install

A preconfigure project
We are ready to build a Plutus project! Before I tell how you can set up such a project, I want to share an already set up example. This so that you can test that you correctly installed the dependencies above. To run this example you use
git clone https://github.com/perturbing/example-project-basic.git
cd example-project-basic
cabal update
cabal run

I would like to reiterate, if you do not have sufficient ram available, for example because you run this example in a VM, you can cabal run again if your memory overflows. This example ran for me in a vm with 10gb ram.
Now how is this project setup?
This project and its structure is not constructed arbitrarily. It is namely derived from the latest release of the plutus-apps repository. This repository and its management of dependencies is chosen because it imports and exposes almost all important Haskell packages written for Cardano.
Now, how to concretely set up and copy the essential bits of this repo? It consists of the following steps.
To start we execute
mkdir my-plutus-project
cd my-plutus-project
cabal init
touch cabal.project

You could also use the flag --interactive for a more detailed set up with cabal init.
Next, we copy the cabal.project file of plutus-apps from its latest release (do not pick the main branch, consider this is unstable). Currently, the latest version of this file is this. Next, we need to adjust some pieces of this file to make it work for us.
The first thing to change, this cabal.project file does not import the plutus-apps repo (since it was part of the original one). So, we need to add that by changing the code that declared the to build packages of the plutus-apps repo. It also does not declare our new build artifacts of our cabal project, we have to change the exposed packages it has to build. Both can be achieved by changing,
packages: cardano-streaming
          doc
          freer-extras
          marconi
          marconi-mamba
          playground-common
          pab-blockfrost
          plutus-chain-index
          plutus-chain-index-core
          plutus-contract
          plutus-contract-certification
          plutus-example
          plutus-ledger
          plutus-ledger-constraints
          plutus-pab
          plutus-pab-executables
          plutus-script-utils
          plutus-tx-constraints
          plutus-use-cases
          rewindable-index

to
packages: ./

source-repository-package
    type: git
    location: https://github.com/input-output-hk/plutus-apps
    tag: the_latest_release_tag_used_here_CHANGE_ME!!!
    subdir: 
          cardano-streaming
          doc
          freer-extras
          marconi
          marconi-mamba
          playground-common
          pab-blockfrost
          plutus-chain-index
          plutus-chain-index-core
          plutus-contract
          plutus-contract-certification
          plutus-example
          plutus-ledger
          plutus-ledger-constraints
          plutus-pab
          plutus-pab-executables
          plutus-script-utils
          plutus-tx-constraints
          plutus-use-cases
          rewindable-index

Next up, we can add to our executables and/or libraries on which modules they depend. For example, we might add to our my-plutus-project.cabal file that the executable depends on
    build-depends:    base ^>=4.14.3.0
                    , aeson
                    , bytestring
                    , containers
                    , cardano-api
                    , data-default
                    , plutus-ledger
                    , plutus-ledger-api
                    , plutus-ledger-constraints
                    , plutus-script-utils
                    , plutus-tx-plugin
                    , plutus-tx
                    , text
                    , serialise

And lastly, we can write our app/Main.hs file to execute some functions for us. A simple cabal update and a cabal run will execute your Main.hs executable.
Some last words
This is a long answer, and in no way is complete. I advise anyone who is eager to learn more about Haskell to take the Haskell course from IOG (it also covers cabal!). I hope this gets you started!

7760: <p>I'm from ETH's ecosystem and recently just decided to get into Cardano development, specifically Plutus dev work thanks to Demeter.Run, and after going through the Plutus starters on there, I noticed there weren't any guides on how to start a <strong>fresh</strong> project from <strong>scratch</strong>. I did a speedrun through the latest iteration of the Plutus Pioneer course and found out that most of the work was either done in the Playground, the Repl, or built from the top of an existing project(which still doesn't add up to me).</p>
<p>Tried moving some sample .hs code from Plutus-apps and Alonzo-testnet repos hoping to compile and submit them for my own experience and only ended up fighting with GHC and Cabal errors because the sample code used other dependencies and structures different from the secondhand project I was guided to build on top of.</p>
<p>I don't want to start a project by piggybacking on some already existing files and .cabal and .project configs with specs I don't know/understand.</p>
<p>If I was starting a NodeJs project I'd begin with <code>npm init</code> then go from there</p>
<p>My question is, how can I start a new Plutus project from scratch such that I know</p>
<ol>
<li>how to setup my .cabal file dependencies</li>
<li>how to setup what's needed for the .project file</li>
<li>where to input my fresh code (or borrowed code from Plutus-apps samples to test) because there's the &quot;main.hs&quot; in the app folder which I learned from Haskell but Plutus samples put their .hs code files in the &quot;src&quot; folder, the &quot;main.hs&quot; in the app folder contains something completely different.</li>
<li>how to compile my .hs to .plutus</li>
</ol>
<p>Everything that comes after these 4 steps i.e. submitting that new .plutus file to the chain (serialised) and building Tx's I know how to do.</p>
<p>I am using Demeter.Run and working from the Terminal and Cardano-CLI from the workspaces, I am under the impression every dependency from IOHK/IOG is setup. I don't know nix and the plutus starter samples didn't need that so hope to progress that way.</p>
<p>I have very minimal Haskell but learning the basics hasn't been tough but I'm good with front-end Javascript and some Solidity.</p>
<p>Please be as detailed/technical as you like, thank you.</p>
<p>Note: I went through the previous questions posed in the links below but still did not get it.</p>
<p><a href="https://cardano.stackexchange.com/questions/7794/starting-a-new-plutus-project">Starting a new Plutus Project</a></p>
<p><a href="https://cardano.stackexchange.com/questions/7339/how-to-start-a-new-project">How to Start a New Project</a></p>
 7460: <p>Since this question was posted Plutus-alternatives have been developed by the community that allow doing DApp development in JavaScript only. One such library is <a href="https://github.com/hyperion-bt/Helios" rel="nofollow noreferrer">https://github.com/hyperion-bt/Helios</a></p>
<p><a href="https://www.hyperion-bt.org/Helios-Book/api/picoswap/index.html" rel="nofollow noreferrer">https://www.hyperion-bt.org/Helios-Book/api/picoswap/index.html</a> is a step-by-step guide on how to implement a simple marketplace. The example code can be found <a href="https://github.com/hyperion-bt/PicoSwap" rel="nofollow noreferrer">here</a>, and a demo is hosted <a href="https://www.hyperion-bt.org/PicoSwap" rel="nofollow noreferrer">here</a></p>
 2335: <p>A well formatted question deserves a well formatted answer! I will go into some depths, but also keep some things at a “magical” level. This is a long read so take your time!</p>
<p>Before we start, it is good to note that most of the Cardano stack is written in Haskell, and thus, managing a Plutus project is just managing a Haskell project. There are multiple ways of doing this, just a plain Cabal project or one of the many Nix ways of building (cabal2nix, Haskell.nix and many others). Now there are good reason to use these Nixs ways (most notably reproducibility and caching), but in this answer I will focus on a more understandable way of just using GHC + cabal on Ubuntu 22.04 (not the minimal install).</p>
<p>A disclaimer, building everything yourself requires lots of ram (you can also re-run the <code>cabal run</code> command if you run out of memory mid-process). The good thing, however, once build you have these Haskell artifact locally prebuilt in your <code>~/.cabal/</code> folder.</p>
<p><strong>The dependencies</strong></p>
<p>Before we can even build a general all-purpose Haskell/plutus project, we need some basic building tools necessary to even start compiling! These mainly consist of the following tools,</p>
<ul>
<li>OS dependent dependencies</li>
<li>GHC and Cabal</li>
<li>A special version of libsodium</li>
<li>A special version of libsecp256k1</li>
</ul>
<p><strong>OS dependent dependencies</strong></p>
<p>To build everything, you at least need these dependencies</p>
<pre class="lang-bash prettyprint-override"><code>sudo apt-get update -y &amp;&amp; sudo apt-get upgrade -y
sudo apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 curl libtool postgresql libpq-dev autoconf -y
</code></pre>
<p>Note that translating these OS dependent dependencies to other operating systems is hard and out of the scope of this post (this is why you might want nix). They may also change in the future as the project might add new dependencies.</p>
<p><strong>GHC and Cabal</strong></p>
<p>It is recommended by IOG to use GHC version 8.10.7 and Cabal version 3.6.2.0. These can be installed via GHCUP via,</p>
<pre class="lang-bash prettyprint-override"><code>curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
</code></pre>
<p>You can press <em>enter</em> for all question the installer asks. Then reload your terminal (to make <code>ghcup</code> appear in your path) and,</p>
<pre class="lang-bash prettyprint-override"><code>ghcup install ghc 8.10.7
ghcup set ghc 8.10.7
ghcup install cabal 3.6.2.0
ghcup set cabal 3.6.2.0
</code></pre>
<p>Reload your terminal again to make these appear in your path and set</p>
<pre class="lang-bash prettyprint-override"><code>cabal configure --with-compiler=ghc-8.10.7
</code></pre>
<p><strong>A special version of libsodium</strong></p>
<p>Libsodium is a tool chain (written for performance) for cryptographic derivatives, for example you can create signatures and hashes with it. We require a particular version of it that adds VRF cryptography to it (used for the Cardano consensus mechanism). Installing this can be done via,</p>
<pre class="lang-bash prettyprint-override"><code>git clone https://github.com/input-output-hk/libsodium
cd libsodium
git checkout 66f017f1
./autogen.sh
./configure
make
sudo make install
</code></pre>
<p>In addition to this add the following to your <code>~/.bashrc</code> and reload your terminal again to add it to your path</p>
<pre class="lang-bash prettyprint-override"><code>export LD_LIBRARY_PATH=&quot;/usr/local/lib:$LD_LIBRARY_PATH&quot;
export PKG_CONFIG_PATH=&quot;/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH&quot;
</code></pre>
<p><strong>A special version of libsecp256k1</strong></p>
<p>Since the Vasil hard fork Cardano has the secp256K1 signature scheme available in plutus. This allows for the validation of Bitcoin signatures and will make it easier to build bridges. Bitcoin is not the only blockchain that use this signature scheme, many others do. So to install this library (again a particular audited version) you use,</p>
<pre class="lang-bash prettyprint-override"><code>git clone https://github.com/bitcoin-core/secp256k1
cd secp256k1
git checkout ac83be33
./autogen.sh
./configure --enable-module-schnorrsig --enable-experimental
make
make check
sudo make install
</code></pre>
<p><strong>A preconfigure project</strong></p>
<p>We are ready to build a Plutus project! Before I tell how you can set up such a project, I want to share an already set up <a href="https://github.com/perturbing/example-project-basic" rel="nofollow noreferrer">example</a>. This so that you can test that you correctly installed the dependencies above. To run this example you use</p>
<pre class="lang-bash prettyprint-override"><code>git clone https://github.com/perturbing/example-project-basic.git
cd example-project-basic
cabal update
cabal run
</code></pre>
<p>I would like to reiterate, if you do not have sufficient ram available, for example because you run this example in a VM, you can <code>cabal run</code> again if your memory overflows. This example ran for me in a vm with 10gb ram.</p>
<p><strong>Now how is this project setup?</strong></p>
<p>This project and its structure is not constructed arbitrarily. It is namely derived from the latest release of the <a href="https://github.com/input-output-hk/plutus-apps/releases/tag/v1.0.0" rel="nofollow noreferrer">plutus-apps</a> repository. This repository and its management of dependencies is chosen because it imports and exposes almost all important Haskell packages written for Cardano.</p>
<p>Now, how to concretely set up and copy the essential bits of this repo? It consists of the following steps.</p>
<p>To start we execute</p>
<pre class="lang-bash prettyprint-override"><code>mkdir my-plutus-project
cd my-plutus-project
cabal init
touch cabal.project
</code></pre>
<p>You could also use the flag <code>--interactive</code> for a more detailed set up with <code>cabal init</code>.</p>
<p>Next, we copy the <code>cabal.project</code> file of plutus-apps from its latest release (do not pick the main branch, consider this is unstable). Currently, the latest version of this file is <a href="https://github.com/input-output-hk/plutus-apps/blob/7952b9d30d15779a7fd8103bdbc9612d5df18ec2/cabal.project" rel="nofollow noreferrer">this</a>. Next, we need to adjust some pieces of this file to make it work for us.</p>
<p>The first thing to change, this <code>cabal.project</code> file does not import the <code>plutus-apps</code> repo (since it was part of the original one). So, we need to add that by changing the code that declared the to build packages of the plutus-apps repo. It also does not declare our new build artifacts of our cabal project, we have to change the exposed packages it has to build. Both can be achieved by changing,</p>
<pre class="lang-haskell prettyprint-override"><code>packages: cardano-streaming
          doc
          freer-extras
          marconi
          marconi-mamba
          playground-common
          pab-blockfrost
          plutus-chain-index
          plutus-chain-index-core
          plutus-contract
          plutus-contract-certification
          plutus-example
          plutus-ledger
          plutus-ledger-constraints
          plutus-pab
          plutus-pab-executables
          plutus-script-utils
          plutus-tx-constraints
          plutus-use-cases
          rewindable-index
</code></pre>
<p>to</p>
<pre class="lang-haskell prettyprint-override"><code>packages: ./

source-repository-package
    type: git
    location: https://github.com/input-output-hk/plutus-apps
    tag: the_latest_release_tag_used_here_CHANGE_ME!!!
    subdir: 
          cardano-streaming
          doc
          freer-extras
          marconi
          marconi-mamba
          playground-common
          pab-blockfrost
          plutus-chain-index
          plutus-chain-index-core
          plutus-contract
          plutus-contract-certification
          plutus-example
          plutus-ledger
          plutus-ledger-constraints
          plutus-pab
          plutus-pab-executables
          plutus-script-utils
          plutus-tx-constraints
          plutus-use-cases
          rewindable-index
</code></pre>
<p>Next up, we can add to our executables and/or libraries on which modules they depend. For example, we might add to our <code>my-plutus-project.cabal</code> file that the executable depends on</p>
<pre class="lang-haskell prettyprint-override"><code>    build-depends:    base ^&gt;=4.14.3.0
                    , aeson
                    , bytestring
                    , containers
                    , cardano-api
                    , data-default
                    , plutus-ledger
                    , plutus-ledger-api
                    , plutus-ledger-constraints
                    , plutus-script-utils
                    , plutus-tx-plugin
                    , plutus-tx
                    , text
                    , serialise
</code></pre>
<p>And lastly, we can write our <code>app/Main.hs</code> file to execute some functions for us. A simple <code>cabal update</code> and a <code>cabal run</code> will execute your <code>Main.hs</code> executable.</p>
<p><strong>Some last words</strong>
This is a long answer, and in no way is complete. I advise anyone who is eager to learn more about Haskell to take the Haskell <a href="https://github.com/input-output-hk/haskell-course/" rel="nofollow noreferrer">course</a> from IOG (it also covers cabal!). I hope this gets you started!</p>
