Getting Started with TangleCat
Prerequisites
Section titled “Prerequisites”Ensure that the following are installed on your device:
- Docker and Docker Compose (for containerized setup)
- Node.js 20+ (for local development)
- Git (for cloning the repository)
Quick Start (Docker - Recommended)
Section titled “Quick Start (Docker - Recommended)”The fastest way to get started is using Docker Compose, which will set up both the Next.js frontend and Sanity Studio automatically.
1. Clone the Repository
Section titled “1. Clone the Repository”git clone <your-repository-url>cd leaderboard-challenges
2. Environment Setup
Section titled “2. Environment Setup”Create a .env
file in the root directory:
# EnvironmentNODE_ENV=developmentPORT=8080
# Sanity ConfigurationNEXT_PUBLIC_SANITY_PROJECT_ID=your_project_idNEXT_PUBLIC_SANITY_DATASET=productionNEXT_PUBLIC_SANITY_DATASET_DEV=developmentSANITY_API_VERSION=2024-03-21SANITY_API_TOKEN=your_api_token
# Sanity Studio Environment VariablesSANITY_STUDIO_PUBLIC_SANITY_PROJECT_ID=your_project_idSANITY_STUDIO_PUBLIC_SANITY_DATASET=productionSANITY_STUDIO_PUBLIC_SANITY_DATASET_DEV=development
3. Start the Development Environment
Section titled “3. Start the Development Environment”# Start both frontend and Sanity Studiodocker compose up
# Or start them separatelydocker compose up web # Frontend onlydocker compose up sanity # Sanity Studio only
4. Access Your Applications
Section titled “4. Access Your Applications”- Frontend: http://localhost:8080
- Sanity Studio: http://localhost:3333
Manual Setup (Alternative)
Section titled “Manual Setup (Alternative)”If you prefer to run the services directly on your machine without Docker:
Frontend Setup
Section titled “Frontend Setup”cd appnpm installnpm run dev
The frontend will be available at http://localhost:3000
Sanity Studio Setup
Section titled “Sanity Studio Setup”cd app/sanitynpm installnpm run dev
The Sanity Studio will be available at http://localhost:3333
Sanity Configuration
Section titled “Sanity Configuration”Initial Setup
Section titled “Initial Setup”- Create a Sanity.io account
- Create a new project (name and org should match your event)
- Note your Project ID from the dashboard
- Create two datasets: production and development
- Configure CORS origins:
- Add
http://localhost:8080
for Docker setup - Add
http://localhost:3000
for manual setup - Add
http://localhost:3333
for Sanity Studio
- Add
- Create an API token with Editor permissions
Environment Variables
Section titled “Environment Variables”Ensure these are set in your .env
file:
# Required for frontendNEXT_PUBLIC_SANITY_PROJECT_ID=your_project_idNEXT_PUBLIC_SANITY_DATASET=productionNEXT_PUBLIC_SANITY_DATASET_DEV=developmentSANITY_API_VERSION=2024-03-21SANITY_API_TOKEN=your_api_token
# Required for Sanity StudioSANITY_STUDIO_PUBLIC_SANITY_PROJECT_ID=your_project_idSANITY_STUDIO_PUBLIC_SANITY_DATASET=productionSANITY_STUDIO_PUBLIC_SANITY_DATASET_DEV=development
Project Structure
Section titled “Project Structure”leaderboard-challenges/├── app/ # Next.js frontend application│ ├── src/ # Source code│ ├── sanity/ # Sanity Studio configuration│ └── package.json # Frontend dependencies├── website/ # Documentation site (this site)├── docker-compose.yml # Frontend container configuration├── docker-compose.sanity.yml # Sanity Studio container configuration└── .env # Environment variables
Development Workflow
Section titled “Development Workflow”1. Start Development Environment
Section titled “1. Start Development Environment”# Using Docker (recommended)docker compose up
# Or manuallycd app && npm run devcd app/sanity && npm run dev
2. Make Changes
Section titled “2. Make Changes”- Frontend code changes will hot-reload automatically
- Sanity Studio changes will hot-reload automatically
- Schema changes require restarting Sanity Studio
3. Database Management
Section titled “3. Database Management”- Access Sanity Studio at http://localhost:3333
- Create and manage your content models
- Import demo data if available
4. Testing
Section titled “4. Testing”- Frontend: http://localhost:8080 (Docker) or http://localhost:3000 (manual)
- Test all features including authentication, challenges, and awards
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Port Already in Use
# Check what's using the portlsof -i :8080lsof -i :3333
# Kill the process or change ports in docker-compose.yml
Sanity Connection Issues
- Verify your
.env
file has correct values - Check CORS origins in Sanity dashboard
- Ensure API token has correct permissions
Docker Issues
# Rebuild containersdocker compose downdocker compose up --build
# Clear Docker cachedocker system prune -a
Getting Help
Section titled “Getting Help”- Check the Developer Guide for detailed setup instructions
- Review Sanity.io documentation
- Check Next.js documentation
Next Steps
Section titled “Next Steps”Once your local environment is running:
- Set up your content models in Sanity Studio
- Create demo data for testing
- Customize the frontend for your event
- Test the complete workflow from user registration to award completion
- Deploy to production when ready
For detailed customization and advanced setup, see the Developer Guide.