Skip to content

Commit

Permalink
Added Project Setup and Run Linting Docs 📝
Browse files Browse the repository at this point in the history
  • Loading branch information
Laban254 committed Oct 21, 2024
1 parent 4e5258a commit a541cdc
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 2 deletions.
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# task-manager-api-gin
RESTful API for task management built with the Gin framework.
# Task Management API 🚀

## Overview 🌟

The Task Management API is a RESTful API built using the Gin framework in Go. It provides a robust backend for managing tasks and projects, featuring user authentication, role-based access control, and integration with Google OAuth for enhanced security and user experience.

Getting Started 🛠️
Refer to the [Project Setup](./docs/project_setup.md) section in the original documentation for instructions on setting up the environment and dependencies.

## Features ⚙️

- **User Authentication**:
- Supports JWT-based authentication for secure user sessions.
- Implements OAuth 2.0 for Google authentication.
- **Role-Based Access Control (RBAC)**:
- Differentiate user roles (admin and regular users) with specific permissions for managing projects and tasks. 👥
- **CRUD Operations**:
- Full support for creating, reading, updating, and deleting tasks and projects.
- API endpoints include:
- `/login` - User login and JWT issuance.
- `/register` - New user registration.
- `/projects` - Manage projects (create, read, update, delete).
- `/tasks` - Manage tasks (create, read, update, delete).
- **Input Validation and Error Handling**:
- Ensures incoming data is validated and errors are handled gracefully.
- **Middleware Support**:
- Integrated middleware for logging, CORS handling, and request parsing.
- Custom middleware for JWT validation and rate-limiting.
- **Secure Communication**:
- All endpoints are protected and require authentication.

## Directory Structure 📁

bash

Copy code

`/cmd - Entry points for the application (main.go).
/pkg - Reusable components (authentication, routes, models).
/config - Configuration files (environment variables).
/internal - Application-specific logic (services, handlers).
/scripts - Deployment scripts (Docker, Kubernetes).`

## Technologies Used 💻

- **Go**: Programming language for building the API.
- **Gin**: Web framework for building the RESTful API.
- **GORM**: ORM for interacting with the database.
- **PostgreSQL**: Database for storing user and project data.
- **JWT**: For user authentication and session management.

61 changes: 61 additions & 0 deletions docs/project_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## Project Setup 🛠️

To set up the Task Management API project, follow these steps:

### Prerequisites 📋

- **Go**: Ensure you have Go installed (version 1.20 or higher is recommended). You can download it from [the official Go website](https://golang.org/dl/).
- **PostgreSQL**: Install PostgreSQL for database management. Make sure to set up a database for the application.
- **Git**: Install Git for version control.

### Steps to Set Up the Project 🚀

1. **Clone the Repository**: Open your terminal and run the following command to clone the repository:



`git clone https://github.com/yourusername/task-management-api.git`

2. **Navigate to the Project Directory**: Change to the project directory:



`cd task-management-api`

3. **Initialize Go Modules**: Initialize a new Go module (if not done already):


`go mod init task_management_api`

4. **Install Gin Framework**: Install the Gin framework by running:

`go get -u github.com/gin-gonic/gin`

5. **Install GORM and PostgreSQL Driver**: Run the following commands to install GORM and the PostgreSQL driver:

`go get -u gorm.io/gorm
go get -u gorm.io/driver/postgres`

6. **Configure Environment Variables**: Create a `.env` file in the root directory to store your environment variables. Here's an example configuration:


`DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=your_db_name
JWT_SECRET=your_jwt_secret`

7. **Run Migrations**: Ensure your database is set up correctly and run any migrations if you have defined them in your application.

8. **Start the Application**: You can start the application by running:


`go run cmd/main.go`

9. **Access the API**: Once the server is running, you can access the API at `http://localhost:8080`.


### Testing the Setup ✅

After setting up, you can test the API using tools like Postman or cURL to ensure the endpoints are functioning correctly.
1 change: 1 addition & 0 deletions docs/run-linting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
golangci-lint run

0 comments on commit a541cdc

Please sign in to comment.