Task Management System in Golang Cloud Native
Published: 2024-04-29 21:06:15

**Introduction**
For our final project, we developed a robust and secure task management system. Our system comprises four microservices: User Service, Task Service, Billing Service, and a Gateway. This final report aims to provide an overview of the implemented solutions, the challenges faced during the development process, and the strategies employed to overcome them.

**User Flow:**
To start the user with login, if they don’t have an account they will create one. Then a regular user can create update or view tasks that below to them. Admin users have the same permissions, and can delete tasks/users and assign tasks to users. When a task is marked “done” an invoice is automatically generated for it. Admins have full Create Read Update and Delete (CRUD) permissions over invoices, regular users cannot see them. The user flow in diagram form is below.


![User Flow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i43onsg8isuu4zud6gf6.png)

**Microservice Architecture**
This project uses a micro service architecture, which comprises four main services. All the backend is written in Golang.


![Microservice Architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xi3764vn90bdzmpnijq3.png)

**The four main services:**
**Api Gateway:** This receives all the requests and forwards them to the correct service.
**User Service:** Manages user registration, authentication, and profile management.
**Task Service:** Allows users to create, update, and manage tasks with features to support hierarchical task relationships.
**Billing Service:** Generates invoices based on completed tasks, automatically calculating the cost based on pre-defined rates and hours worked.

To handle the admin authentication the team chose to generate JWT tokens upon login. This token is then passed via the authentication header and verified by the middleware.go file. This file contains function definitions that are used in each microservice. The main functions used in this are the admin authentication which parses the token and verifies it, if it's correct then the request is allowed, otherwise it's marked as unauthorized.  This file also contains the CORS handling function, this was to streamline the api.go file and not clutter it. 

**Middleware Implementation**
CORS Handling: We incorporated CORS middleware in our gateway to facilitate cross-origin resource sharing, enabling seamless communication between our frontend and backend services.

Authentication Middleware: Implemented authentication middleware to verify user identities using JSON Web Tokens (JWT), ensuring secure access to protected resources.

**Challenges Faced**
Our biggest challenges faced was implementing CORS for the frontend, and auto generating the Invoice IDs. We were able to successfully implement cors at the api gateway which solved our issues. Then for the invoice id we had to make a specific endpoint for the task service to call, this isn’t locked behind an admin token. Then this was locked behind a different middleware function to secure the endpoint.

**Conclusion**
In conclusion, our journey to implement security measures and facilitate communication within our task management system has been both challenging and rewarding. By overcoming obstacles and leveraging innovative solutions, we have learned alot about building a a cloud native full stack project.


**References**
[Github Repo](https://github.com/DavidN0809/Cloud-Computing/)