Prerequisites
Before you begin, ensure you have the following installed:Node.js 20+
Contafy requires Node.js version 20 or higher. Check your version:- Download: nodejs.org
- Version manager: Use nvm or fnm
pnpm 8+
Contafy uses pnpm as its package manager. Install pnpm:Clone the repository
Clone the Contafy repository to your local machine:Install dependencies
Install all project dependencies with pnpm:- Install all packages from
package.json - Create a
node_modules/directory - Generate a
pnpm-lock.yamllock file - Set up Git hooks (if configured)
Environment variables
Create a.env.local file in the project root:
.env.local with your configuration:
Environment variable reference
| Variable | Description | Required | Default |
|---|---|---|---|
NEXT_PUBLIC_API_URL | Backend API base URL | Yes | http://localhost:3001 |
NEXT_PUBLIC_FRONTEND_URL | Frontend base URL | Yes | http://localhost:3000 |
ADMIN_DISCOUNT_ROUTE | Admin panel route path | No | internal/discount-management |
NEXT_PUBLIC_ are exposed to the browser.
Backend API setup
Contafy requires a backend API to function. Ensure your backend is running:- Clone the backend repository (separate repo)
- Install backend dependencies
- Configure backend environment variables
- Start the backend server on port 3001
Run the development server
Start the Next.js development server:Alternative: Webpack mode
If you encounter issues with the default Turbopack bundler:Verify the setup
Check the landing page
Navigate to http://localhost:3000 You should see the Contafy landing page.Test authentication
- Navigate to http://localhost:3000/auth/login
- You should see the login form
- Try registering a new account at http://localhost:3000/auth/register
Check API connectivity
Open the browser console (F12) and check for any API errors. If everything is working:- No CORS errors
- API requests to
/backend/*are successful - Authentication flow works
Available scripts
Contafy includes several npm scripts for development:Development
Production build
Code quality
Development workflow
Typical development workflow:- Start the backend API (separate terminal)
- Start the frontend dev server:
pnpm dev - Make your changes to the code
- Hot reload automatically updates the browser
- Check for errors in terminal and browser console
- Run type checking:
pnpm typecheck - Run linting:
pnpm lint - Commit your changes
IDE setup
VS Code (recommended)
Recommended extensions:- ESLint:
dbaeumer.vscode-eslint - Prettier:
esbenp.prettier-vscode - Tailwind CSS IntelliSense:
bradlc.vscode-tailwindcss - TypeScript Error Translator:
mattpocock.ts-error-translator
.vscode/settings.json):
Other IDEs
Contafy works with any IDE that supports TypeScript and ESLint:- WebStorm: Built-in TypeScript and ESLint support
- Sublime Text: Install LSP-typescript and LSP-eslint
- Vim/Neovim: Use coc.nvim or native LSP
Troubleshooting
Port already in use
If port 3000 is already in use:Module not found errors
If you see module not found errors:TypeScript errors
If TypeScript shows errors:API connection issues
If API requests fail:- Verify backend is running:
curl http://localhost:3001/health - Check
NEXT_PUBLIC_API_URLin.env.local - Check browser console for CORS errors
- Verify Next.js proxy configuration in
next.config.ts
Hot reload not working
If changes don’t reflect in the browser:- Check terminal for compilation errors
- Refresh the browser manually
- Restart the dev server:
Ctrl+Cthenpnpm dev - Clear Next.js cache:
rm -rf .next
Next steps
Now that your environment is set up:- Read Conventions to understand code standards
- Explore Project Structure to navigate the codebase
- Learn Data Fetching patterns
- Review Architecture for system design
Getting help
If you encounter issues:- Check the troubleshooting section above
- Search existing GitHub issues
- Ask in the team Slack channel
- Create a new GitHub issue with:
- Error message
- Steps to reproduce
- Your environment (OS, Node version, pnpm version)