|
| 1 | +# Next.js + Drizzle ORM + MySQL + Protect.js Example |
| 2 | + |
| 3 | +This example demonstrates how to build a modern web application using: |
| 4 | +- [Next.js](https://nextjs.org/) - React framework for production |
| 5 | +- [Drizzle ORM](https://orm.drizzle.team/) - TypeScript ORM for SQL databases |
| 6 | +- [MySQL](https://www.mysql.com/) - Popular open-source relational database |
| 7 | +- [Protect.js](https://cipherstash.com/protect) - Data protection and encryption library |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- Full-stack TypeScript application |
| 12 | +- Database migrations and schema management with Drizzle |
| 13 | +- Data protection and encryption with Protect.js |
| 14 | +- Modern UI with Tailwind CSS |
| 15 | +- Form handling with React Hook Form and Zod validation |
| 16 | +- Docker-based MySQL database setup |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +- Node.js 18+ |
| 21 | +- Docker and Docker Compose |
| 22 | +- MySQL (if running locally without Docker) |
| 23 | + |
| 24 | +## Getting Started |
| 25 | + |
| 26 | +1. Clone the repository and install dependencies: |
| 27 | + ```bash |
| 28 | + npm install |
| 29 | + ``` |
| 30 | + |
| 31 | +2. Set up your environment variables: |
| 32 | + Copy the `.env.example` file to `.env.local`: |
| 33 | + ```bash |
| 34 | + cp .env.example .env.local |
| 35 | + ``` |
| 36 | + Then update the environment variables in `.env.local` with your Protect.js configuration values. |
| 37 | + |
| 38 | +3. Start the MySQL database using Docker: |
| 39 | + ```bash |
| 40 | + docker-compose up -d |
| 41 | + ``` |
| 42 | + |
| 43 | +4. Run database migrations: |
| 44 | + ```bash |
| 45 | + npm run db:generate |
| 46 | + npm run db:migrate |
| 47 | + ``` |
| 48 | + |
| 49 | +5. Start the development server: |
| 50 | + ```bash |
| 51 | + npm run dev |
| 52 | + ``` |
| 53 | + |
| 54 | +The application will be available at `http://localhost:3000`. |
| 55 | + |
| 56 | +## Project Structure |
| 57 | + |
| 58 | +- `/src` - Application source code |
| 59 | +- `/drizzle` - Database migrations and schema |
| 60 | +- `/public` - Static assets |
| 61 | +- `drizzle.config.ts` - Drizzle ORM configuration |
| 62 | +- `docker-compose.yml` - Docker configuration for MySQL |
| 63 | + |
| 64 | +## Available Scripts |
| 65 | + |
| 66 | +- `npm run dev` - Start development server |
| 67 | +- `npm run build` - Build for production |
| 68 | +- `npm run start` - Start production server |
| 69 | +- `npm run db:generate` - Generate database migrations |
| 70 | +- `npm run db:migrate` - Run database migrations |
| 71 | + |
| 72 | +## Learn More |
| 73 | + |
| 74 | +- [Next.js Documentation](https://nextjs.org/docs) |
| 75 | +- [Drizzle ORM Documentation](https://orm.drizzle.team/docs/overview) |
| 76 | +- [Protect.js Documentation](https://cipherstash.com/protect/docs) |
| 77 | +- [MySQL Documentation](https://dev.mysql.com/doc/) |
0 commit comments