---
title: "Deploy OpenShortURL"
description: "Open-source URL shortener with analytics, custom slugs, QR codes & API"
category: "Other"
url: https://railway.com/deploy/openshorturl-1
---

# Deploy OpenShortURL

Open-source URL shortener with analytics, custom slugs, QR codes & API

**[Deploy OpenShortURL on Railway](https://railway.com/template/openshorturl-1)**

- **Creator:** supra126
- **Category:** Other
- **Total deploys:** 24

## Template content

### frontend https://devicons.railway.com/i/nextjs-light.svg

- **Image:** ghcr.io/supra126/open-short-url-frontend:latest

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:17.7

### backend https://devicons.railway.com/i/nestjs.svg

- **Image:** ghcr.io/supra126/open-short-url-backend:latest

### Redis https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg

- **Image:** redis:8.4.0
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

## Documentation

# Deploy and Host OpenShortURL on Railway

OpenShortURL is a modern, self-hosted URL shortener with advanced analytics and security features. Built with NestJS, Next.js 16, and React 19, it provides custom slugs, password protection, UTM tracking, two-factor authentication, link bundles for organization, bot detection and filtering, comprehensive click analytics, QR code generation, and AI-powered features including a built-in chat assistant (supporting Anthropic Claude, OpenAI GPT, Google Gemini, Mistral, and Cohere) and Model Context Protocol (MCP) integration for managing URLs through external AI tools like Claude Desktop.

## About Hosting OpenShortURL

Deploying OpenShortURL on Railway provides a complete URL shortening solution with minimal configuration. The platform includes a NestJS backend API, Next.js frontend dashboard, PostgreSQL database, and Redis for caching. It features a built-in AI chat assistant for managing URLs through natural conversation (optional, requires AI provider API key), link bundles for organizing URLs into collections, automatic bot detection and filtering, Cloudflare Turnstile integration, JWT-based authentication with httpOnly cookies, and real-time analytics including geolocation tracking, device detection, browser analysis, and referrer statistics. The entire stack deploys automatically with Railway's infrastructure.

## Common Use Cases

- Track marketing campaign performance with UTM parameters and detailed click analytics
- Create branded short links with custom slugs for social media and content sharing
- Secure internal link sharing with password protection and two-factor authentication
- Organize URLs into bundles/collections for better campaign and project management
- Filter bot traffic from analytics to get accurate human interaction metrics
- Manage URLs through conversational AI directly in the web interface using the built-in chat assistant
- Integrate with external AI assistants (Claude Desktop, Cursor, Windsurf) using natural language via MCP integration

## Dependencies for OpenShortURL Hosting

- PostgreSQL database for storing URLs, users, bundles, and analytics data
- Redis (optional) for caching, session management, and rate limiting
- Node.js 20+ runtime environment
- Cloudflare Turnstile (optional) for bot protection
- AI Provider API Key (optional) for built-in chat assistant:
  - Anthropic API key for Claude models
  - OpenAI API key for GPT models
  - Google API key for Gemini models
  - Mistral API key for Mistral models
  - Cohere API key for Cohere models

### Deployment Dependencies

- [OpenShortURL GitHub Repository](https://github.com/supra126/open-short-url)
- [NestJS Framework Documentation](https://nestjs.com/)
- [Next.js Framework Documentation](https://nextjs.org/)
- [Prisma ORM Documentation](https://www.prisma.io/)

### Implementation Details

**Required Environment Variables:**

```bash
DATABASE_URL=postgresql://user:password@host:5432/database
JWT_SECRET=your-jwt-secret-key
SHORT_URL_DOMAIN=https://your-domain.com
```

**Optional AI Chat Assistant Variables:**

```bash
AI_PROVIDER=anthropic  # Options: anthropic, openai, google, mistral, cohere
AI_MODEL=claude-3-5-sonnet-20241022
ANTHROPIC_API_KEY=sk-ant-your-api-key-here
# OR
AI_PROVIDER=openai
AI_MODEL=gpt-4o
OPENAI_API_KEY=sk-your-api-key-here
# OR
AI_PROVIDER=google
AI_MODEL=gemini-2.0-flash-exp
GOOGLE_API_KEY=your-api-key-here
# OR
AI_PROVIDER=mistral
AI_MODEL=mistral-large-latest
MISTRAL_API_KEY=your-api-key-here
# OR
AI_PROVIDER=cohere
AI_MODEL=command-r-plus
COHERE_API_KEY=your-api-key-here
```

**Post-Deployment:**

```bash
npx prisma migrate deploy
```

## Why Deploy OpenShortURL on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying OpenShortURL on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/openshorturl-1
