Guides Intro arrow Overview of Lucky

This guide will give a brief intro to the philosophy behind Lucky. It also goes over the file structure of a Lucky app, and how all the pieces fit together.

The Lucky philosophy

Lucky was designed to solve a few core problems that teams often see. Lucky strives to:

We do that by using Crystal’s type system to the fullest. You won’t see strings or symbols passed around. Instead you’ll see method calls with types that make sure bugs are caught early.

We have conventions that help you break your app into smaller pieces that are easier to understand. Things like single class per action, and form objects.

We have helpful code generation so that you don’t need to repeat boilerplate.

Lucky was designed for developers that love making reliable products. We think you’ll love it.

File structure overview

A new Lucky app is a slightly modified version of a Crystal app.

src folder

The src folder holds most of your application code. This includes actions for handling requests, queries for database access, pages for rendering HTML, and a few other things.

config folder

Here are all the files for configuring your application. A new app comes with a few configuration files, but you can add more as you see fit.

static folder

This is where all your static assets go. JavaScript, CSS, images, fonts, and any other assets your project needs.

db folder

This folder houses all the database migrations for your app.

tasks folder

You can put custom tasks here that can be run by the lucky command line tool.

public folder

This folder is never written to by a developer. Instead the asset compiler will put files here automatically.

Procfile and is used when you run lucky dev. By default there is a web and an assets process that are started. You can add more if you need them.

Procfile is often used in production. Companies like Heroku, use it to determine how it should run the app.

The src folder

actions folder

This is where classes go that handle incoming web requests.

models folder

Put anything that models your business. Database objects go here, but you could also put things like service objects.

handlers folder

Custom HTTP handlers. These can be used to do something for all HTTP requests. Great for things like loggers, setting up headers that apply to all requests, etc.

It’s more likely that you will use pipes for most business logic because they can be used selectively on a per action basis.

pipes folder

Pipes are used to do things before or after an action is run. Great for authentication, authorization, or ensuring certain headers are set.

queries folder

This is where your database queries go.

forms folder

Forms for saving database records or interacting with HTTP forms.

pages folder

Pages used for rendering HTML in response to web requests.

This requires all the files and folders that your app needs to run.

Require your third party dependencies (shards) here.

This file requires the app and starts an HTTP server.