DEV Community

Łukasz Stroisz
Łukasz Stroisz

Posted on

RAITHOS777: Deploy 4 Vercel Apps Like a Pro

You've just discovered RAITHOS777 and its suite of four Vercel applications, but the documentation feels scattered. You're staring at four different repos, wondering how they fit together, and you're not sure which app does what. Let's fix that confusion right now.

What you'll learn

  • How RAITHOS777's four applications work together as a cohesive system
  • Step-by-step deployment strategies for each app on Vercel
  • Environment configuration and secrets management across multiple apps
  • Common deployment mistakes that waste hours of debugging time

Why RAITHOS777 matters right now

Modern web development rarely involves a single monolithic application. You've got your frontend, your API, maybe a worker for background jobs, and a separate admin dashboard. RAITHOS777 embraces this architecture by packaging four distinct applications that can be deployed independently but work together seamlessly. This approach gives you flexibility—scale only what needs scaling, deploy updates to one service without touching others, and organize your codebase around business domains rather than technical layers. Vercel's platform makes this particularly appealing with its zero-config deployments, built-in CI/CD, and generous free tier for hobby projects.

Understanding the Four Applications

RAITHOS777 consists of four distinct applications, each serving a specific purpose in the ecosystem. Let's break down what each one does and how they interact.

The frontend application is your user-facing interface—the React, Vue, or Next.js app that visitors interact with directly. This is typically your SPA or static site that handles routing, state management, and user interactions.

The API application serves as your backend layer, exposing REST or GraphQL endpoints that your frontend consumes. This handles business logic, data processing, and authentication flows.

The worker application runs background jobs—think cron jobs, email processing, or heavy computations that shouldn't block your main API responses. In Vercel, this typically deploys as a serverless function triggered by webhooks or scheduled events.

The admin dashboard provides an interface for managing your application's data, users, and configuration. Think of it as your internal control panel, often protected with stricter authentication than the public-facing frontend.

Deploying to Vercel: The Basics

Vercel makes deployment straightforward, but getting four apps right requires some setup. Let's walk through the process for each application type.

Frontend Deployment

Your frontend app is usually the simplest to deploy. Here's a TypeScript configuration example for a Next.js frontend:

// next.config.js
const nextConfig = {
  // Output standalone for better Vercel compatibility
  output: 'standalone',

  // Environment variables exposed to the browser
  env: {
    NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
    NEXT_PUBLIC_APP_VERSION: process.env.npm_package_version,
  },

  // Image optimization configuration
  images: {
    domains: ['your-cdn-domain.com'],
    formats: ['image/avif', 'image/webp'],
  },
}

module.exports = nextConfig
Enter fullscreen mode Exit fullscreen mode

This configuration does three things: enables standalone output for smaller deployments, exposes necessary environment variables to the browser (prefixed with NEXT_PUBLIC_), and configures image optimization domains. The standalone output mode is particularly useful—it reduces deployment size by only including necessary dependencies.

Push this to your Git repository, connect it to Vercel, and Vercel will auto-detect Next.js and handle the build. No complex build commands needed.

API Application Setup

Your API application needs different considerations. Here's a TypeScript example for a serverless API:

// api/users/index.ts
import { NextApiRequest, NextApiResponse } from 'next'

// Database connection should be outside the handler for connection pooling
let db: any = null

async function getDatabase() {
  if (!db) {
    // Lazy initialization - connection happens on first request
    const { MongoClient } = await import('mongodb')
    const client = new MongoClient(process.env.DATABASE_URL!)
    await client.connect()
    db = client.db('raithos777')
  }
  return db
}

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse
) {
  // Only allow GET requests
  if (req.method !== 'GET') {
    return res.status(405).json({ error: 'Method not allowed' })
  }

  try {
    const db = await getDatabase()
    const users = await db.collection('users')
      .find({})
      .project({ password: 0 }) // Never expose passwords
      .toArray()

    res.status(200).json({ users })
  } catch (error) {
    console.error('API Error:', error)
    res.status(500).json({ error: 'Internal server error' })
  }
}
Enter fullscreen mode Exit fullscreen mode

This API handler demonstrates several best practices: lazy database initialization (crucial for serverless cold starts), method validation, proper error handling, and sensitive data filtering. Notice how the database connection is established outside the handler but initialized lazily—this allows Vercel to reuse connections across warm invocations while still handling cold starts gracefully.

