A powerful and feature-rich todo application built with Go and Next.js, featuring a clean architecture, RESTful API, and MongoDB for data persistence. The project includes both a backend API and a modern web client interface.
- CRUD Operations: Create, Read, Update, and Delete todos
- RESTful API: Well-structured API endpoints
- Persistent Storage: Data storage using MongoDB
- Clean Architecture: Follows clean code principles and best practices
- Input Validation: Request validation and error handling
- API Documentation: Comprehensive API documentation
- Environment Configuration: Easy setup with environment variables
- Modern Web UI: Responsive web interface built with Next.js
- Real-time Updates: Instant UI updates when todos change
- Server-Side Rendering: Enhanced performance and SEO with Next.js
- Tailwind CSS: Modern and responsive styling
- TypeScript: Type-safe development
Before running this application, make sure you have the following installed:
- Go (version 1.16 or higher)
- MongoDB
- Git
- Node.js (version 14 or higher)
- Yarn
-
Clone the repository:
git clone https://github.com/yourusername/advanced-todo-using-go.git cd advanced-todo-using-go
-
Install backend dependencies:
go mod download
-
Install frontend dependencies:
cd client yarn install cd ..
-
Set up environment variables:
cp .env.example .env # Edit .env file with your MongoDB connection string
-
Make sure MongoDB is running locally or you have a valid MongoDB connection string
-
Start the server:
go run main.go
-
The API server will start at
http://localhost:8080
-
Navigate to the client directory:
cd client
-
Start the development server:
yarn dev
-
The web interface will be available at
http://localhost:3000
GET /api/todos
- Get all todosGET /api/todos/:id
- Get a specific todoPOST /api/todos
- Create a new todoPUT /api/todos/:id
- Update a todoDELETE /api/todos/:id
- Delete a todo
{
"id": "objectId",
"title": "Task title",
"description": "Task description",
"completed": false,
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z"
}
curl -X POST http://localhost:8080/api/todos \
-H "Content-Type: application/json" \
-d '{
"title": "Complete project",
"description": "Finish the todo app implementation"
}'
.
├── client/ # Frontend Next.js application
│ ├── src/
│ │ ├── app/ # Next.js app directory
│ │ ├── components/ # React components
│ │ ├── lib/ # Utility functions
│ │ └── types/ # TypeScript type definitions
│ ├── public/ # Static files
│ ├── tailwind.config.ts
│ ├── package.json
│ └── README.md
├── config/ # Backend configuration
│ └── db.go
├── controllers/ # API controllers
│ └── todo.go
├── models/ # Data models
│ └── todo.go
├── routes/ # API routes
│ └── todo.go
├── main.go # Backend entry point
└── README.md
The application can be configured using environment variables:
PORT=8080
MONGO_URI=mongodb://localhost:27017/go_todos
- Modern UI with Tailwind: Clean and responsive design using Tailwind CSS
- Server-Side Rendering: Fast page loads and SEO optimization
- TypeScript Support: Type-safe development experience
- Real-time Updates: Instant feedback when creating, updating, or deleting todos
- Filter and Search: Easily find todos with search and filter options
- Sort Options: Sort todos by creation date, due date, or completion status
- Mobile Responsive: Works seamlessly on all device sizes