A modern, full-stack todo application built with Next.js, TypeScript, tRPC, and MongoDB. The application allows users to create, manage, and persist their todo items across sessions.
- Frontend: Next.js 15 with App Router
- Language: TypeScript
- API Layer: tRPC
- Database: MongoDB
- Styling: Tailwind CSS
- State Management: React Context
- Development: Docker
- Create and manage todo items
- Mark todos as complete/incomplete
- Persistent storage using MongoDB
- Modern, responsive UI
- Real-time updates
- Type-safe API with tRPC
- Node.js 18+
- MongoDB (local or Atlas)
- Docker (optional)
- Clone the repository:
git clone <repository-url>
cd todo-app- Install dependencies:
npm install- Set up environment variables:
Create a
.env.localfile in the root directory with the following variables:
MONGODB_URI=your_mongodb_connection_string- Start the development server:
npm run dev- Open http://localhost:3000 in your browser.
The application is fully containerized, supporting both development and production environments. Follow the instructions below to configure and use Docker.
Ensure the following tools are installed on your system:
- Docker
- Docker Compose
-
Create a
.env.localfile with your MongoDB connection string (if not already present):Note: You will only need this if you want to use (3) remote mongo instance, local is setting it up inside
package.jsonfile itselfMONGODB_URI=mongodb+srv://<username>:<password>@your-cluster.mongodb.net/<database>?retryWrites=true&w=majority
-
Start the Development Environment with local mongo:
npm run docker:up-local-mongo
-
Start the Development Environment with remote mongo:
npm run docker:up
-
Access the app locally: Open http://localhost:3000 in your browser.
The development environment supports live-reloading via nodemon or Next.js hot-reloading.
-
Build the Production Image:
docker build -t todo-app --target runner . -
Run the Production Container:
docker run -p 3000:3000 -e MONGODB_URI=mongodb+srv://<username>:<password>@your-cluster.mongodb.net/<database>?retryWrites=true&w=majority todo-app
-
Access the Production App: Open http://localhost:3000.
-
Create or update
docker-compose.remote.ymlto handle your remote MongoDB URL:version: "3.8" services: app: build: context: . target: runner ports: - "3000:3000" environment: NODE_ENV: production MONGODB_URI: your_mongodb_connection_string
-
Start the remote environment:
docker-compose -f docker-compose.remote.yml up --build
- For production, always manage sensitive credentials (like
MONGODB_URI) using environment secrets or a secure vault. - The
Dockerfileincludes support for:- Lightweight production builds using standalone mode.
- Fully-featured development builds supporting live-reloading.
/
├── app/ # Next.js app router pages
│ └── api/trpc/[trpc] # TRPC Route configs Next app router
├── components/ # Reusable UI components
├── features/ # Feature-based modules
│ └── todo/ # Todo feature implementation
│ ├── api/ # tRPC routers
│ └── components # Feature-specific components
├── lib/ # Utilities and types
├── server/ # Backend implementation
│ └── db/ # MongoDB connection and models
├── types/ # Shared TypeScript types
└── public/ # Static assets
- Follow TypeScript best practices
- Use feature-based folder structure
- Implement proper error handling
- Write clean, maintainable code
- Follow the established project structure
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License.