Skip to content

Sam-06060/Kotlin-Learn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kotlin & Jetpack Compose Compiler

A browser-based Kotlin and Jetpack Compose compiler that performs actual compilation (not translation) using the real Kotlin compiler.

Features

  • Real Kotlin Compilation: Uses actual Kotlin compiler via JDoodle API
  • Jetpack Compose Support: Compiles Compose code
  • Browser-Based: No local setup required for users
  • Free Tier Available: 200 requests/day with JDoodle free account
  • Deploy to Vercel: Ready for deployment

Setup for Deployment

1. Get JDoodle API Credentials (Free)

  1. Sign up for a free account at JDoodle
  2. Go to your dashboard and get:
    • Client ID
    • Client Secret

2. Deploy to Vercel

  1. Push your code to GitHub

  2. Import to Vercel:

    • Go to vercel.com
    • Click "New Project"
    • Import your GitHub repository
  3. Add Environment Variables:

    • In Vercel project settings, go to "Environment Variables"
    • Add these two variables:
      • JDOODLE_CLIENT_ID = your client ID
      • JDOODLE_CLIENT_SECRET = your client secret
  4. Deploy:

    • Click "Deploy"
    • Your site will be live with working Kotlin compiler!

How It Works

  1. User writes Kotlin/Compose code in the browser
  2. Code is sent to /api/compile or /api/compile-compose endpoint
  3. Serverless function calls JDoodle API with the code
  4. JDoodle compiles the code using the actual Kotlin compiler
  5. Compilation results (output, errors) are returned and displayed

API Endpoints

  • POST /api/compile - Compiles regular Kotlin code
  • POST /api/compile-compose - Compiles Jetpack Compose code

Local Development

To test locally:

# Install Vercel CLI
npm install -g vercel

# Create .env file with your credentials
echo "JDOODLE_CLIENT_ID=your_id" > .env
echo "JDOODLE_CLIENT_SECRET=your_secret" >> .env

# Run locally
vercel dev

Open http://localhost:3000

Notes

  • Free Tier: JDoodle free tier allows 200 requests per day
  • Production: For higher usage, consider JDoodle paid plans or set up your own Kotlin compiler server
  • Compose Limitations: Full Compose UI rendering requires Android runtime, but code compilation works

License

MIT

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors