Skip to content

Supplier module - #342

Merged
yusuftomilola merged 5 commits into
DistinctCodes:mainfrom
shamoo53:Supplier-Module
Oct 3, 2025
Merged

Supplier module#342
yusuftomilola merged 5 commits into
DistinctCodes:mainfrom
shamoo53:Supplier-Module

Conversation

@shamoo53

@shamoo53 shamoo53 commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

PR Description: Implement Supplier Module with CRUD APIs
Context

Companies rely on suppliers to provide assets. Currently, our system has no structured way to store or manage supplier information. This PR introduces a Supplier module that allows the system to store supplier details, manage their lifecycle, and link assets to suppliers for traceability.

Implementation Details
Database

Created suppliers table with the following fields:

id (primary key, auto-generated)

name (string, required)

contactInfo (string, optional)

address (string, optional)

email (string, unique, required)

phone (string, optional)

createdAt & updatedAt timestamps

Entities & DTOs

Defined Supplier entity in entities/supplier.entity.ts.

Created DTOs for CreateSupplierDto and UpdateSupplierDto with validation rules (e.g., IsEmail, IsNotEmpty, etc.).

Services & Controllers

Added SupplierService with methods:

createSupplier(dto)

getAllSuppliers()

getSupplierById(id)

updateSupplier(id, dto)

deleteSupplier(id)

Added SupplierController with REST endpoints:

POST /suppliers → create supplier

GET /suppliers → list all suppliers

GET /suppliers/:id → get supplier by ID

PUT /suppliers/:id → update supplier

DELETE /suppliers/:id → delete supplier

Asset Linking

Established relationship: One Supplier → Many Assets.

Updated Asset entity to include supplierId foreign key reference.

Enabled fetching suppliers along with their associated assets.

Documentation

Updated Swagger/OpenAPI to document all supplier endpoints.

Added API usage examples.

Acceptance Criteria

Suppliers can be created, read, updated, and deleted through API endpoints.

Each supplier record must contain a name and email.

Suppliers can be linked to assets via foreign key.

Running migrations should generate a suppliers table in the database.

Test Plan
Unit Tests

Entity Validation

Ensure DTOs reject invalid emails and missing required fields.

Service Logic

Test createSupplier stores data correctly.

Test updateSupplier applies changes.

Test deleteSupplier removes entry.

Relationship

Verify assets can be queried by supplier ID.

Integration Tests

POST /suppliers

Should create a supplier and return 201 + new supplier object.

GET /suppliers

Should return a paginated list of suppliers.

GET /suppliers/:id

Should return supplier details including linked assets.

PUT /suppliers/:id

Should update supplier info and return updated record.

DELETE /suppliers/:id

Should delete supplier and return confirmation.

Manual Validation

Run migration → confirm suppliers table created.

Seed a few suppliers and link them to assets.

Use Swagger or Postman to test endpoints.

✅ With this PR, the system can now manage supplier records and link them to assets, laying the foundation for supply-chain visibility.
Close #323

@vercel

vercel Bot commented Oct 3, 2025

Copy link
Copy Markdown

@shamoo53 is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@yusuftomilola
yusuftomilola merged commit 94bf599 into DistinctCodes:main Oct 3, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Supplier Module

2 participants