- Go 99.2%
- Dockerfile 0.8%
| core | move to anarproject | |
| documentations | update the md files to use anarproject/anar | |
| internal | move to anarproject | |
| go.mod | move to anarproject | |
| main.go | move to anarproject | |
| README.md | update README | |
Anar
Anar is a Go-based web framework built on Gin for rapid development of APIs and applications.
It provides scaffolding, CRUD generation, authentication, scheduling, and integrations with multiple OAuth providers.
About the Name
The name "Anar" carries rich symbolism across cultures and mythology. In languages like Turkish and Persian, anar means pomegranate, a fruit often associated with life, fertility, and vitality. In the world of Tolkien’s mythology, Anar represents the Sun, a symbol of light, energy, and guidance. By choosing this name for our framework, we embrace both meanings—the vibrant life of the pomegranate and the illuminating power of the Sun—reflecting our vision of a framework that is both lively and enlightening.
Features
- Scaffold new Go projects with a clean folder structure
- Generate models automatically with gorm.Model support
- Automatically generate CRUD handlers for models
- Database migrations for your models
- JWT-based authentication support
- Redis integration
- SMTP email support
- S3-compatible storage support
- Built-in scheduler for background jobs and tasks
- OAuth login via Facebook, Google, Apple, and GitHub
- Modular, extensible, and configurable architecture
Configuration
The project uses a .env file for environment configuration.
Supported options include:
- Server:
SERVER_PORT - JWT:
JWT_SECRET,JWT_EXPIRATION,TOKEN_ISSUER - Database:
DB_DRIVER,DB_HOST,DB_PORT,DB_USER,DB_PASSWORD,DB_NAME,DB_SSLMODE - Redis:
REDIS_ENABLED,REDIS_HOST,REDIS_PORT,REDIS_PASSWORD,REDIS_TTL - SMTP:
SMTP_HOST,SMTP_PORT,SMTP_USER,SMTP_PASSWORD,SMTP_FROM - Application URL:
APP_URL - S3 Storage:
S3_ENABLED,S3_ENDPOINT,S3_REGION,S3_ACCESS_KEY,S3_SECRET_KEY,S3_BUCKET,S3_USE_SSL - OAuth Providers:
OAUTH_GOOGLE_CLIENT_ID,OAUTH_GOOGLE_CLIENT_SECRET,OAUTH_FACEBOOK_CLIENT_ID,OAUTH_FACEBOOK_CLIENT_SECRET,OAUTH_APPLE_CLIENT_ID,OAUTH_APPLE_CLIENT_SECRET,OAUTH_GITHUB_CLIENT_ID,OAUTH_GITHUB_CLIENT_SECRET
Models
Models are defined in the models/ directory.
Each model can optionally embed gorm.Model to include standard fields (ID, CreatedAt, UpdatedAt, DeletedAt).
Example:
packagemodelsimport"gorm.io/gorm"typePoststruct{gorm.ModelTitlestringContentstring}Scaffold and CRUD Generation
The anar CLI can generate models, handlers, migrations, and request validations automatically.
Generated models can embed gorm.Model by default and integrate seamlessly with CRUD handlers and Gin routes.
This allows developers to quickly create new entities and their full API with a single command.
Routes
API routes are registered in routes/routes.go.
Routes include:
- Public routes: register, login, confirm email, OAuth login
- Protected routes: CRUD endpoints for models
Scheduler
Anar includes a scheduler for running background jobs, cron tasks, and delayed jobs.
Build and Run
Build the project:
go build ./...
Run the server:
go run main.go
The server loads configuration from .env or system environment variables.
License
This project is licensed under the GNU Lesser General Public License (LGPL). See the LICENSE file for details.
Author
Ali Miracle – Designer and maintainer of Anar Email: alimiracle@riseup.net