DocumentationMount independent projects
API referenceGitHub

Mount independent projects

Keep apps independently configured, then mount sibling projects under URL prefixes when useful.

Work through each step in order. The examples use the generated LenAPI project structure and are designed to be adapted to your app.

01

Keep each project independent

Every project created with lenora startproject has its own settings.py, models, schemas, migrations, and database URL. You can run each project as a separate server, or mount one project into another. Mounting is optional and does not merge their settings or databases.

Python
workspace/
├── win/
│   ├── main.py
│   ├── settings.py
│   └── app/
└── games/
    ├── main.py
    ├── settings.py
    └── app/
02

Mount a sibling at the URL prefix you choose

Call app.mount(path, project_name) in the primary project's main.py. The project name identifies the sibling directory; the URL prefix is your choice and does not have to match that project name. The sibling must have its own PROJECT_NAME in settings.py.

Python
# win/main.py — primary project
from lenapi import LENAPI

app = LENAPI()
app.mount("/gamer", "games")

# The sibling app's routes and docs are available under:
# /gamer/       child project's home route
# /gamer/docs/  child project's Swagger UI
# /gamer/redoc/ child project's ReDoc
TIP

The project name passed to mount() must match a sibling project directory. The path is a separate routing choice: app.mount('/arcade', 'games') is valid too.

03

Keep databases and migrations separate

A mounted project loads its own settings and connects to its own DATABASE_URL. LenAPI namespaces its relational tables using the project namespace, so two projects can use one database server without treating each other's tables or migration state as their own. You can also configure separate database servers.

Python
# win/settings.py
PROJECT_NAME = "win"
DATABASE_TYPE = "sqlite"
DATABASE_URL = "sqlite:///win.db"

# games/settings.py
PROJECT_NAME = "games"
DATABASE_TYPE = "postgresql"
DATABASE_URL = "postgresql://user:password@localhost:5432/games"
TIP

Run each project's migration commands from that project's directory. Mounting does not migrate a child project's schema on its behalf.

04

Choose mounting or separate servers

Mount projects when one ASGI process and domain should serve multiple apps under path prefixes. Run projects independently when you want separate ports, deployments, scaling, or failure boundaries. A reverse proxy can route domains or paths to independently deployed servers too.

Python
# Start each app independently from its own project directory
cd win && python lenora.py run
cd ../games && python lenora.py run