Skip to content

ludovic/livecode-session

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ LiveCode Session

A real-time collaborative code sharing platform that allows developers to share their coding sessions live with spectators. Built with FastAPI (backend) and React (frontend).

✨ Features

  • πŸ“ Real-time Code Collaboration: Share your code with multiple spectators in real-time
  • 🎨 Syntax Highlighting: Powered by Monaco Editor with support for multiple languages
  • πŸ‘₯ Role-based Access: Presenter (read/write) vs Spectator (read-only)
  • πŸ”„ Live Synchronization: WebSocket-based real-time updates
  • 🌐 Multi-language Support: Python, JavaScript, TypeScript, and more

🌐 Live Demo

Frontend: https://livecode-session.up.railway.app/
Backend API: https://livecode-session-production.up.railway.app
API Docs: https://livecode-session-production.up.railway.app/docs

πŸ—οΈ Tech Stack

Backend

  • FastAPI - Modern Python web framework
  • WebSocket - Real-time bidirectional communication
  • Uvicorn - Lightning-fast ASGI server
  • Pydantic - Data validation

Frontend

  • React 18 with TypeScript
  • Vite - Next generation frontend tooling
  • TanStack Router - Type-safe routing
  • TanStack Query - Powerful data synchronization
  • Zustand - Lightweight state management
  • Monaco Editor - VS Code's editor in the browser

πŸš€ Deployment

This application is deployed on Railway with automatic deployments from GitHub.

Backend (FastAPI)

Frontend (React)

Environment Variables

Frontend (set in Railway Variables):

VITE_API_URL=https://livecode-session-production.up.railway.app
VITE_WS_URL=wss://livecode-session-production.up.railway.app

πŸ› οΈ Local Development

Prerequisites

  • Python 3.9+
  • Node.js 18+
  • npm or yarn

Backend Setup

cd backend
pip install -r requirements.txt
uvicorn main:app --reload --host 0.0.0.0 --port 8000

The API will be available at http://localhost:8000

  • API docs (Swagger): http://localhost:8000/docs
  • Health check: http://localhost:8000/health

Frontend Setup

cd frontend
npm install
npm run dev

The frontend will be available at http://localhost:5173

Environment Variables (Local)

Create .env in the frontend directory:

VITE_API_URL=http://localhost:8000
VITE_WS_URL=ws://localhost:8000

πŸ“ Project Structure

livecode-session/
β”œβ”€β”€ backend/                 # FastAPI backend
β”‚   β”œβ”€β”€ main.py             # Main application entry
β”‚   β”œβ”€β”€ requirements.txt    # Python dependencies
β”‚   └── railway.toml        # Railway backend config
β”œβ”€β”€ frontend/               # React frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/     # React components
β”‚   β”‚   β”œβ”€β”€ hooks/          # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ pages/          # Page components
β”‚   β”‚   β”œβ”€β”€ routes/         # Router configuration
β”‚   β”‚   └── store/          # Zustand state management
β”‚   β”œβ”€β”€ railway.toml        # Railway frontend config
β”‚   β”œβ”€β”€ vite.config.ts      # Vite configuration
β”‚   └── .env.production     # Production environment variables
└── README.md

πŸ”Œ API Endpoints

REST API

  • POST /sessions - Create a new session
  • GET /sessions/{session_id} - Get session details
  • PUT /sessions/{session_id} - Update session code
  • GET /health - Health check endpoint

WebSocket

  • WS /ws/{session_id}/{role} - Connect to session
    • Events: init, code_update, cursor_move
    • Roles: presenter or spectator

πŸ›οΈ Architecture

Session Management

  • Each coding session has a unique ID
  • Sessions are stored in-memory (can be extended to use a database)

WebSocket Rooms

  • Clients join rooms based on session ID
  • Real-time synchronization using WebSocket events

Role-based Access

  • Presenter: Full read/write access to the code
  • Spectator: Read-only access with real-time updates

Real-time Synchronization

  • Code changes are broadcast via WebSocket
  • All connected clients receive updates instantly

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is open source and available under the MIT License.

πŸ™ Acknowledgments

  • Monaco Editor by Microsoft
  • FastAPI by SebastiΓ‘n RamΓ­rez
  • Railway for hosting

Enjoy coding together! πŸŽ‰

About

Real-time collaborative code sharing platform with FastAPI and React

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors