Skip to main content

Self-hosting Contafy

This guide will help you set up Contafy on your own infrastructure. Contafy is a Next.js application that can be deployed to any platform supporting Node.js.
Contafy requires a backend API to function. Ensure you have access to the Contafy API endpoint before proceeding with the frontend installation.

Prerequisites

Before you begin, ensure you have the following installed:
  • Node.js: Version 20 or higher (Download Node.js)
  • pnpm: Version 8 or higher (required package manager)

Installing pnpm

If you don’t have pnpm installed, install it globally:

Installation steps

1

Clone the repository

Clone the Contafy repository to your local machine:
2

Install dependencies

Install all required dependencies using pnpm:
This will install all dependencies defined in package.json, including:
  • Next.js 16 with React 19
  • Tailwind CSS 4
  • Shadcn/ui and Radix UI components
  • TanStack Query for data fetching
  • Recharts for visualizations
  • And more…
3

Configure environment variables

Create a .env.local file in the root directory of the project:
.env.local

Environment variables explained

The NEXT_PUBLIC_API_URL must point to a running instance of the Contafy backend API. The frontend cannot function without a properly configured backend.
4

Run the development server

Start the Next.js development server:
The application will be available at http://localhost:3000You should see the Contafy landing page. Navigate to /auth/register to create your first account.
The development server includes hot module replacement (HMR), so changes to your code will be reflected immediately without restarting the server.

Building for production

When you’re ready to deploy Contafy to production:

Build the application

This command:
  1. Compiles TypeScript code
  2. Optimizes and bundles all assets
  3. Generates static pages where possible
  4. Creates an optimized production build in the .next directory

Start the production server

The production server will start on port 3000 by default.
For production deployments, ensure all environment variables are properly configured for your production environment.

Available scripts

Contafy includes several npm scripts for development and maintenance:

Deployment options

Contafy can be deployed to various platforms: The easiest deployment option for Next.js applications:
  1. Connect your GitHub repository to Vercel
  2. Configure environment variables in the Vercel dashboard
  3. Vercel will automatically detect Next.js and deploy your application
Vercel provides automatic SSL, global CDN, and seamless integration with Next.js features.

Other platforms

Contafy can also be deployed to:
  • Netlify: Supports Next.js with serverless functions
  • Railway: Simple deployment with automatic HTTPS
  • DigitalOcean: Deploy to droplets or App Platform
  • AWS Amplify: Full AWS integration
  • Docker: Containerize with Next.js standalone output

Docker deployment

For containerized deployments:

Project structure

Understanding the Contafy codebase:

Troubleshooting

Port already in use

If port 3000 is already in use, specify a different port:

API connection errors

If you see API connection errors:
  1. Verify NEXT_PUBLIC_API_URL is correctly set in .env.local
  2. Ensure the backend API is running and accessible
  3. Check for CORS configuration on the backend
  4. Verify network connectivity between frontend and backend

Build errors

If the build fails:
  1. Run type checking: pnpm typecheck
  2. Clear the Next.js cache: rm -rf .next
  3. Delete node_modules and reinstall: rm -rf node_modules && pnpm install
  4. Check for TypeScript errors in your IDE

Next steps

Now that Contafy is installed:
  • Follow the quickstart guide to set up your first account and profile
  • Review the project structure to understand the codebase organization
  • Configure additional features like Firebase (if needed)
  • Set up a production deployment on your preferred platform
Remember to keep your environment variables secure and never commit .env.local to version control.