A full-stack dynamic website where competitive programming users can upload, store, view, edit, and react to solutions. Features public and private solutions, anonymous posts, LaTeX editorial editor, animated lively GUI, search with intelligent sorting, autosave drafts, social reactions, and admin controls.
- Responsive Animated UI - Lively interface inspired by summer.hackclub.com
- Public & Private Solutions - Toggle between public and private views
- Intelligent Search & Sorting - Search by problem code, title, author with smart sorting
- LaTeX Editor - Rich text editor with integrated LaTeX support
- Autosave System - Client and server-side draft persistence
- Social Reactions - Like, helpful, and bookmark reactions
- Anonymous Posting - Post solutions anonymously
- Admin Controls - Comprehensive admin dashboard and moderation tools
- Authentication - Email/password and Google OAuth support
- Frontend: Next.js 14, React 18, TypeScript, Tailwind CSS, Framer Motion
- Backend: Next.js API Routes, Prisma ORM
- Database: PostgreSQL
- Authentication: JWT tokens, bcrypt password hashing
- Editor: TipTap with LaTeX support
- Deployment: Docker, Docker Compose
- Node.js 18+
- Docker and Docker Compose
- PostgreSQL (or use Docker)
git clone <repository-url>
cd cp-solutions-uploader
cp env.example .env.localEdit .env.local with your configuration:
# Database
DATABASE_URL="postgresql://postgres:password@localhost:5432/cp_solutions"
# NextAuth.js
NEXTAUTH_SECRET="your-secret-key-change-in-production"
NEXTAUTH_URL="http://localhost:3000"
# JWT
JWT_SECRET="your-jwt-secret-change-in-production"
# Optional: Google OAuth
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"# Start all services
docker-compose up -d
# The application will be available at:
# - App: http://localhost:3000
# - Database: localhost:5432
# - pgAdmin: http://localhost:8080 (admin@example.com / admin)# Install dependencies
npm install
# Setup database
npx prisma generate
npx prisma db push
# Seed database with admin user
npm run db:seed
# Start development server
npm run devIMPORTANT: These are development credentials. Before deploying to production:
- Change the admin password immediately
- Use environment variables for all secrets
- Enable HTTPS
- Set up proper rate limiting
- Use a secure JWT secret
To change admin credentials:
# Option 1: Update seed script and re-run
npm run db:seed
# Option 2: Use Prisma Studio
npx prisma studio- users - User accounts and authentication
- solutions - Problem solutions with content and metadata
- reactions - User reactions (like, helpful, bookmark)
- drafts - Autosave drafts for solutions
- attachments - File attachments for solutions
- Solutions belong to users (with optional anonymous posting)
- Reactions link users to solutions
- Drafts are user-specific and can be solution-specific
The system intelligently parses problem codes like:
148Aβ number: 148, suffix: "A"1000Bβ number: 1000, suffix: "B"CF-148Aβ prefix: "CF", number: 148, suffix: "A"
- Prefix (lexicographical) - "CF" comes before "AtCoder"
- Number (numerical) - 148 comes before 1000
- Suffix (lexicographical) - "A" comes before "B"
Example sorted order: 148A, 148B, 1000A, CF-148A
- Client-side: Saves to localStorage every 5 seconds
- Server-side: Saves to database every 30 seconds or on significant changes
- Recovery: Merges localStorage and server drafts on page load
- Drafts are stored per user and optionally per solution
- Content is merged intelligently (server takes precedence)
- Users can restore drafts or continue editing
- Drafts are automatically cleaned up after solution publication
- Framer Motion for smooth transitions
- Hover effects on cards and buttons
- Loading states with spinners
- Micro-interactions throughout the interface
Inspired by summer.hackclub.com:
- Primary: Blue gradient (#0ea5e9 to #3b82f6)
- Secondary: Purple gradient (#d946ef to #8b5cf6)
- Accent: Orange gradient (#f97316 to #ef4444)
- Mobile-first approach
- Collapsible navigation
- Adaptive layouts for all screen sizes
# Development
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
# Database
npm run db:generate # Generate Prisma client
npm run db:push # Push schema to database
npm run db:migrate # Run migrations
npm run db:studio # Open Prisma Studio
npm run db:seed # Seed database
# Docker
npm run docker:up # Start all services
npm run docker:down # Stop all services
npm run docker:build # Build containers
# Testing
npm run test # Run unit tests
npm run test:watch # Run tests in watch mode
npm run test:e2e # Run end-to-end testsβββ app/ # Next.js app directory
β βββ api/ # API routes
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ page.tsx # Home page
βββ components/ # React components
βββ hooks/ # Custom React hooks
βββ lib/ # Utility libraries
βββ prisma/ # Database schema and migrations
βββ types/ # TypeScript type definitions
βββ utils/ # Helper functions
# Build and deploy
docker-compose -f docker-compose.prod.yml up -d
# Environment variables for production
export DATABASE_URL="postgresql://user:pass@host:5432/db"
export NEXTAUTH_SECRET="your-production-secret"
export JWT_SECRET="your-production-jwt-secret"- Connect your repository to Vercel
- Set environment variables in Vercel dashboard
- Deploy automatically on push to main branch
# Create backup
pg_dump $DATABASE_URL > backup.sql
# Restore backup
psql $DATABASE_URL < backup.sql
# Automated backup (cron job)
0 2 * * * pg_dump $DATABASE_URL > /backups/backup-$(date +%Y%m%d).sql- Change default admin credentials
- Use strong, unique secrets for JWT and NextAuth
- Enable HTTPS everywhere
- Set up rate limiting
- Configure CORS properly
- Sanitize all user inputs
- Set up monitoring and logging
- Regular security updates
- Database backup strategy
The application includes rate limiting:
- 100 requests per 15 minutes per IP
- Stricter limits for authentication endpoints
- Configurable via environment variables
- XSS prevention on all user inputs
- SQL injection protection via Prisma
- File upload validation
- Content type verification
npm run test # Run all tests
npm run test:watch # Watch mode
npm run test -- --coverage # With coveragenpm run test:e2e # Run Playwright tests
npm run test:e2e:ui # Open Playwright UI- API endpoint testing
- Component unit tests
- Authentication flow tests
- Search and sorting tests
- Autosave functionality tests
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License.
For issues and questions:
- Check the documentation
- Search existing issues
- Create a new issue with detailed information
- When you type: Content saves to browser storage every 5 seconds
- When you pause: Content saves to server every 30 seconds
- When you return: Browser checks for saved content and asks if you want to restore it
- When you publish: Draft is automatically deleted
- Install PostgreSQL (or use Docker)
- Run migrations:
npm run db:migrate - Seed data:
npm run db:seed - Connect: Set
DATABASE_URLin your environment
- Daily backups: Automatically save database every day
- Manual backups: Run
pg_dumpwhen needed - Restore: Use
psqlto restore from backup files
- Set environment variables for database and secrets
- Use Docker Compose for easy deployment
- Enable HTTPS for security
- Set up monitoring to watch for issues
- Regular backups to prevent data loss
Remember: Always change the default admin password before going live!
Made by TomDevX with love β€οΈ
Β©2025 CP Solutions Uploader