Overview
Get up and running with the ForkFit API — environment setup, configuration, and your first request.
Base URL
All API endpoints are served under the /api/v1 prefix. The server also exposes a health check at the root level.
GET /health → "ok"
GET /api/v1/auth/signup
GET /api/v1/auth/signin
...Rate Limiting
The API applies a global rate limit using Tower Governor:
- Rate: 1 request per second (sustained)
- Burst: Up to 120 requests
Rate Limited
When you exceed the rate limit, the server returns a 429 Too Many Requests response. Back off and retry with exponential delay.
Environment Configuration
The API reads configuration from environment variables. Copy .env.example to .env and fill in your values:
Prop
Type
Quick Start
Set up your environment
Clone the repository and configure environment variables:
POSTGRES_DB=forkfit
POSTGRES_USER=your_user
POSTGRES_PASSWORD=your_password
REDIS_HOST=localhost
REDIS_PORT=6379
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secretStart the server
cargo runThe server will automatically run database migrations and seed default roles/permissions on startup.
Verify the server is running
curl http://localhost:3001/health
# → okCreate your first account
curl -X POST http://localhost:3001/api/v1/auth/signup \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "securepassword123",
"full_name": "John Doe"
}'const response = await fetch('http://localhost:3001/api/v1/auth/signup', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'user@example.com',
password: 'securepassword123',
full_name: 'John Doe',
}),
});
const data = await response.json();
console.log(data.access_token);Database Seeding
On startup the server automatically:
- Creates an admin role with description "Full platform administrator"
- Creates a user role with description "Default application user"
- Seeds default permissions for the admin role:
roles:read,roles:createrole_permissions:managepermissions:read,permissions:createuser_roles:manage
- If
ADMIN_EMAILis set and that user exists, assigns the admin role to them