Overview
This guide will walk you through deploying your own Hive instance. Hive is designed to be easy to deploy on modern serverless platforms, with Vercel as the recommended option.This guide assumes you have basic familiarity with Git, npm, and environment variables. If you’re new to these tools, check out the linked resources.
Prerequisites
Before you begin, make sure you have:- Node.js 18+ installed on your machine
- Git for version control
- A Supabase account (free tier works great)
- A Vercel account (free tier recommended for hosting)
- A GitHub account for code repository
Architecture Overview
-- Users table (extends Supabase Auth)
CREATE TABLE usuarios (
id SERIAL PRIMARY KEY,
auth_user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
nombre_usuario TEXT UNIQUE NOT NULL,
correo TEXT UNIQUE NOT NULL,
nombre_completo TEXT,
puesto TEXT,
cedula TEXT UNIQUE,
foto_url TEXT,
ultimo_acceso TIMESTAMPTZ,
presence_state TEXT DEFAULT 'offline',
fecha_registro TIMESTAMPTZ DEFAULT NOW()
);
-- Projects table
CREATE TABLE proyectos (
id SERIAL PRIMARY KEY,
nombre TEXT UNIQUE NOT NULL,
descripcion TEXT,
estado TEXT DEFAULT 'activo',
fecha_inicio DATE NOT NULL,
fecha_fin DATE NOT NULL,
color TEXT DEFAULT '#ECFDF5',
opa FLOAT DEFAULT 0.65,
creador_id INTEGER REFERENCES usuarios(id) ON DELETE SET NULL,
fecha_creacion TIMESTAMPTZ DEFAULT NOW()
);
-- Tasks table
CREATE TABLE tareas (
id SERIAL PRIMARY KEY,
titulo TEXT NOT NULL,
descripcion TEXT,
estado TEXT DEFAULT 'pendiente',
prioridad TEXT DEFAULT 'media',
fecha_vencimiento DATE,
fecha_creacion TIMESTAMPTZ DEFAULT NOW(),
porcentaje_completado INTEGER DEFAULT 0,
proyecto_id INTEGER REFERENCES proyectos(id) ON DELETE CASCADE,
CHECK (porcentaje_completado >= 0 AND porcentaje_completado <= 100)
);
-- Tags table
CREATE TABLE etiquetas (
id SERIAL PRIMARY KEY,
nombre TEXT UNIQUE NOT NULL,
color TEXT DEFAULT '#3B82F6'
);
-- Task-Tag junction table
CREATE TABLE tarea_etiquetas (
tarea_id INTEGER REFERENCES tareas(id) ON DELETE CASCADE,
etiqueta_id INTEGER REFERENCES etiquetas(id) ON DELETE CASCADE,
PRIMARY KEY (tarea_id, etiqueta_id)
);
-- Task-User junction table (assignments)
CREATE TABLE tarea_usuarios (
tarea_id INTEGER REFERENCES tareas(id) ON DELETE CASCADE,
usuario_id INTEGER REFERENCES usuarios(id) ON DELETE CASCADE,
PRIMARY KEY (tarea_id, usuario_id)
);
-- Deleted users (ban list)
CREATE TABLE usuarios_borrados (
id SERIAL PRIMARY KEY,
nombre_usuario TEXT,
correo TEXT,
fecha_eliminacion TIMESTAMPTZ DEFAULT NOW()
);
-- Enable Row Level Security
ALTER TABLE usuarios ENABLE ROW LEVEL SECURITY;
ALTER TABLE proyectos ENABLE ROW LEVEL SECURITY;
ALTER TABLE tareas ENABLE ROW LEVEL SECURITY;
ALTER TABLE etiquetas ENABLE ROW LEVEL SECURITY;
ALTER TABLE tarea_etiquetas ENABLE ROW LEVEL SECURITY;
ALTER TABLE tarea_usuarios ENABLE ROW LEVEL SECURITY;
-- RLS Policies (allow authenticated users to read/write)
CREATE POLICY "Allow authenticated users" ON usuarios
FOR ALL USING (auth.role() = 'authenticated');
CREATE POLICY "Allow authenticated users" ON proyectos
FOR ALL USING (auth.role() = 'authenticated');
CREATE POLICY "Allow authenticated users" ON tareas
FOR ALL USING (auth.role() = 'authenticated');
CREATE POLICY "Allow authenticated users" ON etiquetas
FOR ALL USING (auth.role() = 'authenticated');
CREATE POLICY "Allow authenticated users" ON tarea_etiquetas
FOR ALL USING (auth.role() = 'authenticated');
CREATE POLICY "Allow authenticated users" ON tarea_usuarios
FOR ALL USING (auth.role() = 'authenticated');
Make sure to enable Row Level Security (RLS) to protect your data. The policies above allow any authenticated user to access all data—adjust based on your security requirements.
tareastarea_etiquetastarea_usuariosproyectos
- Project URL (e.g.,
https://xxxxx.supabase.co) - anon/public key (starts with
eyJ...) - service_role key (starts with
eyJ...) - ⚠️ Keep this secret!
NEXT_PUBLIC_SUPABASE_URLhttps://xxxxx.supabase.coNEXT_PUBLIC_SUPABASE_ANON_KEYeyJ...SUPABASE_SERVICE_KEYeyJ...Never commit the
service_role key to your Git repository. This key has full database access and should only be used server-side.The Hive client reads credentials from global variables. You can set them in the browser console or create a
.env file:// Credentials are read from multiple sources
const supabaseUrl =
process.env?.NEXT_PUBLIC_SUPABASE_URL ||
window.SUPABASE_URL ||
'https://vcssfbdprqmpmuhwaapb.supabase.co'; // fallback for dev
const supabaseAnonKey =
process.env?.NEXT_PUBLIC_SUPABASE_ANON_KEY ||
window.SUPABASE_ANON_KEY ||
'eyJ...'; // fallback for dev
const supabaseServiceKey =
process.env?.SUPABASE_SERVICE_KEY ||
window.SUPABASE_SERVICE_KEY ||
'eyJ...'; // fallback for dev
// Initialize clients
const supabase = window.supabase.createClient(
supabaseUrl,
supabaseAnonKey
);
const supabaseAdmin = window.supabase.createClient(
supabaseUrl,
supabaseServiceKey
);
window.__supabaseClient = supabase;
window.__supabaseAdmin = supabaseAdmin;
For production, always use environment variables. The fallback values in the code are only for local development.
hive (or your choice)./ (current directory)INSERT INTO usuarios (
auth_user_id,
nombre_usuario,
correo,
nombre_completo,
puesto
) VALUES (
'YOUR_AUTH_USER_ID', -- Get this from Authentication → Users
'admin',
'admin@yourcompany.com',
'Admin User',
'Administrator'
);
hive.yourcompany.com)Alternative Deployment Options
Self-Hosted (Docker)
Hive can be self-hosted using Docker:Dockerfile
docker-compose.yml
Static Hosting (Netlify, Cloudflare Pages)
Hive’s frontend is entirely static and can be hosted anywhere:- Build the frontend:
npm run build(if you have a build script) - Upload the
frontend/directory to your static host - Configure environment variables in the hosting platform
Troubleshooting
Supabase Connection Issues
Problem: “Supabase CDN no cargado” error in console Solution: Make sure the Supabase CDN script is loaded inindex.html:
Authentication Fails
Problem: “Usuario o contraseña incorrectos” even with correct credentials Solution: Check these:- Verify the
usuariosrecord has the correctauth_user_id - Make sure the user is not in
usuarios_borrados(ban list) - Check RLS policies allow the user to read from
usuariostable
Realtime Not Working
Problem: Changes don’t appear in real-time Solution:- Verify replication is enabled in Supabase (Database → Replication)
- Check browser console for WebSocket errors
- Ensure
PMH_ENABLE_REALTIMEistruein app.js:
Tasks Not Saving
Problem: Tasks appear briefly then disappear Solution: Check RLS policies ontareas table. You may need to adjust:
Performance Optimization
Enable Caching
Configure Vercel edge caching for static assets:vercel.json
Database Indexes
Add indexes for common queries:Security Best Practices
- Never expose
service_rolekey - Only use it server-side in Vercel functions - Use RLS policies - Restrict data access based on user roles
- Validate input - Sanitize all user input on the client and server
- Enable HTTPS - Vercel provides this automatically
- Regular backups - Supabase has automatic backups, but test recovery
Next Steps
Your Hive instance is now running! Here’s what to do next:Quickstart Guide
Log in and create your first project
Authentication Setup
Configure user roles and permissions
Environment Config
Learn about all available environment variables
Supabase Configuration
Advanced Supabase setup and optimization
Getting Help
If you run into issues:- Check the GitHub Issues for known problems
- Review the Supabase documentation
- Check Vercel’s deployment guides
- Contact your Hive administrator
