Skip to content

Latest commit

Β 

History

25 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ Task Manager CRUD API

A simple full-stack task management application built with Go, PostgreSQL, and Docker. Users can securely manage personal to-do lists with authentication and a clean web interface.


πŸš€ Features

  • πŸ” User authentication (login/logout)
  • βœ… Create, read, update, delete (CRUD) tasks
  • πŸ“Œ Mark tasks as complete/incomplete
  • ⚑ Fast backend using Go
  • 🐘 PostgreSQL database with indexing
  • 🐳 Dockerized setup for easy deployment
  • 🌐 Simple frontend with HTML + Tailwind CSS
  • πŸ›  Infrastructure automation using Terraform & Ansible
  • πŸ’» Monitoring Logs, System and Uptime

πŸ—οΈ Project Structure

task-manager/
.
β”œβ”€β”€ ansible
β”‚   β”œβ”€β”€ deploy.yml
β”‚   β”œβ”€β”€ inventory.yml
β”‚   β”œβ”€β”€ node_expoter.yml
β”‚   └── update-install.yml
β”œβ”€β”€ cmd
β”‚   └── server
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docs
β”‚   β”œβ”€β”€ ansible-task.log
β”‚   β”œβ”€β”€ images
β”‚   β”œβ”€β”€ nginx-with-ha.log
β”‚   └── terraform-task.log
β”œβ”€β”€ go.mod
β”œβ”€β”€ go.sum
β”œβ”€β”€ internal
β”‚   β”œβ”€β”€ config
β”‚   β”œβ”€β”€ handlers
β”‚   β”œβ”€β”€ middleware
β”‚   β”œβ”€β”€ models
β”‚   β”œβ”€β”€ repository
β”‚   └── services
β”œβ”€β”€ LICENSE
β”œβ”€β”€ migrations
β”‚   └── init.sql
β”œβ”€β”€ monitoring
β”‚   β”œβ”€β”€ alertmanager
β”‚   β”œβ”€β”€ alloy
β”‚   β”œβ”€β”€ blackbox-exporter
β”‚   β”œβ”€β”€ docker-compose.yml
β”‚   β”œβ”€β”€ grafana-storage
β”‚   β”œβ”€β”€ loki
β”‚   β”œβ”€β”€ prometheus
β”‚   └── webhook_receiver
β”œβ”€β”€ nginx.conf
β”œβ”€β”€ README.md
β”œβ”€β”€ terraform
β”‚   β”œβ”€β”€ main.tf
β”‚   β”œβ”€β”€ terraform.tf
β”‚   β”œβ”€β”€ terraform.tfstate
β”‚   β”œβ”€β”€ terraform.tfstate.backup
β”‚   β”œβ”€β”€ vagrant
β”‚   └── variable.tf
└── web
    └── templates

βš™οΈ Technologies Used

  • Backend: Go 1.25
  • Database: PostgreSQL 17
  • Frontend: HTML + Tailwind CSS
  • Authentication: bcrypt password hashing
  • Containerization: Docker & Docker Compose
  • Infrastructure: Terraform + Ansible
  • Monitoring: Prometheus, Grafana, Loki, Alloy, Alertmanager, blackbox-exporter

πŸ”Œ API Endpoints

Method Endpoint Description
GET / Login page
POST /login Authenticate user
GET /logout Logout user
GET /dashboard View tasks
POST /task/create Create task
POST /task/update Update task
GET /task/toggle Toggle completion
GET /task/delete Delete task

πŸš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • Go 1.25 (for local development)
  • PostgreSQL 17 (or use Docker)

Using Docker (Recommended)

# Clone and navigate
cd crud-api

# Start the application
docker-compose up -d

# Application runs on http://localhost:8080

Local Development

# Install dependencies
go mod download

# Set environment variables
export DB_USER=postgres
export DB_PASS=password
export DB_HOST=localhost
export DB_PORT=5432
export DB_NAME=task_manager

# Run migrations
psql -U postgres -d task_manager -f migrations/init.sql

# Start server
go run cmd/server/main.go

πŸ“‹ Environment Variables

DB_USER=postgres
DB_PASS=your_password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=task_manager
SERVER_PORT=8080

πŸ“Š Monitoring

Monitoring stack includes:

  • Prometheus - Metrics collection
  • Grafana - Visualization & dashboards
  • Loki - Log aggregation
  • Alloy - Flexible telemetry collector

Access Grafana at http://localhost:3000 (default: admin/admin)


πŸ“œ License

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


πŸ—„οΈ Database Schema

Users Table

  • id
  • username
  • password_hash
  • created_at

Tasks Table

  • id
  • user_id
  • title
  • description
  • is_completed
  • created_at
  • updated_at

Indexed on user_id for performance.


🐳 Getting Started (Docker)

1. Clone the Repository

git clone https://github.com/your-username/task-manager.git
cd task-manager

2. Set Environment Variables

Edit docker/docker-compose.yml or create a .env file:

DEFAULT_USER=admin
DEFAULT_PASS=admin123
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=taskdb

3. Run the Application

cd docker && docker-compose up --build -d

4. Access the App

Open your browser:

http://localhost:8080

Login with:

Username: admin
Password: admin123

πŸ’» Development (Dev Container)

This project includes a .devcontainer setup for seamless development in VS Code.

Steps:

  1. Install Dev Containers extension in VS Code
  2. Press:
Ctrl + Shift + P β†’ Reopen in Container

Benefits:

  • Preconfigured Go environment
  • PostgreSQL runs alongside app
  • No local setup required
  • Consistent dev environment

πŸš€ Deployment

1. Provision Infrastructure (Terraform)

Ref: https://registry.terraform.io/providers/bmatcuk/vagrant/latest/docs

cd terraform
terraform init
terraform apply

2. Configure Server & Deploy (Ansible)

Ref: Debian and AlmaLinux

cd ansible

# Step 1 β€” install curl, ca-certificates on target hosts
ansible-playbook -i inventory.yml update-install.yml

# Step 2 β€” install Docker, copy compose files, start the app
ansible-playbook -i inventory.yml deploy.yml

Both playbooks handle Debian (apt) and RedHat / AlmaLinux (dnf) automatically via ansible_os_family.

The deploy strategy pulls the pre-built image from DockerHub β€” only docker-compose.yml and migrations/ are transferred to each server, making it reproducible on any new host without rebuilding.


πŸ”„ Deployment Flow

Terraform β†’ Provision VMs
        ↓
Ansible (update-install.yml)
        ↓
Ansible (deploy.yml)
        ↓        
Application running on :8080

πŸ”§ Cross-Platform Support

Playbook Debian / Ubuntu RedHat / AlmaLinux
update-install.yml apt dnf
deploy.yml apt + Docker GPG key dnf + Docker CE repo

For detailed more detail logs visit: ./docs/

Monitoring

β€” Grafana, Prometheus, alertmanager, Loki, and Alloy (Promtail Alternative), blackbox-exporter

Note: Promtail reached end of life (EOL) on March 2, 2026.
https://grafana.com/docs/loki/latest/send-data/promtail/
So, I used Alloy to collect logs and forward them to Loki.

Blackbox Exporter

πŸ‘¨β€πŸ’» Lokendra Bhat

Built with Go for learning and practical DevOps integration.


About

devops project to host simple task manager app with concept of terraform, ansible, monitoring etc.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages