# Setup Guide

## Initial Setup

When you first deploy Sanasto Wiki, you need to create an initial administrator account.

### Automatic Setup (Recommended)

1. Start the Rails server:
   ```bash
   bundle exec rails server
   ```

2. Navigate to `/setup` in your browser

3. Fill in the setup form:
   - **Name**: Your full name
   - **Email**: Your email address (becomes the system default contact)
   - **Preferred Language**: Your primary working language
   - **Password**: At least 12 characters
   - **Confirm Password**: Re-enter your password

4. Click "Complete Setup"

5. You'll be automatically logged in and redirected to the admin dashboard

### What Happens During Setup

- Creates your admin account with full permissions
- Sets you as the default system contact (User.first.email)
- Creates a `.installed` marker file to prevent re-running setup
- Automatically logs you in
- Protects your account from deletion (first user cannot be deleted)

### After Setup

Once setup is complete:
- The `/setup` route becomes inaccessible
- You can access the admin dashboard at `/admin`
- You can invite other users through the admin interface
- The first admin user (you) is protected from deletion

### Resetting Setup

If you need to re-run setup (e.g., in development):

```bash
# Remove the installed marker
rm .installed

# Clear the database (development only!)
bundle exec rails db:reset

# Now you can access /setup again
```

### Production Deployment

For production deployment:
1. Deploy the application
2. Run migrations: `bundle exec rails db:migrate`
3. Navigate to your domain's `/setup` route
4. Complete the setup form
5. Start inviting contributors

The `.installed` file should NOT be committed to version control (it's in .gitignore).

### Security Notes

- The setup route is only accessible when `.installed` file doesn't exist
- Password must be at least 12 characters
- The first admin user cannot be deleted through the UI
- Setup automatically creates an admin-level account
- After setup, use the invitation system to add more users
