{"id":27879414,"url":"https://github.com/rupesh40/carrental-go","last_synced_at":"2026-02-23T13:34:10.293Z","repository":{"id":65541992,"uuid":"594351600","full_name":"rupesh40/CarRental-Go","owner":"rupesh40","description":"Car Rental Go ","archived":false,"fork":false,"pushed_at":"2025-04-09T10:14:25.000Z","size":14029,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T11:24:58.788Z","etag":null,"topics":["gin","golang","gorm","graphql","jwt-authentication","postgres"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rupesh40.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-28T09:19:58.000Z","updated_at":"2025-04-09T10:14:54.000Z","dependencies_parsed_at":"2023-02-16T09:15:27.781Z","dependency_job_id":null,"html_url":"https://github.com/rupesh40/CarRental-Go","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupesh40%2FCarRental-Go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupesh40%2FCarRental-Go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupesh40%2FCarRental-Go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupesh40%2FCarRental-Go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rupesh40","download_url":"https://codeload.github.com/rupesh40/CarRental-Go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252430274,"owners_count":21746630,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gin","golang","gorm","graphql","jwt-authentication","postgres"],"created_at":"2025-05-05T03:21:42.039Z","updated_at":"2026-02-23T13:34:10.245Z","avatar_url":"https://github.com/rupesh40.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Car Rental Go\n\n## Overview\n\nThis is a Go-based Car Rental system that allows users to sign up, log in, manage cars, book and return rentals. The application supports both local and Docker-based environments.\n\n---\n\n## Requirements\n\nBefore running the project, ensure you have the following installed:\n- Go (1.19.1 version or above)\n- Docker (if using Docker environment)\n- PostgreSQL (for local development)\n\n---\n\n## Setup\n\n### 1. Running Locally (Without Docker)\n\n1. Clone the repository:\n    ```bash\n    git clone \u003crepository-url\u003e\n    cd \u003crepository-directory\u003e\n    ```\n\n2. Install Go dependencies:\n    ```bash\n    go mod tidy\n    ```\n\n3. Set up PostgreSQL locally:\n    - Create a PostgreSQL user.\n    - Create a database.\n    - Grant the database access to the created user.\n\n4. Update the `.env` file with the following credentials:\n    ```env\n    DB_USERNAME=\u003cyour-db-username\u003e\n    DB_PASSWORD=\u003cyour-db-password\u003e\n    DB_NAME=\u003cyour-db-name\u003e\n    DB_HOST=localhost\n    ```\n\n5. Run the application:\n    ```bash\n    go run cmd/main.go\n    ```\n\n### 2. Running with Docker\n\n1. To start the application with Docker, run the following command:\n    ```bash\n    docker-compose up\n    ```\n\n2. To stop the application and containers, run:\n    ```bash\n    docker-compose down\n    ```\n\n---\n\n## API Usage\n\n### 1. **Sign Up a New User**\n- **Endpoint**: `POST http://localhost:3000/user/signup`\n- **Request Body**:\n    ```json\n    {\n        \"first_name\": \"userF\",\n        \"last_name\": \"userL\",\n        \"email\": \"user@gmail.com\",\n        \"phone\": \"1234567890\",\n        \"password\": \"password\",\n        \"user_type\": \"ADMIN\"\n    }\n    ```\n    You can change the `user_type` to `USER`.\n\n---\n\n### 2. **Login User**\n- **Endpoint**: `POST http://localhost:3000/user/login`\n- **Request Body**:\n    ```json\n    {\n        \"email\": \"user@gmail.com\",\n        \"password\": \"password\"\n    }\n    ```\n- **Response**: The response will contain a `token` field (JWT token).\n  \n    **Example Response**:\n    ```json\n    {\n        \"token\": \"your-jwt-token\"\n    }\n    ```\n    Copy the JWT token from the response to use in subsequent requests.\n\n---\n\n### 3. **Add a New Car**\n- **Endpoint**: `POST http://localhost:3000/cars/AddCar`\n- **Request Body**:\n    ```json\n    {\n        \"carModel\": \"fc-001\",\n        \"date_of_manufacture\": \"2021-04-01\",\n        \"last_service_date\": \"2022-02-06\",\n        \"last_used_date\": \"2023-01-04\",\n        \"status\": \"Rented\"\n    }\n    ```\n    **Important**: Don’t forget to add the JWT token in the request header.\n    \n    - Header Key: `token`\n    - Header Value: `your-jwt-token`\n\n---\n\n### 4. **Get All Cars**\n- **Endpoint**: `GET http://localhost:3000/cars`\n- Alternatively, you can use a GraphQL query:\n    ```graphql\n    query GetAllCars {\n        cars {\n            id\n            car_model\n            date_of_manufacture\n            last_service_date\n            last_used_date\n            status\n        }\n    }\n    ```\n\n    **Important**: Don’t forget to add the JWT token in the request header.\n\n---\n\n### 5. **Book a Car**\n- **Endpoint**: `GET http://localhost:3000/cars/bookCar/:carID`\n- Replace `:carID` with the actual car ID you want to book. Example:\n    ```bash\n    http://localhost:3000/cars/bookCar/4ef1af7e-3076-4c29-9358-4365cd42f0d8\n    ```\n\n    **Important**: Don’t forget to add the JWT token in the request header.\n\n---\n\n### 6. **Return a Car**\n- **Endpoint**: `GET http://localhost:3000/cars/returnCar/:carID`\n- Replace `:carID` with the actual car ID you want to return. Example:\n    ```bash\n    http://localhost:3000/cars/returnCar/4ef1af7e-3076-4c29-9358-4365cd42f0d8\n    ```\n\n    **Important**: Don’t forget to add the JWT token in the request header.\n\n---\n\n### 7. **Logout User**\n- **Endpoint**: `GET http://localhost:3000/users/logout`\n\n    **Important**: Don’t forget to add the JWT token in the request header.\n\n---\n\n## Testing API Endpoints\n\nYou can use **Postman** or any other API testing tool to interact with the API. For each request, ensure you add the JWT token obtained during login in the `Authorization` header.\n\n---\n\n## Notes\n\n- Replace all `\u003cplaceholders\u003e` in the provided code with your actual values.\n- The JWT token must be added to the header for all requests requiring authentication.\n- Ensure your PostgreSQL service is running if using a local environment.\n\n---\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frupesh40%2Fcarrental-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frupesh40%2Fcarrental-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frupesh40%2Fcarrental-go/lists"}