Organize Packages Inside the Module
Folder and package structure that scales.
Organize Packages Inside the Module is a free Kotlin Multiplatform Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Multiplatform Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Packages Are Folders With Names
A package groups related Kotlin files under a dotted name. Good packages make a growing shared module easy to navigate. 📁
Declare the Package
Every file starts with a package line. It should mirror the folder path so the structure stays predictable for everyone.
package com.acme.shared.domainGroup by Feature
Prefer grouping by feature over grouping by type. A cart package keeps its model, logic, and helpers together in one place.
Separate Domain and Data
A clean split is domain for pure models and rules, and data for networking and storage. The boundary keeps each part focused.
// com.acme.shared.domain -> models, rules
// com.acme.shared.data -> api, dbUse a Reverse-Domain Root
Start packages with a reverse-domain name like com.acme.shared. It keeps your code from clashing with library packages.
Mirror Folders to Packages
Keep the folder tree matching the package names. When they line up, anyone can find a class just from its full name.
A Tidy Public Package
Put the types you expose in one obvious public package, like com.acme.shared.api. Callers then have a single place to look.
Tuck Internals Away
Keep helpers in an internal package such as .impl or .util. The name signals at a glance that callers should stay out.
Shallow Beats Deep
Avoid endless nesting. A shallow tree of a few clear packages is easier to scan than ten layers of tiny folders.
Same Layout Across Source Sets
Use the same package layout in commonMain, androidMain, and iosMain. Matching paths make expect and actual pairs easy to spot.
Names Tell a Story
Read your package list top to bottom. The names alone should explain what the module does and where each concern lives.
Quick Check
Let's check how to structure packages.
Recap
Group by feature or layer, mirror folders to packages, keep it shallow, and hide internals. A clear tree scales as the module grows. 🎉
Frequently asked questions
Is the “Organize Packages Inside the Module” lesson free?
Yes — the full text of “Organize Packages Inside the Module” is free to read here on the web, and the Kotlin Multiplatform Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Kotlin Multiplatform Academy course, upgrade to CoddyKit PRO.
What will I learn in “Organize Packages Inside the Module”?
Folder and package structure that scales. You practise Kotlin Multiplatform Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Kotlin Multiplatform Academy?
No prior experience is required. Kotlin Multiplatform Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Organize Packages Inside the Module” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Kotlin Multiplatform Academy lesson?
Yes. Every Kotlin Multiplatform Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Design a Small Public API
- internal vs public Visibility
- Organize Packages Inside the Module
- Document the API for Both Teams