A modern Next.js application for digital product delivery through order ID claiming. Customers can claim virtual products using order IDs, while administrators manage products and orders through a comprehensive dashboard.
- Simple Claiming Process: Enter order ID to claim digital products
- Instant Download Links: Automatic generation of secure download links
- Multi-Product Support: Handle multiple products per order
- Expiration Management: Time-limited access to prevent abuse
- One-Time Use Control: Configurable claim restrictions
- Product Management: Create, edit, and delete digital products
- Order Management: Generate orders with product assignments
- Flexible Configuration: Set expiration dates and usage limits
- Secure Authentication: JWT-based admin access
- Real-Time Status: Track claim counts and order status
- Frontend: Next.js 15.4.6, React 18, TypeScript
- Styling: Tailwind CSS with responsive design
- Backend: Next.js API Routes
- Database: SQLite with structured schema
- Authentication: JWT tokens with bcrypt hashing
- Icons: Lucide React
-
Clone the repository
git clone https://github.com/your-username/self-claim-link.git cd self-claim-link -
Install dependencies
npm install --legacy-peer-deps
-
Start development server
npm run dev
-
Access the application
- Customer interface:
http://localhost:3000 - Admin dashboard:
http://localhost:3000/admin
- Customer interface:
Create a .env.local file in the root directory. Do not commit this file to version control.
# Required: A strong, unique secret for JWT token signing.
# In production, GENERATE A RANDOM, LONG, AND COMPLEX KEY (e.g., using `openssl rand -base64 32`).
# Example (Development): JWT_SECRET=super-dev-secret
JWT_SECRET=your-super-secret-jwt-key-here
# Set to 'production' for production deployments.
NODE_ENV=development - Development Only: A default admin account (
username: admin,password: password) is automatically created ONLY whenNODE_ENVis NOTproduction. This is for convenience during development. - Production Warning: In a production environment, this default admin account is NOT created. You MUST manually create the first administrator account with strong, unique credentials. Refer to "Deployment" for production setup.
- NEVER use default credentials in production!
To ensure robust schema management and facilitate easier updates, it is highly recommended to integrate a database migration tool. This helps in versioning your database schema and applying changes in a controlled manner across different environments.
Recommended Tools:
- Knex.js: A popular SQL query builder that includes migration capabilities.
- Prisma Migrate: A declarative, type-safe database migration system.
Getting Started:
- Install your chosen migration tool (e.g.,
npm install knexornpm install prisma --save-devandnpm install @prisma/cli --save-dev). - Configure the tool to connect to your
database.sqlitefile. - Create initial migration files to define your current schema (
products,orders,order_products,settings,admins). - Run migrations using the tool's command-line interface to set up the database schema.
This practice will significantly improve maintainability and reduce potential conflicts during development and deployment.
The application uses SQLite with the following tables:
products: Digital products with download linksorders: Order tracking with claim status and expirationorder_products: Many-to-many relationship between orders and productsadmins: Admin user authenticationsettings: System configuration
POST /api/claim- Claim products with order ID
POST /api/auth/login- Admin loginGET /api/admin/me- Get admin infoGET|POST|PUT|DELETE /api/products- Product managementGET|POST|PUT|DELETE /api/orders- Order managementGET|PUT /api/settings- System settings
- Visit the main page
- Enter your order ID in the input field
- Click "Claim Products"
- Download your products using the provided links
- Navigate to
/admin/login - Login with admin credentials
- Use the dashboard to:
- Create and manage digital products
- Generate orders with product assignments
- Configure system settings
- Monitor claim activity
self-claim-link/
βββ app/
β βββ admin/
β β βββ login/
β β βββ page.tsx # Admin dashboard
β βββ api/
β β βββ admin/
β β βββ auth/
β β βββ claim/
β β βββ orders/
β β βββ products/
β β βββ settings/
β βββ globals.css
β βββ layout.tsx
β βββ page.tsx # Customer interface
βββ lib/
β βββ database.ts # Database configuration
β βββ types.ts # TypeScript interfaces
βββ package.json
βββ README.md
npm run build
npm start- Set
NODE_ENV=production - Configure secure
JWT_SECRET - Set up proper database backup strategy
- Configure reverse proxy (nginx/Apache)
- Enable HTTPS in production
- Change default admin credentials
- Use strong JWT secrets
- Implement rate limiting for production
- Regular database backups
- HTTPS enforcement
- Input validation and sanitization (all API routes)
- Explicit CORS configuration for production environments (if client and server are on different domains)
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLint
- Create API routes in
app/api/ - Update database schema in
lib/database.ts - Add TypeScript interfaces in
lib/types.ts - Implement UI components in respective pages
We welcome contributions! Please see our CONTRIBUTING.md for details on how to get started.
See the CHANGELOG.md for a history of changes.
- Built with Next.js
- Styled with Tailwind CSS
- Icons by Lucide
self-claim-link/
βββ .github/
β βββ ISSUE_TEMPLATE/
β β βββ bug_report.md
β β βββ feature_request.md
β βββ PULL_REQUEST_TEMPLATE.md
β βββ workflows/
β βββ ci.yml
βββ app/
β βββ admin/
β β βββ login/
β β βββ page.tsx # Admin dashboard
β βββ api/
β β βββ admin/
β β βββ auth/
β β βββ claim/
β β βββ orders/
β β βββ products/
β β βββ settings/
β βββ globals.css
β βββ layout.tsx
β βββ page.tsx # Customer interface
βββ lib/
β βββ database.ts # Database configuration
β βββ types.ts # TypeScript interfaces
βββ .dockerignore
βββ Dockerfile
βββ docker-compose.yml
βββ .env.example
βββ CONTRIBUTING.md
βββ CHANGELOG.md
βββ LICENSE
βββ package.json
βββ README.md