Appy
An opinionated productive web framework that helps scaling business easier.
Install / Use
/learn @appable-run/AppyREADME
appy
An opinionated productive web framework that helps scaling business easier, i.e. focus on monolith first, only move to microservices with GRPC later on when your team is ready.
<details> <summary>Click to see an application called "appist" made with "appy" in action</summary> <p align="center"> <img width="48%" alt="Debug Mode" src=".github/assets/debug.gif"> <img width="48%" alt="Release Mode" src=".github/assets/release.gif"> </p> </details>Additional Notes
appyis made as a package for your application to import without the need to install any additional binaryappyglues the great packages to provide best productivity in developing Go web applicationappycomes with 2 build types:- debug - when the code is NOT running within the binary
- release - when the code is running within the binary
appyfollows 12factor viaAPPY_ENVenvironment variable:- by default, it is
development - when
APPY_ENV=stagingis set, the config file isconfigs/.env.staging - utilise
configs/.env.<APPY_ENV>to support multiple environments deployment
- by default, it is
Table Of Contents
Overview
<p align="center"> <img height="450px" alt="architecture" src="./.github/assets/architecture.png" /> </p>Features
package cmd
-
Powerful built-in commands
<details> <summary>Click to see details</summary>
</details>My first awesome web application in Go. Usage: myapp [command] Available Commands: build Compile the static assets into go files and build the release build binary (only available in debug build) config:dec Decrypt a config value using the secret in `configs/<APPY_ENV>.key` or `APPY_MASTER_KEY` (only available in debug build) config:enc Encrypt a config value using the secret in `configs/<APPY_ENV>.key` or `APPY_MASTER_KEY` (only available in debug build) db:create Create all databases for the current environment db:drop Drop all databases for the current environment db:migrate Migrate the database(default: all, use --database to specify the target database) for the current environment db:migrate:status List all the database migration status(default: all, use --database to specify the target database) for the current environment db:rollback Rollback the database(default: primary, use --database to specify the target database) to previous version for the current environment db:schema:dump Dump all the databases schema for the current environment (only available in debug build) db:schema:load Load all the databases schema for the current environment db:seed Seed all databases for the current environment dc:down Tear down the docker compose cluster dc:restart Restart services that are defined in `docker-compose.yml` dc:up Create and start containers that are defined in `docker-compose.yml` gen:migration Generate database migration file(default: primary, use --database to specify the target database) for the current environment (only available in debug build) help Help about any command middleware List all the global middleware routes List all the server-side routes secret Generate a cryptographically secure secret key for encrypting cookie, CSRF token and config secret:rotate Rotate the secret that is used to encrypt/decrypt the configs (only available in debug build) serve Run the HTTP/HTTPS web server without `webpack-dev-server` setup Run dc:up/db:create/db:schema:load/db:seed to setup the datastore with seed data ssl:setup Generate and install the locally trusted SSL certs using `mkcert` ssl:teardown Uninstall the locally trusted SSL certs using `mkcert` start Run the HTTP/HTTPS web server with `webpack-dev-server` in development watch mode (only available in debug build) teardown Tear down the docker compose cluster work Run the worker to process background jobs Flags: -h, --help help for myapp -v, --version version for myapp Use "myapp [command] --help" for more information about a command. -
Flexible custom commands building
package mailer
-
Ready-to-use SMTP email sending
-
I18n support
-
HTML templates binary embed support
-
Developer friendly email preview UI
<details> <summary>Click to see details</summary> <p align="center"> <img height="450px" alt="Preview UI" src="./.github/assets/mailer_preview_ui.png" /> </p> </details>
package pack
-
Powerful built-in HTTP middleware
<details> <summary>Click to see details</summary>-
API Only<br> Remove
Set-Cookieresponse header if theX-API-ONLY: 1request header is sent. -
CSRF<br> Protect cookies from
Cross-Site Request Forgeryby including/validating a token in the cookie across requests. -
GZIP Compress<br> Compress the responses before returning it to the clients.
-
Health Check<br> Provide the HTTP GET endpoint for health check purpose.
-
I18n<br> Provide I18n support which the translations are stored in
<PROJECT_NAME>/pkg/locales/*.yml. -
Logger<br> Provide logger support.
-
Mailer<br> Provide mailer support which the views templates are stored in
<PROJECT_NAME>/pkg/views/mailers/**/*.{html,txt}. -
Prerender<br> Prerender and return the SPA page rendered by Chrome if the HTTP request is coming from the search engines.
-
Real IP<br> Retrieves the client's real IP address via
X-FORWARDED-FORorX-REAL-IPHTTP request header. -
Recovery<br> Recover the HTTP request from panic and return 500 error page.
-
Request ID<br> Generate UUID v4 string for every HTTP request.
-
Request Logger<br> Log the HTTP request information.
-
Secure<br> Provide the standard HTTP security guards.
-
Session<br> Provide session management using cookie/redis.
-
SPA<br> Provide SPA hosting with specific path.
-
View Engine<br> Provide server-side HTML template rendering.
-
-
Fully integrated with gqlgen with watch mode
-
Ready-to-use test context builder for unit test
package record
-
Powerful database management commands
<details> <summary>Click to see details</summary>
</details>db:create Create all databases for the current environment db:drop Drop all databases for the current environment db:migrate Migrate the database(default: all, use --database to specify the target database) for the current environment db:migrate:status List all the database migration status(default: all, use --database to specify the target database) for the current environment db:rollback Rollback the database(default: primary, use --database to specify the target database) to previous version for the current environment db:schema:dump Dump all the databases schema for the current environment (only available in debug build) db:schema:load Load all the databases schema for the current environment db:seed Seed all databases for the current environment -
Extended
sql.DBwith sqlx -
Fully featured ORM
<details> <summary>Click to see details</summary>- Multiple databases support
- Master/Replica switch
- Soft delete
- Associations (Not Yet Supported)
- Has One
- Has Many
- Belongs To
- Many To Many
- Polymorphism
- Preload
- Eager Load
- Callbacks
- BeforeValidate/AfterValidate
- BeforeCreate/AfterCreate
- BeforeDelete/AfterDelete
- BeforeUpdate/AfterUpdate
- BeforeCommit/AfterCreateCommit/AfterDeleteCommit/AfterUpdateCommit
- BeforeRollback/AfterRollback
- Composite primary keys
- Execution with context
- SQL query builder/logger/inspector
- Transactions
- Validations with I18n support
-
Performant ORM
<details> <summary>Click to see details</summary>go test -run=NONE -bench . -benchmem -benchtime 10s -failfast ./record goos: darwin goarch: amd64 pkg: github.com/appist/appy/record BenchmarkInsertRaw-4 1239 10103533 ns/op 88 B/op 5 allocs/op BenchmarkInsertDB-4 898 11351591 ns/op 1548 B/op 19 allo
