Anatomy of a aah application
The layout of a aah application is standardized to keep things as simple as possible and has component of MVC architectural pattern.
app ⇒ Application Go source codes directory config ⇒ Configurations files directory └ env ⇒ Environment profile configurations directory i18n ⇒ Internationalization and Localization message files directory views ⇒ View Template files directory static ⇒ Static public assets directory logs ⇒ Logs directory (default is console on 'dev' profile) tests ⇒ Go test source directory (upcoming), use Go standard way for unit tests build ⇒ Application build directory
Packaged aah application will have following directories/files
bin ⇒ Application binary under bin directory
Packaged aah application won’t have following directories/files
app ⇒ Application Go source directory (compiled into binary under `bin` directory) logs ⇒ Logs directory (created during an app startup) tests ⇒ Go source codes directory (not for production) .gitignore ⇒ Typical Go .gitignore file (not for production) aah.project ⇒ aah project configuration (not for production) app-name.pid ⇒ Application PID file (created during app startup)
app directory contains all the Go source codes for the application. Initially
models directory gets created by
aah new command. Of course you can have as many as packages in the app directory for your application.
config directory contains the application’s configuration files. aah configuration file syntax is very similar to HOCON syntax. The quick start application will have the following config files. Organize the way you want it.
aah.conf- the main configuration file for the application, know more.
routes.conf- the routing configuration file for the application, know more.
security.conf- the security configuration file for the application, know more.
i18n directory (Not applicable to API application)
i18n directory contains internationalization and localization message files. Message filename format is
message.<Language-ID>. Language is combination of
Language + Region value. aah implements Language code as per two-letter
ISO 639-1 standard and Region code as per two-letter
ISO 3166-1 standard, know more.
i18n feature can be used with API application too, if needed.
views directory (Not applicable to API application)
views directory contains application view templates. aah supports partial inheritance with Go template engine, know more. There are three main directories:
common- Common view template files, it can be imported to any page template via
layouts- Application view layout template files. You can have as many you want.
pages- Page view template files. Respective view file for controllers action.
- For example:
- For example:
/<namespace>/<controller-name>/<action-name>.<ext>(namespace directory structure is supported)
- For example:
errors- Application error pages such as 500.html, 404.html, etc.
static directory (Not applicable to API application)
- By default
staticdirectory mapped as
/staticin routes.conf. You can customize it in the config. For example:
- You can use several directories under
staticdirectory as per your need. Just organize it appropriately, it helps you :)
static file delivery feature can be used API application too, if needed.
logs directory is for application logs and default location of server access log.
tests directory is for application functional tests (
upcoming). Use Go conventional way
<source-file>_test.go for unit test your Go source codes.
.gitignore file includes standard Go language ignores from Github and additionally aah ignores: