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
# create a project $ anar new codeberg.org/me/blogapi $ cd blogapi # describe your data $ anar model Post title:string content:text $ anar model Comment post:belongsTo body:text # handlers, migrations and routes $ anar scaffold ✓ handlers/post.go handlers/comment.go ✓ migrations routes/generated_routes.go # run with live reload $ anar run listening on :8002
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.
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
Small packages that work on their own
Anar is built from focused Go libraries. Use them inside an Anar project or on their own in any Go codebase.
The command-line tool and code generators.
anar-coreTemplateThe application template that anar new scaffolds from.
Standards-compliant OAuth 2.0 and OpenID Connect login for Go.
anar-typesCustom database fields and JSON-friendly types: files, emails, money, geo locations and more.
anar-loggerLogging with console, file, syslog and Kafka outputs, async writes and rotation.
anar-schedulerA lightweight and flexible task scheduler.
anarqueueA complete queue library inspired by Laravel's queue system.
anarcacheOne caching interface over Redis, Memcached and in-memory backends.
anar-otpA unified HOTP and TOTP package for one-time passwords.
anar-tagsSimpler handling of Go struct tags.
inflectEnglish word pluralization and singularization.
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.