{"id":23442187,"url":"https://github.com/sealonk/dwitin-backend","last_synced_at":"2026-04-12T00:09:23.888Z","repository":{"id":267308458,"uuid":"900790508","full_name":"Sealonk/dwitin-backend","owner":"Sealonk","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-13T15:19:02.000Z","size":64,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dwitin-backend","last_synced_at":"2025-04-09T21:48:41.345Z","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/Sealonk.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-09T13:31:14.000Z","updated_at":"2024-12-13T15:19:06.000Z","dependencies_parsed_at":"2025-02-15T13:46:17.845Z","dependency_job_id":"2623ccb7-f96f-4855-906e-0deacd7afdf8","html_url":"https://github.com/Sealonk/dwitin-backend","commit_stats":null,"previous_names":["sealonk/dwitin-update","sealonk/dwitin-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Sealonk/dwitin-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sealonk%2Fdwitin-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sealonk%2Fdwitin-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sealonk%2Fdwitin-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sealonk%2Fdwitin-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sealonk","download_url":"https://codeload.github.com/Sealonk/dwitin-backend/tar.gz/refs/heads/dwitin-backend","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sealonk%2Fdwitin-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275071556,"owners_count":25400398,"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","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-23T17:28:57.380Z","updated_at":"2025-10-17T08:02:43.625Z","avatar_url":"https://github.com/Sealonk.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\n- The 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## Credential Variables\n\n- The following credential variables must be defined in a ./credentials/`serviceAccountKey.json` file:\n\n```json\n{\n    \"type\": \"service_account\",\n    \"project_id\": \"your_project_id\",\n    \"private_key_id\": \"your_private_key_id\",\n    \"private_key\": \"your_private_key\",\n    \"client_email\": \"your_client_email\",\n    \"client_id\": \"your_client_id\",\n    \"auth_uri\": \"your_auth_uri\",\n    \"token_uri\": \"your_token_uri\",\n    \"auth_provider_x509_cert_url\": \"your_auth_provider_x509_cert_url\",\n    \"client_x509_cert_url\": \"your_client_cert_url\"\n}\n```\n\n## Getting Started\n\n### Local Setup\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/Sealonk/dwitin-backend.git\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%2Fsealonk%2Fdwitin-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsealonk%2Fdwitin-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsealonk%2Fdwitin-backend/lists"}