{"id":30458472,"url":"https://github.com/m-azra3l/contract-payment-service","last_synced_at":"2026-05-11T07:26:31.354Z","repository":{"id":305435138,"uuid":"850971165","full_name":"m-azra3l/contract-payment-service","owner":"m-azra3l","description":"This application is a Contract and Payment Service built with NestJS, Prisma, and PostgreSQL. It manages profiles, contracts, and jobs, focusing on efficient handling of transactions, concurrency, and adherence to best practices in software development.","archived":false,"fork":false,"pushed_at":"2025-07-20T03:32:44.000Z","size":346,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-20T05:43:56.319Z","etag":null,"topics":["e2e-testing","jest","nestjs-backend","postgres","prisma","swagger-ui","typescript","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m-azra3l.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,"zenodo":null}},"created_at":"2024-09-02T07:23:41.000Z","updated_at":"2025-07-20T03:32:47.000Z","dependencies_parsed_at":"2025-07-20T05:54:10.115Z","dependency_job_id":null,"html_url":"https://github.com/m-azra3l/contract-payment-service","commit_stats":null,"previous_names":["m-azra3l/contract-payment-service"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/m-azra3l/contract-payment-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-azra3l%2Fcontract-payment-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-azra3l%2Fcontract-payment-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-azra3l%2Fcontract-payment-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-azra3l%2Fcontract-payment-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m-azra3l","download_url":"https://codeload.github.com/m-azra3l/contract-payment-service/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-azra3l%2Fcontract-payment-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271755882,"owners_count":24815495,"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-08-23T02:00:09.327Z","response_time":69,"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":["e2e-testing","jest","nestjs-backend","postgres","prisma","swagger-ui","typescript","unit-testing"],"created_at":"2025-08-23T17:04:58.396Z","updated_at":"2026-05-11T07:26:26.311Z","avatar_url":"https://github.com/m-azra3l.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Contract and Payment Service Application\n\nThis application is a **Contract and Payment Service** built with NestJS, Prisma, and PostgreSQL. It manages profiles, contracts, and jobs, focusing on efficient handling of transactions, concurrency, and adherence to best practices in software development.\n\n## Table of Contents\n\n- [Contract and Payment Service Application](#contract-and-payment-service-application)\n  - [Table of Contents](#table-of-contents)\n  - [Features](#features)\n  - [Installation](#installation)\n  - [Database Setup](#database-setup)\n  - [Seeding the Database](#seeding-the-database)\n  - [Running the Application](#running-the-application)\n  - [Testing](#testing)\n    - [Unit Tests](#unit-tests)\n    - [End-to-End (E2E) Tests](#end-to-end-e2e-tests)\n  - [API Documentation](#api-documentation)\n  - [Technologies Used](#technologies-used)\n  - [Project Structure](#project-structure)\n  - [Author](#author)\n  - [License](#license)\n\n## Features\n\n- **Profile Management**: Manages client and contractor profiles.\n- **Contract and Job Management**: Handles contracts between clients and contractors, and tracks jobs associated with contracts.\n- **Payment Processing**: Manages payments for jobs, ensuring transaction safety and handling race conditions.\n- **Admin Functionality**: Provides admin APIs to retrieve the best profession and best clients based on earnings. _Note: Admin routes are excluded from the standard authentication middleware._\n- **Authentication**: Basic authentication using middleware to verify `profile-id` from headers (except for admin routes).\n\n## Installation\n\n1. **Clone the Repository**:\n\n   ```bash\n   git clone https://github.com/m-azra3l/contract-payment-service.git\n   cd contract-payment-service\n   ```\n\n2. **Install Dependencies**:\n\n   Make sure you have [Node.js](https://nodejs.org/) installed, then run:\n\n   ```bash\n   yarn install\n   ```\n\n3. **Set Up Environment Variables**:\n\n   Create a `.env` file in the root directory and configure your database connection:\n\n   ```env\n   DATABASE_URL=\"postgresql://username:password@localhost:5432/contract_payment\"\n   PORT=5000\n   ```\n\n## Database Setup\n\n1. **Prisma Migrations**:\n\n   Run Prisma migrations to set up your database schema:\n\n   ```bash\n   npx prisma migrate dev --name init\n   ```\n\n2. **Prisma Client**:\n\n   Generate the Prisma Client to interact with your database:\n\n   ```bash\n   npx prisma generate\n   ```\n\n## Seeding the Database\n\nThe application includes a seed script to populate the database with initial data:\n\n1. **Run the Seed Script**:\n\n   ```bash\n   yarn seed\n   ```\n\n   This script creates 4 clients and 4 contractors, each with associated contracts and jobs.\n\n## Running the Application\n\nStart the application by running:\n\n```bash\nyarn start\n```\n\nThe server will start on the port specified in your `.env` file (`5000` by default).\n\n## Testing\n\n### Unit Tests\n\nTo run unit tests, use:\n\n```bash\nyarn test\n```\n\n### End-to-End (E2E) Tests\n\nTo run E2E tests, use:\n\n```bash\nyarn test:e2e\n```\n\nThese tests cover the major functionalities, ensuring that each part of the application works correctly in isolation (unit tests) and as a whole (E2E tests).\n\n## API Documentation\n\nSwagger is used to document the API. Once the application is running, you can access the API documentation at:\n\n```\nhttp://localhost:5000/api-docs\n```\n\n## Technologies Used\n\n- **NestJS**: A progressive Node.js framework for building efficient, reliable, and scalable server-side applications.\n- **Prisma**: An ORM that helps manage data in databases with ease and efficiency.\n- **PostgreSQL**: A powerful, open-source object-relational database system.\n- **Swagger**: API documentation made easy.\n- **Jest**: Testing framework for unit and E2E tests.\n\n## Project Structure\n\n```\ncontract-payment-service/\n│\n├── prisma/\n|   ├── migrations/\n│   ├── schema.prisma\n│   ├── seed.ts\n|\n├── src/\n│   ├── admin/\n│   │   ├── dto/\n|   │   │   ├── best-client.dto.ts\n│   │   ├── admin.controller.ts\n│   │   ├── admin.module.ts \n│   │   ├── admin.service.ts\n│   ├── app/\n|   |   ├── app.controller.ts\n│   |   ├── app.module.ts\n│   |   ├── app.service.ts\n│   ├── auth/\n│   │   ├── dto/\n|   │   │   ├── get-profile.dto.ts\n│   │   ├── auth.controller.ts\n│   │   ├── auth.middleware.ts\n│   ├── balances/\n│   │   ├── balances.controller.ts\n│   │   ├── balances.module.ts\n│   │   ├── balances.service.ts\n│   ├── config/\n│   │   ├── app.config.ts\n│   ├── contracts/\n│   │   ├── dto/\n|   │   │   ├── get-contract.dto.ts\n│   │   ├── contracts.controller.ts\n│   │   ├── contracts.module.ts\n│   │   ├── contracts.service.ts\n│   ├── jobs/\n│   │   ├── dto/\n|   │   │   ├── get-unpaid-jobs.dto.ts\n│   │   ├── jobs.controller.ts\n│   │   ├── jobs.module.ts\n│   │   ├── jobs.service.ts\n│   ├── prisma/\n│   │   ├── prisma.module.ts\n│   │   ├── prisma.service.ts\n│   ├── main.ts\n|\n├── test/\n│   ├── admin/\n|   |   ├── admin.controller.spec.ts\n|   |   ├── admin.e2e-specs.ts\n|   |   ├── admin.service.ts\n│   ├── app/\n|   |   ├── app.controller.spec.ts\n|   |   ├── app.e2e-spec.ts\n│   ├── auth/\n|   |   ├── auth.e2e-spec.ts\n|   |   ├── auth.middleware.spec.ts\n│   ├── balances/\n│   │   ├── balances.controller.spec.ts\n│   │   ├── balances.e2e-spec.ts\n│   │   ├── balances.service.spec.ts\n│   ├── contracts/\n│   │   ├── contracts.controller.spec.ts\n│   │   ├── contracts.e2e-spec.ts\n│   │   ├── contracts.service.spec.ts\n│   ├── jobs/\n│   │   ├── jobs.controller.spec.ts\n│   │   ├── jobs.e2e-spec.ts\n│   │   ├── jobs.service.spec.ts\n│   ├── prisma/\n│   │   ├── prisma.e2e-spec.ts\n│   │   ├── prisma.service.spec.ts\n|   ├── jest-e2e.json\n│\n├── .env(ignored)\n├── .eslintrc.js\n├── .gitignore\n├── .prettierrc\n├── Backend Engineer - Coding Exercise.pdf\n├── jest.config.js\n├── LICENSE\n├── nest-cli.json\n├── package.json\n├── README.md\n├── tsconfig.build.json\n├── tsconfig.json\n├── yarn.lock(ignored)\n```\n\n## Author\n\n- [Michael](https://github.com/m-azra3l)\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%2Fm-azra3l%2Fcontract-payment-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm-azra3l%2Fcontract-payment-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm-azra3l%2Fcontract-payment-service/lists"}