# Separating Main Daml Templates to Individual Dar Files

**URL:** <https://forum.canton.network/t/separating-main-daml-templates-to-individual-dar-files/4334>\
**Category:** App Development\
**Tags:** daml, damlhub\
**Created:** [April 13, 2022, 10:01pm UTC](https://forum.canton.network/t/separating-main-daml-templates-to-individual-dar-files/4334 "2022-04-13T22:01:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rikotacards](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@rikotacards](https://forum.canton.network/u/rikotacards)\
**Post date:** [April 13, 2022, 10:01pm UTC](https://forum.canton.network/t/separating-main-daml-templates-to-individual-dar-files/4334/1 "2022-04-13T22:01:10Z")

</div>

Whats the best practice (for structuring the repo) when it comes to separating Daml models into individual dar files?

Also just to be sure, I should NOT be creating a daml project inside a daml project right?  
I could manually do this, and create a daml.yaml file, and a daml directory, but because if I run `daml init` inside a directory which I had init’ed earlier with `daml init` I will get the message:

`Target directory is inside existing DAML project "/Users/maxhsu/Desktop/projects/wallet-refapp/wallet" Please specify a new directory outside an existing project.`

The end goal is to upload 4 Dar files onto Daml hub and have everything interact together, in the name of composability.

1. `Account.dar`,
2. `Asset.dar`,
3. `User.dar`, and finally a
4. `Triggers.dar`

Currently, I have a separated triggers Daml project, and the main daml project under `/wallet`

```haskell
/triggers (daml project)
   /daml
      triggerA.daml
      triggerB.daml
   daml.yaml ( with dep pointing to ../wallet/wallet-refapp.dar)
/wallet (daml project)
   /daml
      Account.daml
      Asset.daml
      User.daml
   daml.yaml
daml.yaml (parent daml.yaml file specifying SDK)

```

And I’m only uploading 2 dar files to hub. Now, how should I structure the directory if I want to bring Account.daml, Asset.daml, and User.daml out as separate .dar files

would the end structure look like this?

```haskell
parent
   /triggers (daml project)
      /daml
         triggerA.daml
         triggerB.daml
      daml.yaml (at root of triggers project pointing to the new .dar file deps)
   /Account (daml project)
      /daml
         Account.daml
   daml.yaml (specifiy any deps from other dar files) 
  /Asset (daml project)
     /daml
       Asset.daml
   daml.yaml
daml.yaml (this one in the root specifying the sdk)

```

and a final question, when I’m doing the JS codegen, would I only need to build the .dar file with all the dependencies?

Currently,

When I am in the `/wallet` directory and run `daml build` , I get the output  
`.daml/dist/wallet-refapp-0.1.0.dar`, this is then used to create the javsscript bindings when I run

`daml codegen js .daml/dist/wallet-refapp-0.1.0.dar -o ui/daml.js`

Now I’ll have multiple dar files.

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [April 14, 2022, 6:49am UTC](https://forum.canton.network/t/separating-main-daml-templates-to-individual-dar-files/4334/2 "2022-04-14T06:49:59Z")

</div>

Your structure seems sensible. I’d generally recommend one directory per project and then the top-level daml.yaml fixing just the SDK version. Note that there are some caveats if you open the root directory in daml studio. Take a look at the [documentation](https://docs.daml.com/daml/daml-studio.html#working-with-multiple-packages) for more details.

---

<div class="post-metadata">

**Author:** ![rikotacards](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@rikotacards](https://forum.canton.network/u/rikotacards)\
**Post date:** [April 14, 2022, 6:54am UTC](https://forum.canton.network/t/separating-main-daml-templates-to-individual-dar-files/4334/3 "2022-04-14T06:54:32Z")

</div>

Thanks, just wanted to confirm.
