# How to organize code for a module + scripts

**URL:** https://discourse.julialang.org/t/how-to-organize-code-for-a-module-scripts/130360
**Category:** General Usage
**Tags:** question
**Created:** [July 1, 2025, 8:03am UTC](https://discourse.julialang.org/t/how-to-organize-code-for-a-module-scripts/130360 "2025-07-01T08:03:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [July 1, 2025, 8:03am UTC](https://discourse.julialang.org/t/how-to-organize-code-for-a-module-scripts/130360/1 "2025-07-01T08:03:55Z")

</div>

I am generating plots and tables for a paper. I want to organize the relevant code

1. in a git repo,
2. containing a module, eg `Figures`, in a single file,
3. a bunch of scripts that I can run that call functionality from the module to make the actual plots.

(Why the module? Because Revise.jl makes this so convenient.)

Let’s say that I am working in `DIR`. Can I somehow have a flat structure like

```ascii
DIR/Figures/Project.toml
DIR/Figures/Figures.jl
DIR/Figures/scrips.jl

```

or do I need `DIR/Figures/src/Figures.jl`? I tried the former but the loader does not find the module unless it is in a `src/`.

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [July 1, 2025, 8:31am UTC](https://discourse.julialang.org/t/how-to-organize-code-for-a-module-scripts/130360/2 "2025-07-01T08:31:39Z")

</div>

I personally have the following structure:

```plaintext
PaperScript.jl
Manifest.toml
Project.toml
lib
- MyModule.jl (important bit: this needs to be named as [MODULONAME].jl)
- MyModule_file1.jl
- MyModule_file2.jl
- ...

```

In PaperScript.jl I then have:

```julia
cd(@ __DIR__ )
using Pkg
Pkg.activate(".")
using Revise
# ### Load the model structure (function "luc_model")
push!(LOAD_PATH,joinpath(@ __DIR__ ,"lib"))
using MyModule
...

```

In MyModule.jl I have:

```julia
module MyModule
using Revise

include("MyModule_file1.jl")
include("MyModule_file1.jl")
# [...]
end

```

In this way I can apply changes in the MyModule files and get them applied (thanks to Revise) to the function calls that I use in PaperScript.jl.

I was using `includet` earlier, but I come into an issue with nested `includet`, so I use this approach now…

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [July 1, 2025, 8:47am UTC](https://discourse.julialang.org/t/how-to-organize-code-for-a-module-scripts/130360/3 "2025-07-01T08:47:40Z")

</div>

> [@Tamas\_Papp](#):
>
> Can I somehow have a flat structure like

You can if you fiddle with `LOAD_PATH` but I would just organize it as a normal package.

> [@sylvaticus](#):
>
> ```julia
> cd(@ __DIR__ )
> using Pkg
> Pkg.activate(".")
> 
> ```

Unless you really need to change the current directory you can do

```julia
Pkg.activate(@ __DIR__ )

```
