Go Engineer
This repository contains three services: User-Service, Task-Service, and Notification-Service. Each service is built with Go, utilizing clean architecture principles, and is ready for production use with Docker, Docker Compose, and RabbitMQ integration.
The User-Service manages user registration, login, profile updates, and role-based access control.
The Task-Service handles task creation, updates, and assignment. It also notifies managers when tasks are completed or updated.
The Notification-Service is responsible for sending notifications to managers whenever a task is updated by a technician.
| Method | Endpoint | Description |
|---|---|---|
| POST | /users/register |
Register a new user |
| POST | /users/login |
Login a user |
| GET | /users/profile/:id |
Get current user profile |
| PUT | /users/update/:id |
Update user profile |
| DELETE | /users/delete/:id |
Delete a user by ID |
| GET | /healthcheck |
Healt check |
- POST
/users/register
Request Body:
{
"name": "Manager",
"email": "manager@gmail.com",
"password": "manager",
"role": "manager"
}Response:
{
"username": "Manager",
"email": "manager@gmail.com",
"role": "Manager"
}- POST
/users/login
Request Body:
{
"email": "manager@gmail.com",
"password": "manager"
}Response:
{
"token": "JWT-TOKEN-HERE",
}| Method | Endpoint | Description |
|---|---|---|
| POST | /tasks |
Create a new task |
| GET | /tasks |
List all tasks |
| GET | /tasks/:task_id |
Update a task by ID |
| PUT | /tasks/:task_id/status |
PUT task task |
| GET | /healthcheck |
Healt check |
- POST
/tasks
Request Body:
{
"title": "Fix server issue",
"description": "Fix the bug in the server-side code.",
"status": "pending",
"assigned_to": 2
}Response:
{
"id": 1,
"title": "Fix the bug in the server-side code.",
"description": "The server is down and needs immediate attention",
"status": "pending",
"assigned_to": 2,
"performed_by": 0,
"performed_at": "0001-01-01T00:00:00Z",
"created_at": "2024-10-17T04:26:02.071374177+01:00"
}- PUT
/tasks/:task_id/status
Request Body:
{
"status": "completed"
}Response:
{
"message": "Task updated successfully"
}| Method | Endpoint | Description |
|---|---|---|
| GET | /notifications |
List all notifications |
| GET | /healthcheck |
Healt check |
- GET
/notifications
Response:
[
{
"id": 1,
"task_id": 1,
"message": "Technician 1 completed task 'Fix server issue' on 2024-10-08.",
"status": "sent",
"sent_at": "2024-10-08T12:30:00Z"
}
]To run all services (User-Service, Task-Service, Notification-Service) together locally:
-
Clone the repository:
git clone https://github.com/your-repo/swordhealth.git cd swordhealth -
Run all services with Docker Compose:
docker-compose up
This will start all three services:
- User-Service at
http://localhost:8081 - Task-Service at
http://localhost:8082 - Notification-Service at
http://localhost:8083
Additionally, the services will communicate through RabbitMQ, which will be automatically set up based on the previous RabbitMQ configuration.
| Variable | Description |
|---|---|
MYSQL_URI |
Database connection string |
JWT_SECRET |
Secret key for JWT authentication |
PORT |
Service port (default: 8081) |
| Variable | Description |
|---|---|
MYSQL_URI |
Database connection string |
RABBITMQ_URL |
RabbitMQ connection URL |
JWT_SECRET |
Secret key for JWT authentication |
PORT |
Service port (default: 8082) |
| Variable | Description |
|---|---|
MYSQL_URI |
Database connection string |
RABBITMQ_URL |
RabbitMQ connection URL |
PORT |
Service port (default: 8083) |
[In construction]
-
make up
-
migrate-up
-
run-user-service
-
run-task-service
-
run-notification-service
{
"email": "admin@gmail.com",
"password": "admin"
}
{
"email": "manager@gmail.com",
"password": "manager"
}
{
"email": "tech1@gmail.com",
"password": "tech"
}