Flowlist - A Full-Stack To-Do Application with Next.js
Welcome to Flowlist, a full-stack, lightweight, and simple to-do application built using Next.js with both backend and frontend integrated seamlessly.
This project shows the power of Next.js and serves as a practical demonstration of using Next.js as a complete full-stack framework, incorporating authentication, dark mode, and local storage for data persistence.
Table of Contents
- π Features
- π Live Deployment
- πΌοΈ UI Preview
- π File Structure
- π API Endpoints
- π Using the App
- π Swagger API Documentation
- π OpenAPI Specification
- π‘ Notes
- π§ͺ Testing
- π³ Containerization
- π§ Contributing
- π License
- π§ Contact
π Features
- Full-stack application with Next.js for both frontend and backend
- Full authentication system (Register and Login)
- Dark and Light mode
- User-specific to-do lists with different categories
- CRUD operations for to-do items
- MongoDB database for data storage
- WebSockets & Socket.io for real-time updates to To-Do items
- Responsive design
- Add, edit, delete, and complete tasks
- Persistent storage using SQLite and in-memory storage
- A clean, modern, and responsive UI
- PWA support with offline capabilities
- Basic testing for API endpoints and utility functions
- Easy-to-understand file structure and codebase
- Customizable with additional features and improvements
π Live Deployment
The application is deployed live on Vercel. You can access it at https://todo-app-nextjs-stack.vercel.app/.
The app features a landing page, authentication (login, register, and forgot password), a to-do list, and a Swagger API documentation page, as well as real-time to-do updates using WebSockets.
πΌοΈ UI Preview
Landing Page
Login Page
Register Page
Homepage (To-Do List)
Planner View
Insights View
Focus Mode
Profile Page
Forgot Password Page
π File Structure
Below is the comprehensive file structure for the project:
todo-app-fullstack-nextjs/
β
βββ public/
β βββ sitemap.xml
β βββ robots.txt
β βββ manifest.json
β βββ favicon.ico
β βββ images/
β
βββ src/
β βββ app/
β β βββ api/ # Backend API endpoints
β β β βββ swagger.ts # Swagger API documentation
β β β βββ auth/
β β β β βββ login/
β β β β β βββ route.ts # Login route
β β β β βββ register/
β β β β β βββ route.ts # Registration route
β β β β βββ reset-password/
β β β β β βββ route.ts # Reset password route
β β β β βββ verify-email/
β β β β βββ route.ts # Email verification route
β β β βββ todos/
β β β βββ route.ts # Full CRUD operations for todos
β β β
β β βββ auth/ # Authentication pages
β β β βββ reset-password/
β β β β βββ page.tsx # Reset password page
β β β βββ login/
β β β β βββ page.tsx # Login page
β β β βββ register/
β β β βββ page.tsx # Registration page
β β β
β β βββ landing/
β β β βββ page.tsx # Landing page
β β β
β β βββ swagger/
β β β βββ page.tsx # Swagger API documentation page
β β β
β β βββ layout.tsx # Layout for the entire app
β β βββ page.tsx # Homepage with conditional redirect logic
β β βββ page.css # Homepage styles
β β βββ page.module.css # Homepage module styles
β β βββ globals.css # Global CSS styles
β β
β βββ fonts/ # Custom fonts
β β
β βββ types/ # TypeScript types
β βββ swagger-ui-react.d.ts # Swagger UI types
β
βββ nginx/ # Nginx configuration
β βββ default.conf # Default Nginx configuration
β βββ nginx.conf # Nginx configuration
β
βββ kubernetes/ # Kubernetes configuration
β βββ frontend-deployment.yaml # Frontend deployment configuration
β βββ frontend-service.yaml # Frontend service configuration
β βββ backend-deployment.yaml # Backend deployment configuration
β βββ backend-service.yaml # Backend service configuration
β βββ configmap.yaml # ConfigMap for environment variables
β
βββ .env.local # Environment variables (if using)
βββ next.config.js # Next.js configuration
βββ Dockerfile # Docker configuration
βββ next.config.js # Next.js configuration
βββ package-lock.json # Locked versions of dependencies
βββ package.json # Project dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ Jenkinsfile # Jenkins CI/CD pipeline
βββ .gitignore # Files and directories to ignore
βββ .eslintrc.json # ESLint configuration
βββ manage_app.sh # Script to manage the app
βββ openapi.yaml # OpenAPI Specification
βββ LICENSE # Project license
βββ README.md # This README file
π API Endpoints
Here's a table listing all the API endpoints provided by this application:
| HTTP Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/login |
Log in with username and password |
POST |
/api/auth/register |
Register a new user |
GET |
/api/todos |
Fetch all todos for a user |
POST |
/api/todos |
Create a new to-do item |
PUT |
/api/todos |
Update a to-do item |
DELETE |
/api/todos |
Delete a to-do item |
PATCH |
/api/todos |
Mark a to-do item as completed |
POST |
/api/auth/reset-password |
Reset user password |
POST |
/api/auth/verify-email |
Verify user email |
π οΈ Getting Started
Follow this step-by-step guide to set up the project locally.
1. Prerequisites
Ensure you have the following installed:
2. Clone the Repository
git clone https://github.com/hoangsonww/ToDo-App-NextJS-Fullstack.git
cd ToDo-App-NextJS-Fullstack
3. Install Dependencies
If you're using npm:
npm install
Or, if you're using Yarn:
yarn install
4. Set Up Environment Variables
Create a .env.local file in the root directory if any environment variables are required. (Currently, the project doesn't use any external services that require environment variables).
5. Run the Development Server
Start the development server:
npm run dev
Or, if using Yarn:
yarn dev
The application should now be running at http://localhost:3000.
6. Build for Production
To build the project for production, run:
npm run build
Or, if using Yarn:
yarn build
To start the production server:
npm run start
Or:
yarn start
The production build will be served at http://localhost:3000.
π Using the App
- Visit the Landing Page (
/landing): Introduces the app with the option to log in or register. - Authentication:
- Register: Create a new account via the
/auth/registerpage. - Login: Access your account through the
/auth/loginpage.
- Manage To-Dos: Access the main to-do list page (
/) where you can add, edit, and delete to-dos, as well as toggle dark mode.
Alternatively, you can directly access the deployed application at https://todo-app-nextjs-stack.vercel.app/.
π Swagger API Documentation
The application includes a Swagger API documentation page that lists all the available API endpoints and their descriptions. You can access the Swagger documentation at /swagger.
Here is what it looks like:
π OpenAPI Specification
Using the openapi.yaml File
- View the API Documentation
- Open Swagger Editor.
- Upload the
openapi.yamlfile or paste its content. - Visualize and interact with the API documentation.
- Test the API
- Import
openapi.yamlinto Postman:- Open Postman β Import β Select
openapi.yaml. - Test the API endpoints directly from Postman.
- Open Postman β Import β Select
- Or use Swagger UI:
- Provide the file URL or upload it to view and test endpoints.
- Generate Client Libraries
- Install OpenAPI Generator:
npm install @openapitools/openapi-generator-cli -g - Generate a client library:
openapi-generator-cli generate -i openapi.yaml -g <language> -o ./client - Replace
<language>with the desired programming language.
- Generate Server Stubs
- Generate a server stub:
openapi-generator-cli generate -i openapi.yaml -g <framework> -o ./server - Replace
<framework>with the desired framework.
- Run a Mock Server
- Install Prism:
npm install -g @stoplight/prism-cli - Start the mock server:
prism mock openapi.yaml
- Validate the OpenAPI File
- Use Swagger Validator:
- Upload
openapi.yamlor paste its content to check for errors.
- Upload
This guide enables you to view, test, and utilize the API. You can also generate client libraries, server stubs, and run a mock server using the OpenAPI Specification.
π‘ Notes
- This application uses local storage to manage user data and to-do items. For a more robust application, consider integrating a real database (e.g., MongoDB, PostgreSQL).
- The dark mode toggle is handled with React state and applied to various components via Material-UI's
ThemeProvider.
π§ͺ Testing
Running Tests
This project includes a few basic tests for the API endpoints and utility functions. To run the tests, use the following command:
npm run test
Or, if using Yarn:
yarn test
The tests will run and display the results in the terminal.
π³ Containerization
This project includes a Dockerfile for containerization. To build the Docker image, run:
docker compose up --build
This command will build the Docker image and start the container. The application will be accessible at http://localhost:3000.
π§ Contributing
Contributions are welcome! If you'd like to contribute, please fork the repository, make your changes, and create a pull request.
π License
This project is licensed under the MIT License. See the LICENSE file for more information.
π§ Contact
For any inquiries or feedback, feel free to reach out to the author at [email protected].
Enjoy using the ToDo-App-Fullstack-NextJS! π
Happy coding! π