Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
Python & Django

Structure That Survives Growth

Last updated:

Structure emerges whether you choose it or not

A project without a deliberate structure develops one anyway, usually organised by what was written when. That structure is invariably worse than one chosen at the start.

The cost of deciding structure early is an hour. The cost of imposing it later is a refactor across the whole codebase.

Separate business logic from the framework

  • Business rules in modules that import nothing framework-specific
  • Framework code that calls into them
  • Data access behind an interface, not scattered through logic
  • Configuration passed in rather than read globally

That separation makes business logic testable without spinning up a web framework, and it means a framework change is a rewrite of the edges rather than of the system.

Organise by feature, not by type

Instead ofPrefer
models/, views/, services/orders/, invoicing/, reporting/
One large utilities moduleUtilities near what uses them
Everything importable from everywhereExplicit, limited public interfaces
Deep nestingFlat until it genuinely needs depth

Feature-based organisation means a change to one area touches one directory, which makes both work and review easier.

Keep dependencies pointing one way

Business logic should not import from the web layer. The web layer imports business logic. Circular imports are a symptom that the boundaries are wrong.

When you find yourself fighting import order, the structure is telling you something.

Consistency over correctness

There is no single right structure for a Python project. There is enormous value in a project where everything follows the same pattern, because unfamiliar code becomes readable.

Decide, document it briefly, and apply it consistently.

Frequently asked questions

Should we use a standard project layout?

A conventional one is a reasonable starting point. Adapt it to your domain rather than following it rigidly.

How do we restructure an existing project?

Incrementally, as you touch areas. A big-bang restructure is high risk and rarely finishes.

What about very small projects?

A single module is fine until it is not. The signal is when finding things starts taking time.

Does structure affect performance?

Negligibly. It affects how long changes take, which matters considerably more.

Keep reading

Codebase where nobody can find anything?

Usually a structure problem rather than a size one. Happy to look at how it is organised.

Book a free 30-minute call Get a project estimate WhatsApp us

Related services

What we build for problems like this one

Custom Software DevelopmentWeb DevelopmentMachine Learning