Midnight logoMidnight Academy
← back to curriculum

Module 05

Understanding the Folder Structure

Most tutorials skip this. It matters — knowing what each folder is for is what lets you debug confidently instead of guessing.

Your project, top level

example-hello-world/
├── contracts/
│ ├── hello-world.compact
│ └── managed/
├── src/
├── docker-compose.yml
└── package.json

contracts/hello-world.compact

The one file you actually hand-wrote. Everything else in this module is generated from it or supports it.

contracts/managed/

Created the moment you ran compact compile. This is the compiler's output, not something you edit by hand:

managed/hello-world/
├── compiler/
├── contract/
├── keys/
└── zkir/

src/

The JavaScript/TypeScript side — code that actually talks to your deployed contract: deployment scripts, wallet setup, and (in this starter) the test file that deployed and called storeMessage in Module 04.

docker-compose.yml

Defines the three containers yarn env:up started for you: the local node, the indexer, and the proof server. If a deploy ever fails mysteriously, checking whether all three are healthy here is the first thing to try.

package.json

The usual Node project manifest — but pay attention to its scriptssection specifically. That's where commands like env:up and test:localare actually defined; when in doubt about what a project's custom commands do, read this file before searching online.

The rule of thumb

If you wrote it by hand, it's source. If a tool generated it, it's an artifact — safe to delete and regenerate, and generally shouldn't be hand-edited. In this project: contracts/hello-world.compact and src/ are source. contracts/managed/ is an artifact — if it ever looks broken or stale, deleting it and re-running compact compile is usually the right move, not trying to hand-fix it.

That's the core fundamentals. Next: mini-projects, building on what you know.