A robust and scalable task management API built with Go and MongoDB, designed to power the Task Manager mobile application.
-
Task Management
- Create, read, update, and delete tasks
- Structured task data with title, description, and status
- Automatic timestamp management (created_at, updated_at)
- MongoDB-based persistence for reliable data storage
-
API Endpoints
POST /tasks- Create a new taskGET /tasks- List all tasksGET /tasks/:id- Get a specific taskPUT /tasks/:id- Update a taskDELETE /tasks/:id- Delete a task
-
Technical Stack
- Go 1.23.4
- MongoDB (via go.mongodb.org/mongo-driver)
- Encore.dev for API development and deployment
- Go 1.23.4 or higher
- MongoDB instance
- Encore.dev CLI (optional, for deployment)
- Clone the repository
- Set up your MongoDB connection string in the environment:
export MONGODB_URI="your_mongodb_connection_string"
-
Install dependencies:
go mod download
-
Run the API locally:
go run .
The API will start on port 4000 by default.
type Task struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
Title string `bson:"title" json:"title"`
Description string `bson:"description" json:"description"`
Status string `bson:"status" json:"status"`
CreatedAt time.Time `bson:"created_at" json:"created_at"`
UpdatedAt time.Time `bson:"updated_at" json:"updated_at"`
}POST /tasks
Content-Type: application/json
{
"title": "Task Title",
"description": "Task Description",
"status": "pending"
}GET /tasksGET /tasks/:idPUT /tasks/:id
Content-Type: application/json
{
"title": "Updated Title",
"description": "Updated Description",
"status": "in_progress"
}DELETE /tasks/:idThe API implements comprehensive error handling with appropriate HTTP status codes:
- 400: Invalid input
- 404: Resource not found
- 500: Internal server error
Run the test suite:
go test ./...encore.dev v1.46.1go.mongodb.org/mongo-driver v1.14.0
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.