A comprehensive Next.js application for managing, sharing, and organizing AI prompts with advanced caching capabilities.
- Prompt Management: Create, edit, organize, and share AI prompts
- Tag System: Categorize prompts with a flexible tagging system
- User Authentication: Secure user registration and login with NextAuth
- Dashboard Analytics: Real-time insights into prompt usage and performance
- Shared Prompts Marketplace: Discover and share prompts with the community
- Search & Filtering: Advanced search capabilities across prompts and tags
- Semantic Search: AI-powered search using embeddings for finding similar prompts
- Embedding Management: Background worker for generating and updating embeddings
- Redis Caching: Comprehensive caching strategy for optimal performance
- Session Management: Cached user sessions and preferences
- Analytics Caching: Real-time dashboard data with intelligent cache invalidation
- Rate Limiting: Redis-based API rate limiting for security
- Frontend: Next.js 15, React, TypeScript, Tailwind CSS
- Backend: Next.js API Routes, Prisma ORM
- Database: PostgreSQL
- Caching: Redis 7 with ioredis client
- Authentication: NextAuth.js
- Deployment: Docker Compose for development
- Node.js 18+
- Docker and Docker Compose
- Git
-
Clone the repository
git clone <repository-url> cd Promptforge
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env.local
Update the environment variables in
.env.local:# Database DATABASE_URL="postgresql://user:password@localhost:5432/prompt-manager" # NextAuth NEXTAUTH_SECRET="your-secret-key" NEXTAUTH_URL="http://localhost:3000" # Redis REDIS_HOST=localhost REDIS_PORT=6379 REDIS_PASSWORD=redispassword
-
Start the services
# Start PostgreSQL and Redis docker-compose up -d # Run database migrations npx prisma migrate dev # Generate Prisma client npx prisma generate
-
Start the development server
npm run dev
This command automatically starts both:
- The Next.js development server
- The embedding worker (required for semantic search)
Note: If you want to run only the Next.js server without the worker:
npm run dev:next-only
-
Open the application Navigate to http://localhost:3000
- Tag management and search
- Dashboard analytics and statistics
- Shared prompts with filtering and pagination
- User sessions and preferences
- Popular content and trending data
// TTL (Time To Live) settings
const cacheTTL = {
prompt: 5 * 60, // 5 minutes
tags: 10 * 60, // 10 minutes
dashboardAnalytics: 5 * 60, // 5 minutes
sharedPrompts: 10 * 60, // 10 minutes
session: 24 * 60 * 60, // 24 hours
};src/
├── app/
│ ├── actions/ # Server actions
│ │ ├── tag.actions.cached.ts # Cached tag operations
│ │ ├── analytics.actions.cached.ts # Cached analytics
│ │ └── shared-prompts.actions.cached.ts # Cached shared prompts
│ ├── api/ # API routes
│ ├── dashboard/ # Dashboard pages
│ ├── prompts/ # Prompt management pages
│ └── shared-prompts/ # Shared prompts marketplace
├── lib/
│ ├── redis.ts # Redis configuration and cache service
│ ├── session-cache.ts # Session caching utilities
│ ├── cache-invalidation.ts # Cache invalidation strategies
│ └── prisma.ts # Database configuration
└── components/ # Reusable UI components
# Development
npm run dev # Start dev server + embedding worker
npm run dev:next-only # Start only Next.js dev server
npm run worker # Start embedding worker separately
npm run build # Build for production
npm run start # Start production server
# Database
npx prisma migrate dev # Run database migrations
npx prisma generate # Generate Prisma client
npx prisma studio # Open Prisma Studio
# Docker
docker-compose up -d # Start services (PostgreSQL + Redis)
docker-compose down # Stop services
docker-compose logs # View service logs
# Redis Management
npm run redis:up # Start Redis container
npm run redis:down # Stop Redis container
npm run redis:logs # View Redis logsPOST /api/auth/register- User registrationPOST /api/auth/[...nextauth]- NextAuth endpoints
GET /api/prompts- List user promptsPOST /api/prompts- Create new promptPUT /api/prompts/[id]- Update promptDELETE /api/prompts/[id]- Delete prompt
GET /api/tags- List all tags (cached)POST /api/tags- Create new tagPUT /api/tags/[id]- Update tag
GET /api/analytics/dashboard- Dashboard analytics (cached)GET /api/analytics/global- Global statistics (cached)
- User: User accounts and profiles
- Prompt: AI prompts with content and metadata
- Tag: Categorization tags
- PromptToTag: Many-to-many relationship
- SharedPrompt: Public prompt sharing
- Users can have multiple prompts
- Prompts can have multiple tags
- Prompts can be shared publicly
- Analytics track user interactions
cache:{domain}:{identifier}:{optional_params}
Examples:
- cache:prompt:123
- cache:tags:all
- cache:analytics:dashboard:user456
- cache:shared-prompts:popular
- cache:session:sess_abc123
- Prompt Operations: Clear prompt, tags, and analytics caches
- Tag Operations: Clear tag-related caches
- User Actions: Clear user-specific caches
- Sharing Actions: Clear shared prompts caches
- Connection pooling and lazy connections
- Pipeline operations for batch requests
- Automatic retry with exponential backoff
- Health monitoring and error handling
- Server-side rendering with Next.js
- Optimized database queries with Prisma
- Efficient cache-aside patterns
- Strategic cache warming
// Redis health check
await CacheService.getInstance().healthCheck();
// Database health check
await prisma.$queryRaw`SELECT 1`;- Monitor hit/miss ratios
- Track memory usage
- Performance metrics
- Error rates
main- Production-ready coderedis- Redis caching implementationfeature/*- Feature development branches
# Run tests
npm test
# Type checking
npm run type-check
# Linting
npm run lint# Build production image
docker build -t promptforge .
# Run with docker-compose
docker-compose -f docker-compose.prod.yml up -dNODE_ENV=production
DATABASE_URL="postgresql://..."
REDIS_URL="redis://..."
NEXTAUTH_SECRET="secure-secret"
NEXTAUTH_URL="https://your-domain.com"If you see Redis timeout errors in the logs:
- Ensure Redis is running:
docker-compose ps - Check Redis connection:
npm run redis:logs - Make sure the embedding worker is running:
npm run worker
- Check Admin > AI Settings > Embedding tab
- Verify OpenAI API key is configured
- Look for "Worker Status" alerts
- If jobs are waiting, start the worker:
npm run worker
- Check Redis is accessible
- Verify API keys in Admin settings
- Check logs for specific errors
- Try restarting:
npm run worker
The embedding worker is automatically started with npm run dev:
- Development:
npm run devstarts both app and worker - Production: Run worker as a separate process
- Monitor: Check Admin > AI Settings > Embedding Management
For detailed worker documentation, see docs/EMBEDDING_WORKER.md
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
-
Dashboard and Page Layouts
- Problem: Content was hidden behind the 260px fixed sidebar
- Solution: Added
ml-[260px]margin to content wrappers in all layout files - Files Fixed: dashboard/layout.tsx, prompts/layout.tsx, admin/layout.tsx, search/layout.tsx, templates/layout.tsx, favorites/layout.tsx, shared-prompts/layout.tsx, tags/layout.tsx, profile/layout.tsx
-
My Prompts Page Scrolling
- Problem: Content was cut off at the bottom without scroll capability in ResizablePanels
- Solution: Changed
overflow-hiddentooverflow-autoin ResizablePanels component - File Fixed: src/components/ui/resizable-panels.tsx
-
CSS Import Order
- Problem: @import rule for Google Fonts was after other CSS rules
- Solution: Moved Google Fonts to HTML head tags in layout.tsx
- File Fixed: src/app/layout.tsx, src/app/globals.css
-
Design System Migration
- Applied Hyper template design system with:
- Primary color: #727cf5 (indigo)
- Nunito font family
- Professional shadows and spacing
- Consistent card heights and layouts
- Applied Hyper template design system with:
- Used Playwright MCP to test each fix
- Verified fixes with screenshots
- Checked for text overflow, cut-off content, and proper scrolling
- Ensured all pages are accessible and properly laid out
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the GitHub repository
- Review the API documentation
- Next.js team for the excellent framework
- Prisma for the powerful ORM
- Redis for high-performance caching
- The open-source community for inspiration and tools