Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

44 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

✨ NotePrompt

AI Prompt Management Platform

A modern, full-stack AI prompt management platform with multi-model optimization, community prompt library, and professional-grade editing tools.

Live Demo Β· Documentation Β· Report Bug

Next.js TypeScript React Tailwind CSS MySQL Docker License


πŸ“– Overview

NotePrompt is an AI prompt management platform built with Next.js 15. It provides a workspace for creating, organizing, optimizing, and sharing AI prompts across multiple AI providers, with a dual-mode editor, community library, and administration tools.

🌐 Production endpoint: noteprompt.cn. A release is considered healthy only after the commit-SHA image, migration status, database/Redis readiness, and live TLS checks in DEPLOY.md pass.

Portfolio Highlights

  • Built as a complete SaaS-style product rather than a single-page demo: authentication, personal workspace, public library, admin dashboard, deployment scripts, and production reverse proxy are all included.
  • Designed around a real prompt-management workflow: users can draft, organize, optimize, publish, search, and reuse prompts across multiple model providers.
  • Shows full-stack engineering range: Next.js App Router, TypeScript, MySQL, Redis, JWT auth, Docker Compose, Nginx, email verification, and rate limiting.
  • Useful as a portfolio project because it demonstrates product thinking, backend API design, AI-provider integration, and deployable infrastructure in one repository.

🎯 Key Features

Prompt Management

  • Dual-Mode Editor β€” Switch between Standard and Professional editing modes with real-time preview
  • Folder Organization β€” Hierarchical folder system with drag-and-drop, custom descriptions, and nested structure
  • Version History β€” Automatic edit tracking with one-click rollback to any previous version
  • Global Search β€” Ctrl+K instant search across all prompts and folders
  • Tags & Categories β€” Organize prompts with 15 built-in categories and custom tagging

AI-Powered Optimization

  • 17+ AI Models β€” Integrated with DeepSeek (V3.2, R1), Kimi (K2.5, K2 Thinking), Qwen (3.5 Plus, 3 Max, Coder Plus), Zhipu GLM (5, 4.7, 4.6, 4.5)
  • Multi-Turn Optimization β€” Iterative prompt refinement through AI-guided conversations
  • Model Presets β€” Creative / Balanced / Precise temperature presets for different use cases
  • Auto-Fallback β€” Seamless failover between providers if one is unavailable
  • Bounded Attachment Parsing β€” Local PDF extraction and Chinese/English OCR in the production image, with a finite OCR work queue

Community & Sharing

  • Public Prompt Library β€” Browse, search, and collect community-shared prompts
  • 15 Curated Categories β€” Writing, Programming, Education, Marketing, Creative Design, Data Analysis, Life Assistant, Translation, Productivity, AI Art, Academic Research, Social Media, Role-Playing, Content Creation, and more
  • Favorites & Likes β€” Save and engage with the best community prompts
  • One-Click Publish β€” Share your prompts to the public library instantly

Platform Features

  • Dark Mode β€” Light / Dark / System-following theme with smooth transitions
  • Admin Dashboard β€” Full platform management: user management, content moderation, usage statistics, featured content curation
  • JWT Authentication β€” Secure registration/login with bcrypt password hashing (12 rounds)
  • Email Verification β€” Optional email verification with rate-limited, brute-force-protected verification codes
  • Rate Limiting β€” Redis-backed rate limiting on all sensitive endpoints
  • Responsive Design β€” Fully optimized for desktop, tablet, and mobile

πŸ›  Tech Stack

Layer Technology
Frontend Next.js 15, React 18, TypeScript, Tailwind CSS 3.4
UI Components shadcn/ui, Radix UI, Lucide Icons
Backend Next.js App Router API Routes (Node.js)
Database MySQL 8.0
Caching Redis 7
Authentication JWT + bcrypt
Email Nodemailer
AI Providers DeepSeek, Kimi (Moonshot), Qwen (DashScope), Zhipu GLM
Deployment Docker Compose + Nginx + SSL

πŸš€ Getting Started

Prerequisites

  • Node.js 24 LTS
  • MySQL >= 8.0
  • Redis >= 6 (optional only for local development; mandatory in production)
  • At least one AI provider API key

