This project is a Go-based management server for EasyEditor Premium, integrating with local encrypted storage to manage license data, user credits, and token consumption tracking. Built with Gin, it provides an admin dashboard, API playground, and a full REST API for external app integration.
-
Go: Version 1.21 or higher.
-
Gmail Account: A Gmail account with an App Password for sending login tokens and welcome emails via SMTP.
-
Environment Configuration: Create a
.env.localfile in the project root with the following variables:GMAIL_USER=your-email@gmail.com GMAIL_PASS=your-app-password ADMIN_EMAIL=admin-email@gmail.com SERVER_PORT=5555 PRIME_KEY=xxxxxx-xxxxxx-xxxxxx-xxxxxx TLS_CERT=/path/to/your/cert.crt TLS_KEY=/path/to/your/private.key DEV_MODE=true
Variable Description GMAIL_USERGmail address used to send emails (login tokens, welcome emails) GMAIL_PASSGmail App Password (not your regular password) PRIME_KEYMaster API key used to authenticate all API requests via X-API-KeyheaderTLS_CERT(Optional) Path to the TLS certificate file ( .crt) for HTTPSTLS_KEY(Optional) Path to the TLS private key file ( .key) for HTTPSSERVER_PORTPort the server listens on (defaults to 8080)PRIME_KEYMaster API key used to authenticate all API requests via X-API-KeyheaderDEV_MODEDisable the dashboard login credentials
The admin dashboard uses a passwordless email-based login flow:
- The admin visits
/and clicks "Request Login Token". - A one-time token is generated and emailed to the configured
ADMIN_EMAIL. - The admin enters the token to authenticate and is redirected to
/dashboard. - Tokens expire after 10 minutes and are single-use.
All API endpoints under /api/* are protected by the X-API-Key header, which must match the PRIME_KEY from your environment configuration.
- Install dependencies:
go mod tidy
- Build the application:
go build . - Run the server:
The server will start on
go run .0.0.0.0:<SERVER_PORT>(defaults to8080if not set).
├── main.go # Server entry point, routes, and API handlers
├── email.go # Email sending (login tokens, welcome emails) and token management
├── crypto_utils.go # AES-GCM encryption/decryption for local data storage
├── .env.local # Environment variables (not committed)
├── .local/ # Encrypted local data cache
├── static/css/ # Dashboard stylesheets
├── templates/ # HTML templates (login, dashboard, API docs, emails)
└── docs/ # External integration guide
Access the admin dashboard at /dashboard after logging in. It provides a UI to:
- View all registered users and their credit balances
- Create new users (auto-generates a license ID or accepts a custom one)
- Update user credits and top-up amounts
- Delete users
- Monitor token consumption per user
Visit /api-docs for an interactive API documentation page. It comes pre-filled with your PRIME_KEY and lets you test all endpoints directly from the browser.
All endpoints require the X-API-Key header.
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/local-data |
List all users and credit data |
GET |
/api/credits/:licenseId |
Get credits for a specific user |
POST |
/api/check-credits |
Check if a user has enough tokens |
POST |
/api/report-usage |
Report token usage after an LLM call |
POST |
/api/update-credits |
Update a user's credit balance |
POST |
/api/create-user |
Create a new user with a license |
POST |
/api/delete-user |
Delete a user (requires licenseId + email) |
DELETE |
/api/delete-credits/:licenseId |
Remove a user by license ID |
For detailed integration instructions with curl and PowerShell examples, see the External App Guide.
This server is 100% standalone with no external database dependencies.
- User data is stored locally in
.local/credits_cache.json.enc - Data is encrypted at rest using AES-GCM
- No user data leaves your server
The passwordless login page where the admin requests a one-time token via email.
The token input step where the admin pastes the token received by email.
Confirmation screen after a successful token submission.
The main dashboard showing all registered users, their credits, and management actions.
A detailed view of an individual user's credit balance and token usage.
A view showing token consumption details and usage tracking per user.
The LLM-specific dashboard for monitoring AI model usage and token metrics.
The interactive API docs playground for testing endpoints directly in the browser.
A sample of the welcome email sent to new users with their license details.








