Go web framework · built on Gin

From empty folder to working API in minutes.

Anar scaffolds your Go project and generates models, CRUD handlers, migrations and routes. Authentication, role-based permissions and OAuth login come already wired in.

$ go install codeberg.org/anarproject/anar@latest
Features

The parts every API needs, ready on day one

Stop rewriting the same login flow, CRUD endpoints and migration boilerplate for each new service.

Project scaffolding

anar new lays out a clean structure for models, handlers, routes, jobs and config.

Models and migrations

Generate GORM models from the command line, including belongsTo, hasOne, hasMany and manyToMany relations.

CRUD handlers and routes

Handlers come with search, filtering and pagination, and their routes are generated from //anar:route comments.

JWT authentication

Registration with email confirmation by link or one-time code, login, rotating refresh tokens and protected route groups are included.

Two-factor authentication

OTP one-time passwords (TOTP) from any authenticator app, with single-use recovery codes, for both password and OAuth logins.

Roles and permissions

A complete role-based access control system with middleware to guard any route.

OAuth login

Sign in with Google, GitHub, Facebook and Apple through standards-compliant OAuth 2.0 and OpenID Connect.

Caching

Choose an in-memory, Redis or Memcached cache with CACHE_TYPE, and cache the responses of any route with automatic invalidation and ETags.

Email over SMTP

Send confirmation and notification emails with settings from your environment.

S3-compatible storage

Upload files to AWS S3, MinIO or any S3-compatible store with the FileField type.

How it works

Three commands to a working API

Anar generates ordinary Go code that you own and can edit. You can drop down to Gin and GORM whenever you need to.

Create a project

Scaffold from the pinned anar-core template and set your database, cache and SMTP settings in .env.

anar new codeberg.org/me/shop

Describe your models

Add fields and relations from the CLI, or write the structs by hand in models/.

anar model Product name:string price:float
anar model Order user:belongsTo

Generate and run

Scaffold handlers, migrations and routes, then run with live reload while you work.

anar scaffold
anar run
The name

A pomegranate and a sun

The logo carries both meanings of the word.

Pomegranate

In Persian and Turkish, anar means pomegranate, a fruit long associated with life, fertility and vitality.

The Sun

In Tolkien's mythology, Anar is the Sun, a source of light and guidance. We want the framework to have both: plenty of life, and a clear path to follow.

Open source, and open to contributions

Anar is MIT licensed and developed in the open on Codeberg. Bug reports, ideas and pull requests are all welcome.