Skip to content

AgentGTD/agent-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task Manager API

A robust and scalable task management API built with Go and MongoDB, designed to power the Task Manager mobile application.

🚀 Features

  • 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 task
    • GET /tasks - List all tasks
    • GET /tasks/:id - Get a specific task
    • PUT /tasks/:id - Update a task
    • DELETE /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

🛠️ Prerequisites

  • Go 1.23.4 or higher
  • MongoDB instance
  • Encore.dev CLI (optional, for deployment)

🔧 Environment Setup

  1. Clone the repository
  2. Set up your MongoDB connection string in the environment:
    export MONGODB_URI="your_mongodb_connection_string"

🚀 Getting Started

  1. Install dependencies:

    go mod download
  2. Run the API locally:

    go run .

The API will start on port 4000 by default.

📝 API Documentation

Task Schema

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"`
}

Endpoints

Create Task

POST /tasks
Content-Type: application/json

{
    "title": "Task Title",
    "description": "Task Description",
    "status": "pending"
}

List Tasks

GET /tasks

Get Task

GET /tasks/:id

Update Task

PUT /tasks/:id
Content-Type: application/json

{
    "title": "Updated Title",
    "description": "Updated Description",
    "status": "in_progress"
}

Delete Task

DELETE /tasks/:id

🔒 Error Handling

The API implements comprehensive error handling with appropriate HTTP status codes:

  • 400: Invalid input
  • 404: Resource not found
  • 500: Internal server error

🧪 Testing

Run the test suite:

go test ./...

📦 Dependencies

  • encore.dev v1.46.1
  • go.mongodb.org/mongo-driver v1.14.0

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages