This is a full-stack to-do list application built using Next.js, TypeScript, Tailwind CSS, Zustand for state management, Prisma for database management, and NextAuth for authentication. The project is structured following the Feature-Sliced Design (FSD) pattern for better scalability and maintainability.
This to-do list app allows users to register, log in, and manage their tasks. Each task can be marked as completed, and users can delete tasks as needed. The application features authentication and protected routes, ensuring that each user can only access their own tasks.
Before you begin, ensure you have the following installed on your local machine:
Clone the repository:
Open your terminal and run the following command to clone the repository:
git clone https://github.com/efqz11/todo-app.git
Change to the project directory:
cd todo-app
Install dependencies:
Install the required npm packages by running:
npm install
Set up environment variables:
Set up environment variables: Create a .env file in the root of the project and add the following environment variables:
DATABASE_URL="mysql://user:password@localhost:3306/todo_db"
NEXTAUTH_SECRET="your_secret"
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key"
JWT_SECRET="your_jwt_secret_here"
Replace user
and password
with your MySQL credentials, and todo_db
with the database name of your choice.
Run database migrations:
Set up the database schema using Prisma by running:
npx prisma migrate dev
This will apply the migrations and set up your database tables.
Run the development server:
After setting up the database, run the application locally:
npm run dev
Open the application:
Navigate to http://localhost:3000 in your browser. You should now be able to see the application running.
Running MySQL with Docker: If you don't have MySQL installed locally, you can use Docker to set it up quickly:
docker run --name mysql-container -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=todo_db -p 3306:3306 -d mysql:latest
Ensure that your .env
file points to this database with the correct credentials.
This project follows the Feature-Sliced Design (FSD) pattern. FSD organizes the application into clear feature boundaries, making the app modular and scalable. The main ideas behind FSD are:
pages
, features
, shared
, and entities
. Each layer has a specific responsibility.pages/
: This folder contains the top-level routing pages of the application.features/
: Contains feature-specific components, logic, and services. For example, auth
, todos
, etc.shared/
: Contains reusable components and utilities that are shared across multiple features.entities/
: Contains the core domain logic, including Prisma models and business rules.```bash ├── features/ # Feature-specific folders │ ├── auth/ # Authentication logic (login, registration) │ └── todos/ # To-do functionality (add, update, delete todos) │ └── quotes/ # External API integration to get random quote ├── shared/ # Reusable components, utilities, and hooks │ ├── components/ # Shared UI components (Button, Modal, etc.) │ └── utils/ # Utility functions (date formatting, etc.) ├── entities/ # Domain models and business logic (Prisma models, services) ├── pages/ # Next.js routing pages │ ├── index.tsx # Home page │ ├── auth/ # Auth routes (login, register) │ └── api/ # API routes for todos, auth └── prisma/ # Prisma schema and migrations