Worker Application Configuration

Workers in Vercel typically use cron jobs or webhook triggers. Here's how to structure a worker:

// api/cron/backup.ts
import { NextApiRequest, NextApiResponse } from 'next'

// Verify the request is from Vercel Cron
function isAuthorized(req: NextApiRequest): boolean {
  const authHeader = req.headers.authorization
  return authHeader === `Bearer ${process.env.CRON_SECRET}`
}

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse
) {
  // Security check - prevent unauthorized cron triggers
  if (!isAuthorized(req)) {
    return res.status(401).json({ error: 'Unauthorized' })
  }

  const startTime = Date.now()

  try {
    // Your background job logic here
    console.log('Starting backup job...')

    // Simulate work - in production, this might be:
    // - Database backups
    // - Cache warming
    // - Email queue processing
    // - Data aggregation
    await new Promise(resolve => setTimeout(resolve, 5000))

    const duration = Date.now() - startTime
    console.log(`Backup completed in ${duration}ms`)

    res.status(200).json({ 
      success: true, 
      duration: `${duration}ms`,
      timestamp: new Date().toISOString()
    })
  } catch (error) {
    console.error('Worker error:', error)
    res.status(500).json({ error: 'Job failed' })
  }
}

// Configure Vercel Cron in vercel.json
// {
//   "crons": [{
//     "path": "/api/cron/backup",
//     "schedule": "0 2 * * *"
//   }]
// }
Enter fullscreen mode Exit fullscreen mode

The worker includes authentication to prevent unauthorized triggers—anyone with the URL could hit your endpoint otherwise. The CRON_SECRET should be set in your Vercel environment variables. The comment at the bottom shows how to configure the cron schedule in vercel.json, using standard cron syntax (this example runs daily at 2 AM UTC).

Environment Variables Across Apps

Managing environment variables across four applications can get messy. Here's a strategy that keeps things organized:

Shared variables (like API keys for third-party services) should be defined once and referenced across apps. In Vercel, you can use the same variable name in each project, or use Vercel's environment variable synchronization features if you're on a team plan.

App-specific variables should be namespaced. For example, use FRONTEND_API_URL for your frontend and API_DATABASE_URL for your API, rather than generic names like API_URL that could cause confusion.

Never commit .env files to version control. Instead, document required variables in a .env.example file:

# .env.example - Commit this file
# Database
DATABASE_URL=mongodb+srv://localhost:27017/raithos777

# API Configuration
API_SECRET_KEY=your-secret-key-here
CRON_SECRET=your-cron-secret-here

# Frontend Public Variables
NEXT_PUBLIC_API_URL=https://your-api.vercel.app
Enter fullscreen mode Exit fullscreen mode

This gives new developers a template without exposing actual secrets.

Common Pitfalls to Avoid

Mixing frontend and backend code

Don't put your API routes inside your frontend app if you plan to scale them separately. Keep them in distinct repositories or at least distinct Vercel projects. This lets you deploy frontend updates without risking API downtime and vice versa.

Forgetting cold start considerations

Serverless functions have cold starts—your database connection logic needs to handle this. Don't create a new connection on every request (too slow) or assume connections persist forever (they don't). Use connection pooling and lazy initialization like the example above.

Hardcoding URLs across environments

Never hardcode your API URL in frontend code. Use environment variables and different values for preview, production, and development environments. Vercel automatically provides VERCEL_URL which you can use to construct URLs dynamically.

Wrap-up

RAITHOS777's four-application architecture gives you flexibility and scalability that monolithic deployments can't match. By separating concerns into frontend, API, worker, and admin applications, you can iterate faster, scale smarter, and organize your codebase around business domains.

Key takeaways:

  • Deploy each application independently to Vercel for maximum flexibility
  • Use environment variables consistently across all four apps
  • Implement proper authentication for worker endpoints
  • Design your serverless functions with cold starts in mind

Next steps:

  1. Set up your four Vercel projects and connect them to your Git repositories
  2. Configure environment variables using the .env.example template approach
  3. Deploy your frontend first, then progressively add the API, worker, and admin dashboard
  4. Set up monitoring and logging to track performance across all applications

Top comments (0)