AI Dreams is a cutting-edge full-stack web application that transforms users' dreams into captivating experiences through advanced AI technology. Built with modern technologies including React 19, TypeScript, Vite 7, and Tailwind CSS 4, the platform combines dream journaling with AI-powered storytelling and image generation, creating an immersive community where users can share their nocturnal adventures and explore the dreams of others.
-
π§ Modern Tech Stack Upgrade
- Upgraded to React 19.1.1 with latest concurrent features
- Migrated to Vite 7.1.7 for faster development and optimized builds
- Updated to Tailwind CSS 4.1.13 with enhanced performance
- Implemented TypeScript 5.8+ across frontend and backend
-
ποΈ Architecture Enhancements
- Implemented feature-based frontend architecture for better maintainability
- Added comprehensive TypeScript interfaces and type safety
- Restructured components with Radix UI primitives for accessibility
- Enhanced API structure with proper error handling and validation
-
π Security & Performance
- Upgraded Express to 5.1.0 with enhanced security features
- Implemented comprehensive JWT authentication with refresh tokens
- Added rate limiting and advanced security middleware
- Optimized MongoDB queries and database indexing
-
π± User Experience
- Redesigned UI with modern Tailwind CSS 4 components
- Improved responsive design for all device sizes
- Enhanced loading states and error handling
- Added comprehensive form validation and user feedback
- π€ AI-Powered Storytelling: Transform raw dream descriptions into engaging, immersive narratives using OpenRouter.ai
- π¨ Dream Visualization: Generate stunning AI images with intelligent fallback system using Stable Diffusion
- π₯ Community Features: Share dreams publicly or keep them private with user attribution
- π Secure Authentication: JWT-based authentication with comprehensive user management
- π± Modern UI/UX: Fully responsive design built with React 19, TypeScript, and Tailwind CSS 4
- β‘ High Performance: Vite 7 build system with optimized bundle size and fast development
- π‘οΈ Production Security: Comprehensive security middleware, rate limiting, and environment-based configuration
- ποΈ Clean Architecture: Feature-based frontend structure with separation of concerns
- π§ͺ Developer Experience: Full TypeScript support, ESLint configuration, and comprehensive API documentation
ai-dreams/
βββ π¨ Frontend (React 19 + TypeScript + Vite 7)
β βββ src/
β β βββ features/ # Feature-based architecture
β β β βββ auth/ # Authentication module
β β β β βββ components/ # LoginForm, SignUpForm, ProtectedRoute
β β β β βββ contexts/ # AuthContext for state management
β β β β βββ hooks/ # useAuth custom hook
β β β β βββ types/ # Auth-related TypeScript types
β β β βββ dreams/ # Dream management module
β β β βββ components/ # DreamCard, DreamForm, PublicDreamFeed, StoryDisplay
β β β βββ services/ # Dream API integration
β β β βββ types/ # Dream-related TypeScript types
β β βββ shared/ # Shared components & utilities
β β β βββ components/ # Reusable UI components
β β β β βββ layout/ # Header, Footer, Navigation
β β β β βββ ui/ # Button, Alert, Input components
β β β βββ utils/ # Utility functions & validation
β β βββ services/ # API communication layer
β β β βββ api/ # Centralized API client
β β βββ pages/ # Route components
β β β βββ auth/ # Login, Signup pages
β β β βββ dreams/ # Dream-related pages
β β β βββ Home.tsx # Landing page
β β β βββ ApiKeySettings.tsx # API key management (disabled)
β β βββ App.tsx # Main application component with routing
β β βββ main.tsx # Application entry point
β β βββ index.css # Global styles with Tailwind imports
β βββ public/ # Static assets
β βββ dist/ # Production build output
β βββ package.json # Frontend dependencies
β βββ vite.config.ts # Vite configuration with path aliases
β βββ tailwind.config.js # Tailwind CSS 4 configuration
β βββ tsconfig.json # TypeScript configuration
β βββ eslint.config.js # ESLint configuration
β
βββ π§ Backend (Node.js + Express 5 + TypeScript)
β βββ src/
β β βββ controllers/ # Request handlers
β β β βββ authController.ts # User authentication logic
β β β βββ dreamController.ts # Dream CRUD operations
β β β βββ aiController.ts # AI generation endpoints
β β βββ models/ # MongoDB schemas with Mongoose
β β β βββ User.ts # User model with bcrypt hashing
β β β βββ Dream.ts # Dream model with relationships
β β β βββ ApiKey.ts # API key management model
β β βββ routes/ # API route definitions
β β β βββ v1/ # Versioned API routes
β β β β βββ auth.ts # Authentication routes
β β β β βββ dreams.ts # Dream management routes
β β β β βββ ai.ts # AI generation routes
β β β β βββ apiKeys.ts # API key routes
β β β β βββ index.ts # Route aggregation
β β β βββ analytics.ts # Analytics and metrics
β β βββ middleware/ # Express middleware
β β β βββ auth.ts # JWT authentication & authorization
β β β βββ errorHandler.ts # Global error handling
β β β βββ rateLimiter.ts # Rate limiting protection
β β βββ services/ # Business logic layer
β β β βββ aiService.ts # OpenRouter & Stable Diffusion integration
β β βββ utils/ # Utility functions
β β β βββ jwt.ts # JWT token operations
β β βββ config/ # Configuration modules
β β βββ database.ts # MongoDB connection setup
β β βββ apiDocs.ts # API documentation config
β βββ tests.postman/ # Postman API testing suite
β β βββ AI_Dreams_API.postman_collection.json
β β βββ AI_Dreams_Environment.postman_environment.json
β β βββ POSTMAN_TESTING_GUIDE.md
β βββ dist/ # Compiled JavaScript output
β βββ index.ts # Server entry point with middleware setup
β βββ package.json # Backend dependencies
β βββ tsconfig.json # TypeScript configuration
β
βββ π§ Configuration & Deployment
βββ .env # Environment variables (local development)
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
βββ .vercelignore # Vercel deployment ignore
βββ components.json # Radix UI components configuration
βββ README.md # Project documentation
- Secure JWT-based authentication system
- User registration and login with email/password
- Protected routes and session management
- User profile management
- Create and store personal dream entries
- Rich text descriptions with title and content
- Public/private visibility controls
- Edit and delete dream entries
- Personal dream collection dashboard
- Story Generation: Transform dreams into immersive narratives using OpenRouter.ai
- Image Generation: Create visual representations using Stable Diffusion
- Complete Dream Processing: Generate both story and image in one request
- Community API Keys: Shared pool of API keys for sustainable AI usage
- Public dream feed with pagination
- Explore other users' shared dreams
- Search and filter community content
- User attribution and dream statistics
- Platform usage statistics
- User engagement metrics
- Dream creation trends
- API key usage monitoring
- Rate limiting to prevent abuse
- Input validation and sanitization
- Error handling with proper HTTP codes
- CORS protection and security headers
- Optimized database queries with indexing
- Fully responsive design (mobile, tablet, desktop)
- Modern UI with Tailwind CSS and Radix UI
- Loading states and error handling
- Intuitive navigation and user flows
- Accessibility-compliant components
- Node.js 18+ and npm
- MongoDB Atlas account (or local MongoDB)
- Git
git clone https://github.com/anzirish/AI-Dream-Visualizzer.git
cd ai-dreams# Navigate to server directory
cd server
# Install dependencies
npm install
# Create environment file
cp .env.example .env
# Update .env with your configuration:
# MONGODB_URI=your_mongodb_connection_string
# JWT_SECRET=your_secure_jwt_secret
# CLIENT_URL=http://localhost:5173
# Start development server
npm run dev# Navigate to root directory (from server/)
cd ..
# Install dependencies
npm install
# Create environment file
cp .env.example .env
# Update .env with backend URL:
# VITE_API_BASE_URL=http://localhost:5000/api/v1
# Start development server
npm run dev- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- API Documentation: http://localhost:5000/api
npm run dev # Start Vite development server (http://localhost:5173)
npm run build # Build for production (TypeScript compilation + Vite build)
npm run preview # Preview production build locally
npm run lint # Run ESLint with TypeScript supportnpm run dev # Start development server with nodemon and ts-node
npm run build # Compile TypeScript to JavaScript (dist/ folder)
npm start # Start production server from compiled JavaScript
npm test # Run Jest test suite
npm run render-build # Build script for Render deploymentBoth frontend and backend are production-ready and can be immediately.
# Install Vercel CLI
npm i -g vercel
# Deploy frontend
vercel --prod
# Set environment variable in Vercel dashboard:
# VITE_API_BASE_URL=https://your-backend-domain.com/api/v1# Build the application
cd server
npm run build
# Deploy to your preferred platform
# Set environment variables:
# NODE_ENV=production
# MONGODB_URI=your_production_mongodb_uri
# JWT_SECRET=your_production_jwt_secret
# CLIENT_URL=https://your-frontend-domain.comVITE_API_BASE_URL=http://localhost:5000/api/v1 # Development
# VITE_API_BASE_URL=https://your-api-domain.com/api/v1 # Production# Server Configuration
PORT=5000
NODE_ENV=development
# Database
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/aidreams
# JWT Configuration
JWT_SECRET=your-super-secure-jwt-secret-here
JWT_EXPIRE=7d
# Client Configuration
CLIENT_URL=http://localhost:5173
# AI API Keys (Optional - for fallback)
OPENROUTER_API_KEY=your_openrouter_api_key
STABLE_DIFFUSION_API_KEY=your_stable_diffusion_api_keyPOST /api/v1/auth/signup- User registration with email/passwordPOST /api/v1/auth/login- User authentication and JWT token generationGET /api/v1/auth/me- Get current authenticated user profilePOST /api/v1/auth/logout- User logout and token invalidation
POST /api/v1/dreams- Create new dream entry (authenticated)GET /api/v1/dreams/my- Get user's personal dreams with paginationGET /api/v1/dreams/public- Get public dreams feed with user attributionGET /api/v1/dreams/:id- Get specific dream by IDPUT /api/v1/dreams/:id- Update existing dream (owner only)DELETE /api/v1/dreams/:id- Delete dream (owner only)
POST /api/v1/ai/generate-story- Generate AI story from dream descriptionPOST /api/v1/ai/generate-image- Generate AI image from dream contentPOST /api/v1/ai/generate-complete- Generate both story and image in one request
POST /api/v1/api-keys- Add community API key for shared usageGET /api/v1/api-keys/my- Get user's contributed API keysGET /api/v1/api-keys/stats- Get API key usage statistics
GET /api/analytics/overview- Platform usage statisticsGET /api/analytics/user/stats- Individual user statisticsGET /api/analytics/trends- Platform growth and usage trends
The project includes a comprehensive Postman testing suite located in server/tests.postman/:
- Collection:
AI_Dreams_API.postman_collection.json- Complete API endpoint tests - Environment:
AI_Dreams_Environment.postman_environment.json- Environment variables - Documentation:
POSTMAN_TESTING_GUIDE.md- Testing instructions and workflows
- Automated Workflows - Sequential test execution with dependency management
- Environment Variables - Dynamic token management and base URL configuration
- Response Validation - Comprehensive assertion testing for all endpoints
- Error Scenarios - Testing for edge cases and error conditions
- Authentication Flow - Complete user registration, login, and protected route testing
- React 19.1.1 - Latest React with concurrent features and improved performance
- TypeScript 5.8.3 - Full type safety across the application
- Vite 7.1.7 - Ultra-fast build tool and development server
- Tailwind CSS 4.1.13 - Modern utility-first CSS framework with latest features
- Radix UI - Accessible, unstyled component primitives
- React Router DOM 7.9.3 - Declarative client-side routing
- Lucide React - Beautiful, customizable SVG icons
- Class Variance Authority - Type-safe component variants
- clsx & tailwind-merge - Conditional CSS class utilities
- Node.js 18+ - JavaScript runtime with ES modules support
- Express.js 5.1.0 - Fast, minimalist web framework
- TypeScript 5.9.3 - Type-safe server development
- MongoDB 8.19.2 - NoSQL document database
- Mongoose 8.19.2 - Elegant MongoDB object modeling
- JWT (jsonwebtoken 9.0.2) - Secure authentication tokens
- bcryptjs 3.0.2 - Password hashing and salting
- Helmet 8.1.0 - Security middleware for Express
- Morgan 1.10.1 - HTTP request logging
- Express Rate Limit 8.1.0 - Rate limiting middleware
- CORS 2.8.5 - Cross-origin resource sharing
- Nodemon 3.1.10 - Auto-restart development server
- ts-node 10.9.2 - TypeScript execution for Node.js
- ESLint 9.36.0 - Code linting and formatting
- PostCSS 8.4.0 - CSS processing and optimization
- Autoprefixer 10.4.0 - Automatic CSS vendor prefixing
- OpenRouter.ai - Access to multiple LLM models for story generation
- Stability AI - Stable Diffusion for AI image generation
- MongoDB Atlas - Cloud-hosted database service
- Vercel - Frontend deployment and hosting
- Render/Railway - Backend API deployment
- Environment-based Configuration - Secure API key management
- JWT Authentication with secure token handling
- Password Hashing using bcrypt with salt rounds
- Rate Limiting to prevent abuse
- Input Validation and sanitization
- CORS Protection with proper origin configuration
- Security Headers via Helmet middleware
- Environment Variables for sensitive configuration
- Complete TypeScript Implementation - Full type safety with comprehensive JSDoc documentation
- Advanced Security - Helmet middleware, CORS protection, rate limiting, and JWT authentication
- Error Handling - Centralized error handling with custom ApiError classes and proper HTTP status codes
- Database Optimization - MongoDB indexes, connection pooling, and optimized queries
- API Testing Suite - Complete Postman collection with environment configurations
- Production Build - TypeScript compilation with source maps and optimized output
- Environment Configuration - Secure environment-based API key management
- Logging & Monitoring - Morgan HTTP logging and comprehensive request tracking
- Modern React 19 - Latest React features with concurrent rendering and improved performance
- TypeScript Excellence - Full type coverage with strict TypeScript configuration
- Optimized Build - Vite 7 with tree-shaking, code splitting, and minimal bundle size
- Responsive Design - Mobile-first design with Tailwind CSS 4 and modern CSS features
- Accessibility - WCAG-compliant components using Radix UI primitives
- Performance - Lazy loading, optimized images, and efficient state management
- Developer Experience - Hot module replacement, fast refresh, and comprehensive linting
- API Testing - Complete Postman test suite with automated workflows
- Code Quality - ESLint with TypeScript rules and consistent code formatting
- Type Safety - Strict TypeScript configuration preventing runtime errors
- Security Testing - Comprehensive security middleware and input validation
- 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
- TypeScript First - Use strict TypeScript configuration and comprehensive type definitions
- Component Architecture - Follow feature-based architecture with clear separation of concerns
- Code Documentation - Write comprehensive JSDoc comments for all functions and interfaces
- Testing Strategy - Add Postman tests for API endpoints and component tests for UI
- Code Quality - Use ESLint rules and maintain consistent code formatting
- Security Practices - Follow secure coding practices and validate all inputs
- Performance - Optimize bundle size and implement efficient state management
- Accessibility - Ensure WCAG compliance using Radix UI and semantic HTML
This project is licensed under the MIT License.
- Project: AI Dreams Visualizer - Transform Your Dreams into Stories
- Version: 2.0.0 (2025 Modern Stack Update)
- Frontend: React 19 + TypeScript + Vite 7 + Tailwind CSS 4
- Backend: Node.js + Express 5 + TypeScript + MongoDB
- Status: β Production Ready with Modern Architecture
π Star this repository if you found it helpful!