Directory Structure
The default Almasix application structure provides a sensible starting point for both small and large applications. Feel free to organize your application however you like — Almasix imposes almost no restrictions — but understanding the conventions will help you navigate quickly.
The root directory
Section titled “The root directory”The app directory
Section titled “The app directory”The core of your application lives here: HTTP controllers, middleware, models, policies, and service providers.
Almasix uses PascalCase for class names and snake_case for Python packages and modules:
| Layer | Convention | Example |
|---|---|---|
| Class | PascalCase | class Post(Model), PostController |
| Package directories | lowercase | app/models/, app/http/controllers/ |
| Module files | snake_case | post.py, post_controller.py |
| Imports | dotted snake_case | from app.models.post import Post |
Generators follow the same rules. smith make:model Post writes app/models/post.py containing class Post. Nested namespaces snake-case as well: Admin/UserController → app/http/controllers/admin/user_controller.py. smith make:policy PostPolicy --model=Post writes app/policies/post_policy.py.
The bootstrap directory
Section titled “The bootstrap directory”Contains app.py, where you configure the application and register middleware. See Middleware.
The config directory
Section titled “The config directory”All of your application’s configuration files live here (app.py, database.py, http.py, and so on). Browse these files to become familiar with the options available to you.
The database directory
Section titled “The database directory”Holds your database migrations and seeders. See Migrations and Seeding.
The routes directory
Section titled “The routes directory”Route definitions for your application. By convention:
routes/web.py— routes that return HTMLroutes/api.py— routes that return JSONroutes/console.py— scheduled tasks (loaded bysmith schedule:run, not the HTTP kernel)
The app/console directory
Section titled “The app/console directory”Console Command classes (smith make:command …). See Smith Console and Task Scheduling.
The lang directory
Section titled “The lang directory”Translation catalogs for localization (lang/en/…, lang/en.json, and so on).
The smith script
Section titled “The smith script”The entry point for Almasix’s command-line interface. Generate code, run migrations, schedule work, and open Loupe:
smith make:controller PostControllersmith migratesmith schedule:runsmith loupesmith serve