{"id":26802519,"url":"https://github.com/yeab-b/backend-business-directory","last_synced_at":"2025-03-29T21:18:31.862Z","repository":{"id":282072305,"uuid":"856721003","full_name":"yeab-B/BACKEND-BUSINESS-DIRECTORY","owner":"yeab-B","description":"🌐 This is a Business Directory project where businesses can easily register their information, and users can effortlessly access detailed profiles 📊 with just a few clicks!","archived":false,"fork":false,"pushed_at":"2024-10-09T07:34:08.000Z","size":379,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T17:27:11.171Z","etag":null,"topics":["backend","business-directory","bussiness"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yeab-B.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-09-13T04:42:32.000Z","updated_at":"2024-10-09T07:34:11.000Z","dependencies_parsed_at":"2025-03-12T17:37:28.030Z","dependency_job_id":null,"html_url":"https://github.com/yeab-B/BACKEND-BUSINESS-DIRECTORY","commit_stats":null,"previous_names":["yeab-b/backend-business-directory"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeab-B%2FBACKEND-BUSINESS-DIRECTORY","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeab-B%2FBACKEND-BUSINESS-DIRECTORY/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeab-B%2FBACKEND-BUSINESS-DIRECTORY/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeab-B%2FBACKEND-BUSINESS-DIRECTORY/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yeab-B","download_url":"https://codeload.github.com/yeab-B/BACKEND-BUSINESS-DIRECTORY/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246243526,"owners_count":20746312,"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":["backend","business-directory","bussiness"],"created_at":"2025-03-29T21:18:31.212Z","updated_at":"2025-03-29T21:18:31.847Z","avatar_url":"https://github.com/yeab-B.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n---\n\n# Business Directory Backend\n\n## 🙏 Acknowledgment\n\nWe would like to extend our heartfelt thanks to **Etech Company** for providing us with the incredible opportunity to work on this project during our internship. Your support and guidance have been invaluable in helping us develop our skills and grow as developers.\n\nAdditionally, we would like to thank all of our friends who offered insights, suggestions, and encouragement throughout the development process. Your input played a significant role in shaping the success of this project!\n\n\n## 📑 Table of Contents\n\n1. [📖 Project Overview](#📖-Project-Overview)\n2. [✨ Features](#✨-features)\n3. [🛠️ Technologies Used](#🛠️-technologies-used)\n4. [🚀 Getting Started](#🚀-getting-started)\n   - [🔧 Prerequisites](#🔧-prerequisites)\n   - [⚙️ Installation](#⚙️-installation)\n5. [📚 API Manual for Business Directory Project](#📚-api-manual-for-business-directory-project)\n6. [🧪 Running Tests](#🧪-running-tests)\n7. [🤝 Contributing](#🤝-contributing)\n8. [📜 License](#📜-license)\n9. [📞 Contact](#📞-contact)\n\n\n\n\n## 📖 Project Overview\n\nThis repository contains the backend code for the **Business Directory** platform, a service designed to connect business owners and users by enabling businesses to be registered, rated, and managed efficiently. The backend is built using Node.js and Express and leverages PostgreSQL for data storage. Key features include JWT authentication for security, role-based access control to differentiate between regular users, business owners, and admins, and a RESTful API for interacting with the platform's data.\n\n\n\n## 📸 Screenshot1\n![Projects Screenshots](./utils/image/2.jpg)\n\n\n\n## 📸 Screenshot2\n\n![Projects Screenshots](./utils/image/3.jpg)\n\n\n---\n\n## ✨Features\n\n- **Business Registration**: Allows business owners to register their businesses by selecting from a predefined list of categories.\n- **User Authentication**: Secure user authentication using JWT (JSON Web Token) for session management.\n- **Role-Based Access Control**: Differentiates access rights among regular users, business owners, and administrators.\n- **Business Search and Ratings**: Enables users to search for businesses and leave ratings and reviews.\n- **Admin Management**: Admins can manage the platform, including approving or rejecting business registrations.\n- **Data Persistence**: Uses PostgreSQL for robust data storage and management.\n- **Category Management**: Businesses are categorized into predefined categories, facilitating easy search and filtering.\n\n## 🛠️ Technologies Used\n\n- **Node.js**: JavaScript runtime for building scalable network applications.\n- **Express**: Web framework for Node.js, used for building RESTful APIs and handling HTTP requests.\n- **PostgreSQL**: Relational database management system for data persistence.\n- **Prisma**: ORM (Object-Relational Mapping) tool for database interaction and schema management.\n- **JWT (JSON Web Tokens)**: Used for implementing secure authentication and authorization.\n\n\n## 🚀 Getting Started\n\n### 🔧Prerequisites\n\n- **Node.js**: Install from [Node.js official website](https://nodejs.org/).\n- **PostgreSQL**: Install and set up PostgreSQL. Refer to the [official documentation](https://www.postgresql.org/docs/) for installation guidance.\n\n\n### ⚙️Installation\n\n1. **Clone the Repository**:\n\n    ```bash\n    git clone https://github.com/Fitsumhelina/business-directory-backend.git\n    cd business-directory-backend\n    ```\n\n2. **Install Dependencies**:\n\n    ```bash\n    npm install\n    ```\n\n3. **Set Up Environment Variables**:\n\n    Create a `.env` file in the root directory and define the following environment variables:\n\n    ```plaintext\n    JWT_SECRET=your_jwt_secret\n    DATABASE_URL=\"postgresql://username:password@localhost:5432/Business-Directory?schema=public\"\n    PORT=your_port\n    ```\n\n    Replace placeholders with your actual database credentials, JWT secret, and preferred port number.\n\n4. **Migrate the Database**:\n\n    Set up the database schema using Prisma migrations:\n\n    ```bash\n    npx prisma migrate dev --name init\n    ```\n\n5. **Seed the Database**:\n\n    Seed the database with predefined categories:\n\n    ```bash\n    npm run seed\n    ```\n\n6. **Start the Server**:\n\n    ```bash\n    npm start\n    ```\n\n    The server will start, and you can access the application at `http://localhost:5000`.\n\n\n# 📚 API Manual for Business Directory Project\n\n## Overview\nThis manual provides detailed information about the API endpoints available in the Business Directory application. It includes descriptions, required fields, and example requests for both backend and frontend developers.\n\n---\n\n## User Management APIs\n\n### 1. **User Registration**\n- **Endpoint**: `/api/users/register`\n- **Method**: `POST`\n- **Purpose**: Register a new user.\n\n#### Required Fields\n| Field      | Description                          |\n|------------|--------------------------------------|\n| `username` | The unique username for the user.    |\n| `email`    | The user's email address.            |\n| `password` | The user's password.                 |\n| `firstname`| The user's first name.               |\n| `lastname` | The user's last name.                |\n\n#### Example Request\n```json\n{\n  \"username\": \"john_doe\",\n  \"email\": \"john@example.com\",\n  \"password\": \"securepassword\",\n  \"firstname\": \"John\",\n  \"lastname\": \"Doe\"\n}\n```\n### 2. User Login\n\n- **Endpoint**: `/api/users/login`\n- **Method**: `POST`\n- **Purpose**: Log in an existing user.\n\n#### Required Fields\n\n| Field    | Description                  |\n|----------|------------------------------|\n| `email`  | The user's email address.    |\n| `password` | The user's password.       |\n\n#### Example Request\n\n```json\nPOST /api/users/login\nContent-Type: application/json\n\n{\n  \"email\": \"testuser@example.com\",\n  \"password\": \"Password@123\"\n}\n\n```\n### 3. Get User Profile\n\n- **Endpoint**: `/api/users/profile`\n- **Method**: `GET`\n- **Purpose**: Retrieve the current user's profile.\n\n#### Usage\n\n- **Authentication**: Requires an authentication token.\n\n#### Example Request\n\n```http\nGET /api/users/profile\nAuthorization: Bearer YOUR_AUTH_TOKEN\n```\n### 4. Update User Profile\n\n- **Endpoint**: `/api/users/profile`\n- **Method**: `PUT`\n- **Purpose**: Update the user's profile information.\n- **Authentication**: Requires an authentication token.\n- **Required Fields**:\nfirstname: The updated first name.\nlastname: The updated last name.\nemail: The updated email address.\n#### Example Request\n\n```json\nPUT /api/users/profile\nAuthorization: Bearer YOUR_JWT_TOKEN\nContent-Type: application/json\n\n{\n  \"firstname\": \"Updated\",\n  \"lastname\": \"User\",\n  \"email\": \"updateduser@example.com\"\n}\n\n```\n### 5. Delete User Profile\n\n- **Endpoint**: `/api/users/profile`\n- **Method**: `DELETE`\n- **Purpose**: Delete the current user's profile.\n\n#### Usage\n\n- **Authentication**: Requires an authentication token.\n\n#### Example Request\n\n```http\nDELETE /api/users/profile\nAuthorization: Bearer YOUR_AUTH_TOKEN\n```\n## Business Directory APIs\n\n### 1. Register Business\n\n- **Endpoint**: `/api/businesses/register`\n- **Method**: `POST`\n- **Purpose**: Register a new business.\n\n#### Required Fields\n\n\n| Field                | Description                                                                 |\n|----------------------|-----------------------------------------------------------------------------|\n| `businessName`        | The name of the business.                                                   |\n| `businessEmail`       | The email address of the business owner, used to identify the owner.        |\n| `categoryId`          | The ID of the category to which the business belongs.                       |\n| `subcategoryId`       | The ID of the subcategory to which the business belongs. **(New)**          |\n| `businessAddress`     | The physical address of the business.                                       |\n| `businessPhone`       | The contact phone number for the business.                                  |\n| `websiteUrl`          | The business's website URL.                                                 |\n| `latitude`            | The latitude coordinate of the business location.                           |\n| `longitude`           | The longitude coordinate of the business location.                          |\n| `openingTime`         | The opening time of the business.                              |\n| `closingTime`         | The closing time of the business.                               |\n| `businessLicenseNumber` | The license number of the business for verification purposes.  |\n\n\n\n#### Example Request\n\n```json\nPOST /api/businesses/register\nAuthorization: Bearer YOUR_JWT_TOKEN\nContent-Type: application/json\n\n{\n  \"businessName\": \"Test Business\",\n  \"businessEmail\": \"business@example.com\",\n  \"categoryId\": \"CATEGORY_ID_HERE\",\n  \"businessAddress\": \"123 Business St\",\n  \"businessPhone\": \"123-456-7890\",\n  \"websiteUrl\": \"http://example.com\",\n  \"latitude\": 40.7128,\n  \"longitude\": -74.0060,\n  \"openingTime\": \"09:00\",\n  \"closingTime\": \"17:00\",\n  \"businessLicenseNumber\": \"123456789\"\n}\n\n\n```\n\n\n### 2. Get All Businesses\n\n- **Endpoint**: `/api/businesses`\n- **Method**: `GET`\n- **Purpose**: Retrieve a list of all registered businesses.\n\n#### Example Request\n\n```http\nGET /api/businesses\n```\n### 3. Get Business by ID\n\n- **Endpoint**: `/api/businesses/{BUSINESS_ID}`\n- **Method**: `GET`\n- **Purpose**: Retrieve details of a specific business by its ID.\n\n#### Example Request\n\n```http\nGET /api/businesses/123\n```\n### 4. Update Business\n\n- **Endpoint**: `/api/businesses/business/{BUSINESS_ID}`\n- **Method**: `PUT`\n- **Purpose**: Update the details of an existing business.\n- **Required Fields**:\n  - *businessName*: The updated name of the business.\n  - *businessEmail*: The updated email address.\n  - *businessAddress*: The updated address.\n  - *businessPhone*: The updated phone number.\n\n#### Example Request\n\n```json\nPUT /api/businesses/123\nAuthorization: Bearer YOUR_JWT_TOKEN\nContent-Type: application/json\n\n{\n  \"businessName\": \"Updated Business Name\",\n  \"businessEmail\": \"updated@example.com\",\n  \"businessAddress\": \"456 New Address\",\n  \"businessPhone\": \"987-654-3210\"\n}\n\n```\n### 5. Delete Business\n\n- **Endpoint**: `/api/businesses/business/{BUSINESS_ID}`\n- **Method**: `DELETE`\n- **Purpose**: Delete a specific business by its ID.\n- **Authentication**: Requires an authentication token.\n#### Example Request\n\n```http\nDELETE /api/businesses/123\nAuthorization: Bearer YOUR_JWT_TOKEN\n\n```\n### 6. Get Businesses by Category ID\n\n- **Endpoint**: `/api/businesses/businesses/category/{CATEGORY_ID}`\n- **Method**: `GET`\n- **Purpose**: Retrieve businesses belonging to a specific category.\n\n#### Example Request\n\n```http\nGET /api/businesses/businesses/category/1\n```\n### 7. Get Businesses by Search Criteria\n\n- **Endpoint**: `/api/businesses/search`\n- **Method**: `GET`\n- **Purpose**: Search for businesses based on various criteria (e.g., name, location).\n\n#### Example Request\n\n```http\nGET /api/businesses/businesses/search?name=Test Busiyu\u0026address=123 Business St\n```\n\n### 8,Get Category Name by Category ID\n\n- **Endpoint**: `http://localhost:5000/api/businesses/categories/{CATEGORY_ID}`\n- **Method**: `GET`\n- **Purpose**: Retrieve the name of a category by its ID.\n\n#### Example Request\n\n```http\nGET http://localhost:5000/api/businesses/categories/1\n```\n\n\n\n  \n### 🧪 Running Tests\n\nTo run tests, execute the following command in the root directory:\n\n```bash\nnpm test\n```\n\nTests are located in the `tests` directory and cover various functionalities of the application.\n\n## 🤝 Contributing\n\nWe welcome contributions from the community! To contribute:\n\n1. Fork the repository.\n2. Create a new branch (`git checkout -b feature-branch-name`).\n3. Make your changes.\n4. Commit your changes (`git commit -m 'Add feature description'`).\n5. Push to the branch (`git push origin feature-branch-name`).\n6. Create a Pull Request.\n\n## 📜 License\n\nThis project is licensed under the MIT License. For more information, see the [LICENSE](LICENSE) file.\n\n## 📞 Contact the developers \n\nFor questions or suggestions, please reach out:\n\n- Yeabsira Behailu: [GitHub Profile](https://github.com/Yabe12)\n- Fitsum Helina: [dev.fitsum@gmail.com](mailto:dev.fitsum@gmail.com)\n\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeab-b%2Fbackend-business-directory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyeab-b%2Fbackend-business-directory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeab-b%2Fbackend-business-directory/lists"}