A modern, AI-powered document editor similar to Genspark Ai Docs, built with Next.js 14, MongoDB, and OpenAI integration.
- AI-Powered Document Generation: Create documents using natural language prompts
- Dual Editor Mode: Toggle between Rich Text and Markdown editors seamlessly
- Smart Templates: Pre-built templates for common document types
- Real-time Sync: Content stays synchronized between both editor modes
- Full-featured toolbar with formatting options
- Support for headings, lists, blockquotes, and code blocks
- Image and link insertion
- Text alignment and color options
- Undo/redo functionality
- Live preview with syntax highlighting
- Markdown toolbar for quick formatting
- GitHub Flavored Markdown support
- Responsive design for all screen sizes
- Project Proposal: Comprehensive business proposal template
- Technical Report: Structured technical documentation
- Blog Post: Engaging content creation template
- Resume: Professional career template
- Export Options: PDF, Word (.docx), and HTML formats
- Content Import: Paste existing content for AI-powered reformatting
- Smart Formatting: AI automatically improves document structure and readability
- Iron Session: Secure cookie-based authentication
- User Isolation: Each user's documents are private
- MongoDB: Robust data storage with Mongoose ODM
- Frontend: Next.js 14 (App Router), TypeScript, TailwindCSS
- UI Components: shadcn/ui, Radix UI primitives
- Database: MongoDB with Mongoose
- Authentication: Iron Session with secure cookies
- AI Integration: OpenAI GPT-4o-mini API
- Rich Text Editor: Tiptap with comprehensive extensions
- Markdown: React-Markdown with syntax highlighting
- Export: jsPDF, html-to-docx, custom HTML export
- Node.js 18+
- MongoDB instance (local or cloud)
- OpenAI API key
git clone <repository-url>
cd ai-docsnpm installCreate a .env.local file in the root directory:
# Database
MONGODB_URI=mongodb://localhost:27017/ai-docs
# Iron Session
NEXT_PUBLIC_COOKIE_NAME=your-cookie
NEXT_PUBLIC_COOKIE_PASSWORD=your-secure-password-here
# OpenAI
OPENAI_API_KEY=your-openai-api-key- Generate a secure password for cookie encryption
- Set the
NEXT_PUBLIC_COOKIE_PASSWORDenvironment variable - Customize cookie name if needed via
NEXT_PUBLIC_COOKIE_NAME
- Visit OpenAI Platform
- Create an account and get your API key
- Add the key to your
.env.localfile
- Start MongoDB instance
- The app will automatically create collections on first run
- (Optional) Seed default templates:
node scripts/seed-templates.js
npm run devVisit http://localhost:3000 to see your Ai Docs application!
ai-docs/
โโโ app/ # Next.js App Router
โ โโโ api/ # API routes
โ โ โโโ documents/ # Document CRUD operations
โ โ โโโ generate/ # AI document generation
โ โ โโโ templates/ # Template management
โ โโโ auth/ # Authentication pages
โ โโโ editor/ # Document editor
โ โโโ globals.css # Global styles
โ โโโ layout.tsx # Root layout
โ โโโ page.tsx # Dashboard
โโโ components/ # React components
โ โโโ editor/ # Editor components
โ โโโ providers/ # Context providers
โ โโโ ui/ # Reusable UI components
โโโ hooks/ # Custom React hooks
โโโ lib/ # Utility libraries
โโโ models/ # MongoDB schemas
โโโ scripts/ # Database seeding scripts
โโโ public/ # Static assets
The app uses the custom primary color #6737ec. To change it:
- Update
tailwind.config.js:
primary: {
DEFAULT: "#your-color-here",
// ...
}- Update
app/globals.css:
--primary: 262 83% 58%; /* Update HSL values */- Create template in
scripts/seed-templates.js - Run the seeding script
- Templates will be available in the editor
- AI Prompt: Describe what you want to create
- Template: Choose from pre-built templates
- Manual: Start with a blank document
- Rich Text Mode: Use the toolbar for formatting
- Markdown Mode: Write in markdown with live preview
- Auto-save: Changes are automatically saved
- Export: Download in PDF, Word, or HTML formats
- Smart Formatting: AI automatically improves document structure
- Content Generation: Generate content from prompts
- Style Consistency: Maintains professional formatting
- Connect your GitHub repository
- Add environment variables
- Deploy automatically
- Build the application:
npm run build - Start production server:
npm start - Configure environment variables
- Set up MongoDB connection
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
- Issues: Create GitHub issues for bugs or feature requests
- Documentation: Check the code comments and this README
- Community: Join our discussions for help and ideas
- Real-time collaboration
- Advanced AI features (summarization, translation)
- Mobile app
- Plugin system
- Advanced export options
- Document versioning
- Team workspaces
Built with โค๏ธ using Next.js, MongoDB, and OpenAI