Skip to content

Cloud-kit is a deployment platform built with TypeScript, Node.js, Redis, and AWS S3. This project demonstrates a complete CI/CD pipeline for deploying React applications with automatic builds and hosting.

Notifications You must be signed in to change notification settings

Harsh22428/Cloud-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Cloud-Kit

Cloud-kit is a deployment platform built with TypeScript, Node.js, Redis, and AWS S3. This project demonstrates a complete CI/CD pipeline for deploying React applications with automatic builds and hosting.

🎯 Overview

This platform enables users to deploy React applications directly from GitHub repositories, similar to Vercel. The system automatically clones repositories, builds projects, and serves them through a custom domain infrastructure.

πŸ—οΈ Architecture

The project follows a microservices architecture with three primary services:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend  β”‚
β”‚   (React)   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”‚ GitHub URL
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Upload Service  β”‚ ──► Clone Repo ──► Upload to S3 ──► Push to Redis Queue
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”‚ deployment-id
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Deploy Service   β”‚ ──► Pull from Queue ──► Build Project ──► Upload Build to S3
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”‚ Build artifacts
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Request Handler  β”‚ ──► Serve from S3 ──► Deliver to Browser
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Services

1. Upload Service (vercel-upload-service)

  • Purpose: Handles GitHub repository ingestion
  • Responsibilities:
    • Receives GitHub repository URLs from the frontend
    • Clones the repository to a temporary directory
    • Uploads the project files to AWS S3
    • Generates a unique deployment ID
    • Pushes the deployment job to Redis Queue for processing
    • Tracks upload status

2. Deploy Service (vercel-deploy-service)

  • Purpose: Builds and deploys projects
  • Responsibilities:
    • Monitors Redis Queue for new deployment jobs
    • Retrieves project files from S3
    • Runs concurrent workers to build React projects
    • Executes npm install and npm run build
    • Uploads built artifacts (HTML, CSS, JS) back to S3
    • Updates deployment status in Redis

3. Request Handler Service (vercel-request-handler)

  • Purpose: Serves deployed applications
  • Responsibilities:
    • Processes incoming HTTP requests
    • Extracts subdomain from request URL
    • Fetches corresponding built files from S3
    • Serves static files to the browser
    • Handles routing for deployed applications

4. Frontend

  • Purpose: User interface for deployment management
  • Technology: React + TypeScript (Vite)
  • Features:
    • GitHub repository URL input
    • Deployment initiation
    • Real-time deployment status tracking
    • Deployment link generation
    • Responsive UI

πŸ› οΈ Tech Stack

Backend

  • Runtime: Node.js
  • Language: TypeScript
  • Queue: Redis (for job management)
  • Storage: AWS S3 (for file storage) and Cloudflare
  • Additional:
    • Express.js (API framework)
    • Bull/BullMQ (Redis queue wrapper)

Frontend

  • Framework: React
  • Language: TypeScript
  • Build Tool: Vite
  • Styling: CSS

Infrastructure

  • AWS S3 for object storage
  • Redis for message queuing
  • Potential deployment on AWS EC2/ECS

πŸš€ Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • Redis server
  • AWS Account with S3 access
  • AWS CLI configured

Environment Variables

Create a .env file in each service directory:

# AWS Configuration
S3_BUCKET_NAME=your-bucket-name
S3_ACCESS_KEY_ID=your-access-key-id
S3_SECRET_ACCESS_KEY=your-secret-access-key
AWS_REGION=your-region

# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=your-redis-password

# Service Configuration
PORT=3000
BACKEND_UPLOAD_URL=http://localhost:3000

Installation

  1. Clone the repository
git clone https://github.com/hkirat/vercel.git
cd vercel
  1. Install dependencies for each service
# Upload Service
cd vercel-upload-service
npm install

# Deploy Service
cd ../vercel-deploy-service
npm install

# Request Handler
cd ../vercel-request-handler
npm install

# Frontend
cd ../frontend
npm install
  1. Build TypeScript services
# In each service directory
npm run build
# or
npx tsc -b

Running the Services

Start each service in separate terminal windows:

# Terminal 1 - Upload Service
cd vercel-upload-service
node dist/index.js

# Terminal 2 - Deploy Service
cd vercel-deploy-service
node dist/index.js

# Terminal 3 - Request Handler
cd vercel-request-handler
node dist/index.js

# Terminal 4 - Frontend
cd frontend
npm run dev

Configure Local Hosts

For local development, add entries to /etc/hosts:

