{"id":23028537,"url":"https://github.com/c2p2-ps546/dwitin-backend-cloud-computing","last_synced_at":"2026-04-11T06:05:00.521Z","repository":{"id":267835663,"uuid":"902503871","full_name":"C2P2-PS546/Dwitin-Backend-Cloud-Computing","owner":"C2P2-PS546","description":"A backend project for transaction management, including user authentication, transaction CRUD operations, and image upload support using Google Cloud Storage.","archived":false,"fork":false,"pushed_at":"2024-12-13T08:17:18.000Z","size":4472,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dwitin-backend","last_synced_at":"2025-02-08T10:45:55.017Z","etag":null,"topics":["api","authentication","backend","express","google-cloud-storage","mysql","nodejs","transaction-management"],"latest_commit_sha":null,"homepage":"http://35.219.51.198:5000","language":"JavaScript","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/C2P2-PS546.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-12T17:36:35.000Z","updated_at":"2024-12-13T05:52:46.000Z","dependencies_parsed_at":"2024-12-13T06:29:01.891Z","dependency_job_id":null,"html_url":"https://github.com/C2P2-PS546/Dwitin-Backend-Cloud-Computing","commit_stats":null,"previous_names":["c2p2-ps546/dwitin","c2p2-ps546/dwitin-backend-cloud-computing"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/C2P2-PS546%2FDwitin-Backend-Cloud-Computing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/C2P2-PS546%2FDwitin-Backend-Cloud-Computing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/C2P2-PS546%2FDwitin-Backend-Cloud-Computing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/C2P2-PS546%2FDwitin-Backend-Cloud-Computing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/C2P2-PS546","download_url":"https://codeload.github.com/C2P2-PS546/Dwitin-Backend-Cloud-Computing/tar.gz/refs/heads/dwitin-backend","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246885077,"owners_count":20849612,"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":["api","authentication","backend","express","google-cloud-storage","mysql","nodejs","transaction-management"],"created_at":"2024-12-15T14:11:40.606Z","updated_at":"2025-12-30T23:10:31.732Z","avatar_url":"https://github.com/C2P2-PS546.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Backend for DWITIN\n\nThis repository contains the backend code for the DWITIN project, a platform for managing transactions, user profiles, and file uploads. The backend is built with Node.js, Express, Sequelize, and integrates with Google Cloud services.\n\n## Table of Contents\n\n1. [Features](#features)\n2. [Prerequisites](#prerequisites)\n3. [Environment Variables](#environment-variables)\n4. [Getting Started](#getting-started)\n   - [Local Setup](#local-setup)\n   - [Deployment](#deployment)\n5. [API Documentation](#api-documentation)\n   - [Base URL](#base-url)\n   - [Authentication](#authentication)\n     - [Register User](#register-user)\n     - [Login User](#login-user)\n   - [Users](#users)\n     - [Get User Profile](#get-user-profile)\n     - [Upload Profile Image](#upload-profile-image)\n   - [Transactions](#transactions)\n     - [Create Transaction](#create-transaction)\n     - [Get All Transactions](#get-all-transactions)\n     - [Get Transaction by ID](#get-transaction-by-id)\n     - [Delete Transaction](#delete-transaction)\n6. [License](#license)\n   \n## Features\n- User authentication (register and login).\n- Manage transactions (create, read, delete).\n- Upload and retrieve user profile images.\n- Google Cloud Storage integration for storing uploaded images.\n\n## Prerequisites\n\nBefore you begin, ensure you have the following:\n\n- Node.js and npm installed.\n- MySQL database instance.\n- Google Cloud service account key file for accessing Google Cloud Storage.\n- Compute Engine instance with the backend deployed.\n\n## Environment Variables\n\nThe following environment variables must be defined in a `.env` file:\n\n```plaintext\nPORT=5000\nJWT_SECRET=your_jwt_secret_key\nDB_HOST=your_database_host\nDB_USER=your_database_user\nDB_PASS=your_database_password\nDB_NAME=your_database_name\nGOOGLE_CLOUD_PROJECT=your_google_cloud_project_id\nGOOGLE_APPLICATION_CREDENTIALS=./credentials/service-account-key.json\n```\n\n## Getting Started\n\n### Local Setup\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/C2P2-PS546/Dwitin.git dwitin-backend\n   cd dwitin-backend\n   ```\n\n2. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n3. Add the required environment variables in a `.env` file in the root directory.\n\n4. Create a `credentials` directory and place your Google Cloud service account key file inside.\n\n5. Start the server:\n\n   ```bash\n   npm run start\n   ```\n\n### Deployment\n\nThe backend is deployed to Google Compute Engine at:\n\n```\nhttp://35.219.51.198:5000\n```\n\nEnsure that the Compute Engine instance has:\n- Node.js installed.\n- Environment variables configured.\n- Required ports (e.g., 5000) open in the firewall settings.\n\n## API Documentation\n\n### Base URL\n```\nhttp://35.219.51.198:5000/api\n```\n\n### Authentication\n\n#### 1. Register User\n- **Endpoint:** `POST /auth/register`\n- **Description:** Registers a new user.\n- **Request Body:**\n  ```json\n  {\n    \"name\": \"string\",\n    \"email\": \"string\",\n    \"password\": \"string\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"error\": false,\n    \"message\": \"User Created\"\n  }\n  ```\n\n#### 2. Login User\n- **Endpoint:** `POST /auth/login`\n- **Description:** Logs in an existing user and generates a JWT token.\n- **Request Body:**\n  ```json\n  {\n    \"email\": \"string\",\n    \"password\": \"string\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"error\": false,\n    \"message\": \"success\",\n    \"loginResult\": {\n      \"userId\": 1,\n      \"name\": \"John Doe\",\n      \"token\": \"eyJhbGciOiJIUzI1NiIs...\"\n    }\n  }\n  ```\n\n### Users\n\n#### 1. Get User Profile\n- **Endpoint:** `GET /users/user`\n- **Headers:**\n  ```json\n  {\n    \"Authorization\": \"Bearer \u003cJWT_TOKEN\u003e\"\n  }\n  ```\n- **Description:** Fetches the profile of the authenticated user.\n- **Response:**\n  ```json\n  {\n    \"error\": false,\n    \"message\": \"User profile fetched successfully\",\n    \"user\": {\n      \"id\": 1,\n      \"name\": \"John Doe\",\n      \"email\": \"johndoe@example.com\",\n      \"profileImage\": \"null\",\n      \"darkMode\": false,\n      \"language\": \"en\",\n      \"balance\": 10000\n    }\n  }\n  ```\n\n#### 2. Upload Profile Image\n- **Endpoint:** `POST /users/user/profile-image`\n- **Headers:**\n  ```json\n  {\n    \"Authorization\": \"Bearer \u003cJWT_TOKEN\u003e\"\n  }\n  ```\n- **Description:** Uploads a profile image for the authenticated user.\n- **Request Form Data:**\n  - Key: `profileImage`\n  - Value: Image file\n- **Response:**\n  ```json\n  {\n    \"error\": false,\n    \"message\": \"Profile image uploaded successfully\",\n    \"profileImage\": \"https://storage.googleapis.com/dwitin-bucket/profile_image_url.jpg\"\n  }\n  ```\n\n### Transactions\n\n#### 1. Create Transaction\n- **Endpoint:** `POST /transactions`\n- **Headers:**\n  ```json\n  {\n    \"Authorization\": \"Bearer \u003cJWT_TOKEN\u003e\"\n  }\n  ```\n- **Request Body:**\n  ```json\n  {\n    \"title\": \"string\",\n    \"amount\": \"number\",\n    \"type\": \"income | expense\",\n    \"description\": \"string\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"error\": false,\n    \"message\": \"Transaction added successfully\",\n    \"transactionData\": {\n      \"id\": 22,\n      \"title\": \"Monthly Salary\",\n      \"amount\": 50000,\n      \"type\": \"income\",\n      \"description\": \"Salary for December\",\n      \"userId\": 1,\n      \"createdAt\": \"2024-12-11T04:54:20.697Z\",\n      \"updatedAt\": \"2024-12-11T04:54:20.697Z\"\n    }\n  }\n  ```\n\n#### 2. Get All Transactions\n- **Endpoint:** `GET /transactions`\n- **Headers:**\n  ```json\n  {\n    \"Authorization\": \"Bearer \u003cJWT_TOKEN\u003e\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"error\": false,\n    \"message\": \"Transactions fetched successfully\",\n    \"listTransaction\": [\n      {\n        \"id\": 11,\n        \"title\": \"Shopping\",\n        \"amount\": 100,\n        \"type\": \"expense\",\n        \"description\": \"Groceries\",\n        \"imageUrl\": null,\n        \"createdAt\": \"2024-12-10T06:31:03.000Z\",\n        \"updatedAt\": \"2024-12-10T06:31:03.000Z\"\n      }\n    ]\n  }\n  ```\n\n#### 3. Get Transaction by ID\n- **Endpoint:** `GET /transactions/:id`\n- **Headers:**\n  ```json\n  {\n    \"Authorization\": \"Bearer \u003cJWT_TOKEN\u003e\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"error\": false,\n    \"message\": \"Transaction fetched successfully\",\n    \"transaction\": {\n      \"id\": 22,\n      \"title\": \"Monthly Salary\",\n      \"amount\": 50000,\n      \"type\": \"income\",\n      \"description\": \"Salary for December\",\n      \"userId\": 1,\n      \"createdAt\": \"2024-12-11T04:54:20.697Z\",\n      \"updatedAt\": \"2024-12-11T04:54:20.697Z\"\n    }\n  }\n  ```\n\n#### 4. Delete Transaction\n- **Endpoint:** `DELETE /transactions/:id`\n- **Headers:**\n  ```json\n  {\n    \"Authorization\": \"Bearer \u003cJWT_TOKEN\u003e\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"error\": false,\n    \"message\": \"Transaction deleted successfully\",\n    \"balance\": 45000\n  }\n  ```\n\n---\n\n## License\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc2p2-ps546%2Fdwitin-backend-cloud-computing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc2p2-ps546%2Fdwitin-backend-cloud-computing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc2p2-ps546%2Fdwitin-backend-cloud-computing/lists"}