1. Clone the Repository

git clone https://github.com/computersciencefreshmen/NotePrompt.git
cd NotePrompt

2. Install Dependencies

npm ci

3. Configure Environment Variables

cp .env.example .env.local

Edit .env.local with your configuration:

# ── Long-running application database account (DML only) ──
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=note_prompt_app
MYSQL_PASSWORD=local_app_password
MYSQL_DATABASE=agent_report

# ── One-shot migration account (DML + reviewed schema DDL) ──
MYSQL_MIGRATION_USER=note_prompt_migrator
MYSQL_MIGRATION_PASSWORD=local_migration_password

# ── Authentication ──────────────────────────
JWT_SECRET=your_jwt_secret_at_least_32_chars
PROVIDER_KEY_ENCRYPTION_SECRET=an_independent_encryption_secret
VERIFICATION_CODE_SECRET=an_independent_verification_hmac_secret
NEXTAUTH_URL=http://localhost:3000
ENABLE_CONTRIBUTION_UPGRADES=false
PRO_AI_MONTHLY_LIMIT=100

# ── Redis (recommended locally, required in production) ──
# REDIS_URL=redis://localhost:6379/0
RATE_LIMIT_ALLOW_MEMORY_FALLBACK=true

# ── AI API Keys (configure at least one) ────
DEEPSEEK_API_KEY=sk-xxx
KIMI_API_KEY=sk-xxx
QWEN_API_KEY=sk-xxx
ZHIPU_API_KEY=xxx.xxx

# ── Email (optional) ────────────────────────
EMAIL_HOST=smtp.example.com
EMAIL_PORT=587
EMAIL_SECURE=false
EMAIL_USER=your_email@example.com
EMAIL_PASS=your_password_or_app_token
EMAIL_FROM=your_email@example.com
EMAIL_FROM_NAME=Note Prompt
ENABLE_EMAIL_VERIFICATION=false

The application and migration usernames must differ and neither may be root. The application account receives only SELECT, INSERT, UPDATE, and DELETE; see DEPLOY.md for production grants.

4. Apply Versioned Migrations

npm run db:plan
npm run db:status
npm run db:migrate
npm run db:status

