A modern full-stack AI-enabled template using Next.js for frontend and Express.js for backend, with Telegram and OpenAI integrations! ✨
This template is specially crafted for the Cursor IDE, offering:
- 🤖 AI-assisted development with inline code explanations
- 🔍 Smart environment variable setup assistance
- 💡 Intelligent error resolution
- 📝 Context-aware code completion
- 🛠️ Built-in debugging helpers
Just highlight any error message, code snippet, or variable in Cursor and ask the AI for help!
Cmd/Ctrl + K
: Ask AI about highlighted codeCmd/Ctrl + L
: Get code explanationsCmd/Ctrl + I
: Generate code completions- Highlight any error message to get instant fixes
- Prerequisites:
node >= 22 🟢
pnpm >= 9.14.1 📦
- Install dependencies:
pnpm install
- Fire up the dev servers:
pnpm run dev
.
├── 📦 client/ # Next.js frontend
│ ├── 📱 app/ # Next.js app router (pages, layouts)
│ ├── 🧩 components/ # React components
│ │ └── HelloWorld.tsx # Example component with API integration
│ ├── 💅 styles/ # Global styles and Tailwind config
│ │ ├── globals.css # Global CSS and Tailwind imports
│ │ └── tailwind.config.ts # Tailwind configuration
│ ├── 🛠️ bin/ # Client scripts
│ │ └── validate-env # Environment variables validator
│ ├── next.config.js # Next.js configuration (API rewrites)
│ ├── .env.example # Example environment variables for client
│ └── tsconfig.json # TypeScript configuration
│
├── ⚙️ server/ # Express.js backend
│ ├── 📂 src/ # Server source code
│ │ ├── 🛣️ routes/ # API route handlers
│ │ │ └── hello.ts # Example route with middleware
│ │ └── index.ts # Server entry point (Express setup)
│ ├── 🛠️ bin/ # Server scripts
│ │ ├── validate-env # Environment validator
│ │ └── www-dev # Development server launcher
│ └── tsconfig.json # TypeScript configuration
│
├── 📜 scripts/ # Project scripts
│ └── dev # Concurrent dev servers launcher
│
├── 📝 .env.example # Root environment variables example for server
├── 🔧 package.json # Root package with workspace config
└── 📦 pnpm-workspace.yaml # PNPM workspace configuration
💡 Pro Tip: In Cursor IDE, highlight any environment variable name and ask the AI for setup instructions!
NEXT_PUBLIC_API_URL
: Backend API URL (default: http://localhost:3001) 🌐NEXT_PUBLIC_TELEGRAM_BOT_NAME
: Telegram bot name without the @ symbol, you can get it from BotFather after creating your bot (default: your_bot_username) 🤖
-
PORT
: Server port (default: 3001) 🚪 -
NODE_ENV
: Environment (development/production) 🌍 -
TELEGRAM_BOT_TOKEN
: 🤖- Open Telegram and search for @BotFather
- Start chat and send
/newbot
- Follow prompts to name your bot
- Copy the provided token
-
OPENAI_API_KEY
: 🧠- Visit https://platform.openai.com/api-keys
- Click "Create new secret key"
- Give it a name and copy the key immediately
- Set usage limits in API settings if needed
-
NGROK_AUTH_TOKEN
: 🔗- Create account at https://dashboard.ngrok.com/signup
- Go to https://dashboard.ngrok.com/get-started/your-authtoken
- Copy your authtoken
-
NGROK_DOMAIN
: 🔗- Go to https://dashboard.ngrok.com/domains
- Copy your domain (without https://)
-
COLLABLAND_API_KEY
: 🤝- Visit https://dev-portal-qa.collab.land/signin
- Click on "Get Started"
- Select Telegram login
- Login with Telegram
- Verify your e-mail with the OTP sent to your inbox
- Click on "Request API Access" on the top right corner, and set up the API key name
- Copy your API key
-
GAIANET_MODEL
: 🤖- Visit https://docs.gaianet.ai/user-guide/nodes
- Choose your model (default: llama)
- Copy the model name
-
GAIANET_SERVER_URL
: 🌐- Visit https://docs.gaianet.ai/user-guide/nodes
- Get server URL for your chosen model
- Default: https://llama8b.gaia.domains/v1
-
GAIANET_EMBEDDING_MODEL
: 🧬- Visit https://docs.gaianet.ai/user-guide/nodes
- Choose embedding model (default: nomic-embed)
- Copy the model name
-
USE_GAIANET_EMBEDDING
: ⚙️- Set to TRUE to enable Gaianet embeddings
- Set to FALSE to disable (default: TRUE)
-
JOKERACE_CONTRACT_ADDRESS
: 🎰- Go to https://www.jokerace.io/contest/new
- Create the contest
- Copy the contract address
🔒 Note: Keep these tokens secure! Never commit them to version control. The template's
.gitignore
has your back!
- Build both apps:
pnpm run build
- Launch production servers:
pnpm start
- For production deployment: 🌎
- Set
NODE_ENV=production
- Use proper SSL certificates 🔒
- Configure CORS settings in server/src/index.ts 🛡️
- Set up error handling and logging 📝
- Use process manager like PM2 ⚡
- Client:
const ENV_HINTS = {
NEXT_PUBLIC_API_URL: "Your API URL (usually http://localhost:3001)",
// Add more hints as needed! ✨
};
- Server:
const ENV_HINTS = {
PORT: "API port (usually 3001)",
NODE_ENV: "development or production",
TELEGRAM_BOT_TOKEN: "Get from @BotFather",
OPENAI_API_KEY: "Get from OpenAI dashboard",
NGROK_AUTH_TOKEN: "Get from ngrok dashboard",
// Add more hints as needed! ✨
};
- Add TypeScript types in respective env.d.ts files 📝
- Create new route file in server/src/routes/
- Import and use in server/src/index.ts
- Add corresponding client API call in client/components/
- Create component in client/components/
- Use Tailwind CSS for styling ✨
- Follow existing patterns for API integration
- Create middleware in server/src/middleware/
- Apply globally or per-route basis
- Next.js App Router: https://nextjs.org/docs/app 🎯
- Express.js: https://expressjs.com/ ⚡
- Tailwind CSS: https://tailwindcss.com/docs 💅
- TypeScript: https://www.typescriptlang.org/docs/ 📘