sudo nano /etc/hosts

# Add entries like:
127.0.0.1   <deployment-id>.localhost

Usage

  1. Open the frontend at http://localhost:5173
  2. Enter a GitHub repository URL (must be a React project)
  3. Click "Upload" to start deployment
  4. Wait for the build process to complete
  5. Access your deployed site at the provided subdomain

πŸ”§ Development

Project Structure

vercel/
β”œβ”€β”€ frontend/                 # React frontend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ App.tsx
β”‚   β”‚   └── main.tsx
β”‚   └── package.json
β”‚
β”œβ”€β”€ vercel-upload-service/   # Upload service
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ aws.ts          # S3 operations
β”‚   β”‚   β”œβ”€β”€ index.ts        # Main server
β”‚   β”‚   └── utils.ts
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   └── package.json
β”‚
β”œβ”€β”€ vercel-deploy-service/   # Build & deploy service
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ aws.ts          # S3 operations
β”‚   β”‚   β”œβ”€β”€ index.ts        # Queue consumer & builder
β”‚   β”‚   └── utils.ts
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   └── package.json
β”‚
└── vercel-request-handler/  # Request handling service
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ aws.ts          # S3 retrieval
    β”‚   β”œβ”€β”€ index.ts        # HTTP server
    β”‚   └── utils.ts
    β”œβ”€β”€ tsconfig.json
    └── package.json

Building

Each service uses TypeScript and requires compilation:

npx tsc -b

🌐 Deployment Workflow

  1. User submits GitHub URL β†’ Frontend sends request to Upload Service
  2. Upload Service β†’ Clones repo, uploads to S3, queues deployment job
  3. Deploy Service β†’ Picks job from queue, builds project, uploads artifacts
  4. Request Handler β†’ Serves built files from S3 to end users

πŸ” AWS Configuration

S3 Bucket Setup

  1. Create an S3 bucket for storing projects
  2. Configure CORS policy:
[
  {
    "AllowedHeaders": ["*"],
    "AllowedMethods": ["GET", "PUT", "POST", "DELETE"],
    "AllowedOrigins": ["*"],
    "ExposeHeaders": []
  }
]
  1. Set appropriate IAM permissions for S3 access

IAM Permissions Required

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:PutObject",
        "s3:GetObject",
        "s3:ListBucket",
        "s3:DeleteObject"
      ],
      "Resource": [
        "arn:aws:s3:::your-bucket-name/*",
        "arn:aws:s3:::your-bucket-name"
      ]
    }
  ]
}

🚧 Scaling Considerations

For production deployment, consider:

Containerization

  • Docker: Containerize each service
  • Kubernetes: Orchestrate with K8s for auto-scaling
  • AWS ECS/EKS: Deploy on managed container services

Queue Management

  • Replace Redis with AWS SQS for managed queuing
  • Use AWS Lambda for serverless deployment workers
  • Implement AWS Fargate for auto-scaling based on queue size

Global Distribution

  • CloudFront: CDN for faster content delivery
  • AWS Global Accelerator: Optimize routing
  • Multi-region S3: Deploy across regions for redundancy

Monitoring & Logging

  • CloudWatch: Monitor service health and logs
  • X-Ray: Distributed tracing
  • Prometheus + Grafana: Custom metrics dashboard

πŸ” Testing

Test the deployment locally:

# Using curl to check deployed site
curl -H "Host: <deployment-id>.localhost:3001" http://localhost:3001

πŸ“ Troubleshooting

Common Issues

Build Fails

  • Ensure package.json has proper build script
  • Check Node.js version compatibility
  • Verify all dependencies are installed

Cannot Access Deployed Site

  • Update /etc/hosts file
  • Use HTTPS or configure proper DNS
  • Check S3 bucket permissions

Redis Connection Issues

  • Verify Redis server is running
  • Check Redis connection credentials
  • Ensure firewall allows Redis port

🀝 Contributing

Contributions are welcome! Please follow these steps:

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

πŸ“„ License

This project is open source and available for educational purposes.

πŸ™ Acknowledgments

  • Built as an educational project inspired by Vercel's architecture
  • Community contributions and feedback

πŸ“§ Contact

For questions or suggestions, please open an issue on GitHub.

⭐ Show Your Support

If you found this project helpful, please give it a star!

About

Cloud-kit is a deployment platform built with TypeScript, Node.js, Redis, and AWS S3. This project demonstrates a complete CI/CD pipeline for deploying React applications with automatic builds and hosting.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published