database/migrations/*.cjs is the only schema source of truth. The server does not perform request-time DDL. Never replace production with a checked-in schema dump; back up first and apply the ordered, checksummed migrations using the dedicated account.

5. Start Development Server

npm run dev

Open http://localhost:3000 in your browser.


🐳 Docker Deployment

Production is not a one-command latest deployment. Follow DEPLOY.md for the required backup, full commit-SHA image build, one-shot migration, readiness, TLS validation, rollback, credential rotation, and cache cleanup workflow.

The Docker Compose stack includes:

  • note-prompt-migrate β€” one-shot schema migration using a dedicated DDL account
  • note-prompt-app β€” read-only Next.js runtime using a DML-only account
  • nginx β€” pinned reverse proxy with TLS termination and readiness dependency

MySQL and Redis are private external dependencies and are deliberately not exposed or bootstrapped by this Compose file.


πŸ“ Project Structure

NotePrompt/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                    # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ page.tsx            #   Landing page
β”‚   β”‚   β”œβ”€β”€ admin/              #   Admin dashboard
β”‚   β”‚   β”œβ”€β”€ api/v1/             #   RESTful API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/           #     Authentication (register, login, verify-email)
β”‚   β”‚   β”‚   β”œβ”€β”€ ai/             #     AI optimization endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ prompts/        #     User prompts CRUD
β”‚   β”‚   β”‚   β”œβ”€β”€ public-prompts/ #     Public prompt library
β”‚   β”‚   β”‚   β”œβ”€β”€ folders/        #     Folder management
β”‚   β”‚   β”‚   β”œβ”€β”€ favorites/      #     Favorites system
β”‚   β”‚   β”‚   β”œβ”€β”€ search/         #     Global search
β”‚   β”‚   β”‚   └── tags/           #     Tag management
β”‚   β”‚   β”œβ”€β”€ prompts/            #   Prompt workspace pages
β”‚   β”‚   β”œβ”€β”€ public-prompts/     #   Public library pages
β”‚   β”‚   β”œβ”€β”€ folders/            #   Folder view pages
β”‚   β”‚   └── settings/           #   User settings
β”‚   β”œβ”€β”€ components/             # Reusable React components
β”‚   β”‚   β”œβ”€β”€ ui/                 #   shadcn/ui base components
β”‚   β”‚   β”œβ”€β”€ AIOptimizeDialog.tsx #   AI optimization dialog
β”‚   β”‚   β”œβ”€β”€ Header.tsx          #   Navigation header
β”‚   β”‚   └── ...                 #   40+ components
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── ai.ts               # AI provider & model configuration
β”‚   β”œβ”€β”€ contexts/               # React Context providers
β”‚   β”‚   β”œβ”€β”€ AuthContext.tsx      #   JWT authentication state
β”‚   β”‚   └── ThemeContext.tsx     #   Theme management
β”‚   β”œβ”€β”€ hooks/                  # Custom React hooks
β”‚   β”œβ”€β”€ lib/                    # Utilities & services
β”‚   β”‚   β”œβ”€β”€ mysql-database.ts   #   Database access layer
β”‚   β”‚   β”œβ”€β”€ rate-limit.ts       #   Rate limiting
β”‚   β”‚   └── email-service.ts    #   Email service
β”‚   └── types/                  # TypeScript type definitions
β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ migrations/             # Ordered, checksummed CJS migrations
β”‚   β”œβ”€β”€ schema-requirements.json# Runtime schema contract
β”‚   └── README.md               # Migration lifecycle and recovery rules
β”œβ”€β”€ scripts/
β”‚   └── mysql-migrate.cjs       # plan / status / up migration CLI
β”œβ”€β”€ nginx/
β”‚   └── nginx.conf              # Nginx config (Cloudflare-ready)
β”œβ”€β”€ docker-compose.yml          # Docker Compose orchestration
β”œβ”€β”€ Dockerfile                  # Multi-stage production build
└── package.json

πŸ”Œ API Reference

All API endpoints are prefixed with /api/v1/.

Method Endpoint Description
POST /auth/register Register a new account
POST /auth/login Login and receive JWT token
POST /auth/verify-email Verify email with 6-digit code
GET /prompts List user's prompts
POST /prompts Create a new prompt
PUT /prompts/:id Update a prompt
DELETE /prompts/:id Delete a prompt
GET /public-prompts Browse public prompt library
POST /public-prompts Publish a prompt
GET /folders List user's folders
POST /folders Create a new folder
POST /ai/optimize AI-powered prompt optimization
GET /search Global search
GET /favorites List favorites
POST /favorites Add to favorites
GET /categories List all categories
GET /tags List all tags

πŸ€– Supported AI Models

Provider Models Highlights
DeepSeek V3.2 Chat, R1 (Reasoner) Top-tier reasoning capability
Kimi (Moonshot) K2.5, K2 Thinking, Moonshot V1 (32K/128K) 128K context window
Qwen (Alibaba) 3.5 Plus, 3 Max, Coder Plus, Long, 3.5 Flash Best Chinese language support
Zhipu GLM GLM-5, GLM-4.7, GLM-4.7-Flash, GLM-4.6, GLM-4.5 128K context, up to 131072 tokens

πŸ”’ Security

  • Password Hashing β€” bcrypt with 12 salt rounds (OWASP recommended)
  • JWT Authentication β€” Secure token-based auth with httpOnly cookies
  • Rate Limiting β€” Redis-backed rate limiting on auth and API endpoints
  • Input Validation β€” Server-side validation on all user inputs
  • CSRF Protection β€” SameSite cookie policy
  • Brute Force Protection β€” Lockout after 5 failed verification attempts
  • Timing-Safe Comparison β€” crypto.timingSafeEqual for verification codes

πŸ“Έ Screenshots

πŸ“Œ Screenshots coming soon β€” visit noteprompt.cn for the live experience.


πŸ“„ License

This project is licensed under the MIT License.


Built with ❀️ using Next.js, TypeScript, and Tailwind CSS

⬆ Back to Top