Quick Start

Create your first Azu application in minutes.

Prerequisites

Step 1: Create a New Project

azu new my_blog --database postgres

This creates a new project with:

  • Complete project structure

  • PostgreSQL configuration

  • Git repository initialized

Step 2: Navigate and Explore

cd my_blog

Project structure:

my_blog/
├── src/
│   ├── my_blog.cr           # Main application
│   ├── server.cr            # Server configuration
│   ├── endpoints/           # HTTP handlers
│   ├── models/              # Database models
│   ├── requests/            # Request validation
│   ├── pages/               # Response pages
│   ├── services/            # Business logic
│   └── db/
│       ├── migrations/      # Database migrations
│       └── schema.cr        # Auto-generated schema
├── spec/                    # Tests
├── public/                  # Static assets
└── shard.yml               # Dependencies

Step 3: Set Up the Database

Step 4: Start the Server

Open http://localhost:4000 in your browser.

Step 5: Generate a Resource

Create a complete blog post resource:

This generates:

  • Model (src/models/post.cr)

  • Endpoints (src/endpoints/posts/)

  • Requests (src/requests/posts/)

  • Pages (src/pages/posts/)

  • Services (src/services/posts/)

  • Migration (src/db/migrations/)

Step 6: Run the Migration

Step 7: View Your Application

Visit http://localhost:4000/posts to see your CRUD interface.

Generated Code Examples

Model

Endpoint

Request

Run Tests

Next Steps

Troubleshooting

Server Won't Start

Port Already in Use

Database Connection Error

Last updated