A Next.js full-stack application for the Locked-In Challenge, featuring user authentication, daily submissions, admin panel, and CSV export.
- Authentication: Passwordless login using signed JWT cookies
- Daily Submissions: Users can submit one entry per day with timezone handling (Africa/Lagos)
- Admin Panel: Admins can view all submissions and export data
- CSV Export: Export submissions to CSV format
- Responsive UI: Mobile-first design with TailwindCSS
- Type Safety: Full TypeScript implementation
- Database: PostgreSQL with Prisma ORM
- Frontend: Next.js 14 (App Router), React, TypeScript, TailwindCSS
- Backend: Next.js API Routes, Prisma ORM
- Database: PostgreSQL
- Authentication: JWT cookies
- Validation: Zod
- Testing: Jest
- Node.js 18+
- PostgreSQL database
-
Clone the repository:
git clone <repository-url> cd locked-in-challenge
-
Install dependencies:
npm install
-
Set up environment variables:
cp .env.example .env.local
Edit
.env.localwith your database URL and JWT secret. -
Set up the database:
npm run db:migrate npm run db:seed
-
Run the development server:
npm run dev
-
Open http://localhost:3000 in your browser.
- Login: Enter your email to log in (no password required).
- Submit Entry: On the dashboard, submit your daily locked-in activity.
- View Submissions: See your previous submissions.
- Log in with an admin email (e.g., admin@example.com).
- Access
/adminto view all submissions. - Export data to CSV.
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpm run test- Run testsnpm run db:generate- Generate Prisma clientnpm run db:migrate- Run database migrationsnpm run db:seed- Seed database with demo datanpm run export:csv- Export submissions to CSV
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ ├── admin/ # Admin page
│ └── page.tsx # Home page
├── components/ # Reusable components
├── lib/ # Utility libraries
├── prisma/ # Database schema
├── scripts/ # Seed and export scripts
├── tests/ # Unit tests
└── README.md
- JWT tokens are signed and stored in HTTP-only cookies
- Rate limiting implemented for API endpoints
- Input validation with Zod
- Admin access controls
- Timezone-specific date logic to prevent exploits
Run tests with:
npm run test-
Build the application:
npm run build
-
Start the production server:
npm run start
Ensure your production environment has the required environment variables set.
This project is licensed under the MIT License.