A fast, secure REST API built in Go that synchronizes and serves game data from the MatD1/arcraiders-data-fork repository.
- Data Synchronization: Automatically syncs JSON data from GitHub repository on a configurable schedule
- CRUD Operations: Full CRUD API for Missions, Items, Skill Nodes, and Hideout Modules
- Dual Authentication: Requires both API keys and JWT tokens for all protected endpoints
- OAuth Integration: Optional GitHub OAuth for user authentication
- Comprehensive Logging: All requests are logged with API key/JWT information for auditing
- Management API: Admin endpoints for managing API keys, JWT tokens, and querying logs
- Web Dashboard: Built-in Next.js frontend accessible at
/dashboardfor managing all data - High Performance: Uses Go concurrency features and optional Redis caching
- PostgreSQL: Persistent storage with proper indexing
- Docker Support: Complete Docker Compose setup for local development
- Go 1.24 or higher
- Node.js 18+ and npm (for frontend)
- PostgreSQL 12 or higher
- Redis (optional, for caching)
- Docker and Docker Compose (optional)
- Clone the repository:
git clone <repository-url>
cd ArcAPI- Copy the example environment file:
cp .env.example .env-
Update
.envwith your configuration:- Set
DB_PASSWORDfor PostgreSQL - Set
JWT_SECRET(use a secure random string) - Set
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRETif using OAuth
- Set
-
Install dependencies:
go mod download
cd frontend && npm install && cd ..- Build the frontend:
make build-frontend
# Or manually:
cd frontend && npm run build && cd ..- Start PostgreSQL and Redis (if using Docker Compose):
docker-compose up -d postgres redis- Run the application:
go run cmd/server/main.go
# Or make runThe API will be available at http://localhost:8080
The Dashboard will be available at http://localhost:8080/dashboard
- Copy
.env.exampleto.envand configure it:
cp .env.example .env- Build and start all services:
docker-compose build
docker-compose up -dThe Dockerfile will automatically build the frontend during the image build process.
All configuration is done via environment variables. See .env.example for all available options.
DB_HOST,DB_PORT,DB_USER,DB_PASSWORD,DB_NAME: PostgreSQL connection detailsREDIS_ADDR,REDIS_PASSWORD: Redis connection (optional)JWT_SECRET: Secret key for JWT signing (required)JWT_EXPIRY_HOURS: JWT token expiration time (default: 72)GITHUB_CLIENT_ID,GITHUB_CLIENT_SECRET: GitHub OAuth credentialsOAUTH_ENABLED: Enable/disable OAuth (default: true)SYNC_CRON: Cron expression for sync schedule (default:*/15 * * * *= every 15 minutes)PORT: Server port (default: 8080, Railway uses PORT env var)LOG_LEVEL: Logging level (debug, info, warn, error)
Access the integrated web dashboard at /dashboard after starting the server.
Features:
- Login: Use your API key to authenticate
- Dashboard: Overview of all entities
- CRUD Operations: Full Create, Read, Update, Delete interfaces for:
- Missions
- Items
- Skill Nodes
- Hideout Modules
- Management:
- API Key management (create, revoke, view)
- JWT Token management
- Audit Logs viewer with filtering
The dashboard is built with Next.js and automatically detects the API URL.
See docs/api.md for complete API documentation.
GET /api/v1/auth/github/login- Initiate GitHub OAuth flowGET /api/v1/auth/github/callback- OAuth callback handlerPOST /api/v1/auth/login- Login with API key and get JWT token
All data endpoints require both an API key (header: X-API-Key) and a JWT token (header: Authorization: Bearer <token>).
GET /api/v1/missions- List missions (paginated)GET /api/v1/missions/:id- Get mission by IDPOST /api/v1/missions- Create missionPUT /api/v1/missions/:id- Update missionDELETE /api/v1/missions/:id- Delete mission
Similar endpoints for /items, /skill-nodes, /hideout-modules.
POST /api/v1/admin/api-keys- Create API keyGET /api/v1/admin/api-keys- List API keysDELETE /api/v1/admin/api-keys/:id- Revoke API keyPOST /api/v1/admin/jwts/revoke- Revoke JWT tokenGET /api/v1/admin/jwts- List active JWT tokensGET /api/v1/admin/logs- Query audit logs with filters
GET /health- Health check endpoint
-
Via OAuth (if enabled):
- Visit
/api/v1/auth/github/loginto initiate OAuth - After GitHub authentication, you'll receive a JWT token
- Create an API key via the management API (requires admin role initially)
- Visit
-
Via API Key:
- Login with API key via
POST /api/v1/auth/login - Receive JWT token in response
- Use both API key and JWT token for subsequent requests
- Login with API key via
-
Via Dashboard:
- Visit
/dashboardin your browser - Login with your API key
- Access all features through the web interface
- Visit
All protected endpoints require:
- API Key: Send in
X-API-Keyheader - JWT Token: Send in
Authorization: Bearer <token>header
Example:
curl -H "X-API-Key: your-api-key" \
-H "Authorization: Bearer your-jwt-token" \
http://localhost:8080/api/v1/missionsThe sync service automatically fetches JSON data from the MatD1/arcraiders-data-fork repository on a schedule defined by SYNC_CRON. By default, it runs every 15 minutes.
The sync service:
- Fetches JSON files for missions, items, skill nodes, and hideout modules
- Parses and maps data to the database
- Uses upsert logic (updates existing records or creates new ones)
- Runs concurrently for better performance
ArcAPI/
├── cmd/server/ # Application entry point
├── frontend/ # Next.js frontend (served at /dashboard)
├── internal/
│ ├── config/ # Configuration management
│ ├── models/ # Database models
│ ├── handlers/ # HTTP handlers
│ ├── middleware/ # Middleware (auth, logging)
│ ├── services/ # Business logic
│ └── repository/ # Data access layer
├── migrations/ # SQL migration files
├── tests/ # Test files
├── docs/ # API documentation
├── docker-compose.yml # Docker Compose setup
└── Dockerfile # Application container
# Build everything (includes frontend)
make build
# Build just frontend
make build-frontendgo test ./...GORM automatically handles migrations on startup. See migrations/ for SQL reference.
- API Keys: Stored as bcrypt hashes, cannot be retrieved once created
- JWT Tokens: Signed with HS256, include expiration
- Passwords: All secrets should use strong, random values
- HTTPS: Use HTTPS in production
- Rate Limiting: Consider adding rate limiting for production
[Add your license here]
[Add contributing guidelines here]