ArtisanConnect-Backend is a backend API for managing artisan bookings. It provides secure authentication, real-time appointment scheduling, role-based access, and appointment status tracking. Built with Node.js, Express, Knex.js, MySQL, and JWT authentication, this backend ensures seamless interactions between users and artisans.
- User & Artisan Authentication (JWT-based)
- Appointment Booking with Timeframe Constraints
- Role-based Access Control
- Appointment Status Management (Pending, Accepted, Declined, Completed)
- Artisan Availability Tracking
- Backend: Node.js, Express.js
- Database: MySQL with Knex.js ORM
- Authentication: JWT (JSON Web Token)
- Validation: Express Validator
Ensure you have the following installed:
- Clone the Repository
git clone https://github.com/Umoru98/ArtisanConnect-Backend.git cd ArtisanConnect-Backend - Install Dependencies
npm install
- Configure Environment Variables
- Create a
.envfile in the root directory and add:PORT=8000 DB_HOST=your_database_host DB_USER=your_database_user DB_PASSWORD=your_database_password DB_NAME=your_database_name JWT_SECRET=your_secret_key
- Create a
- Run Database Migrations
npx knex migrate:latest
- Start the Server
The API will run on
npm start
http://localhost:5000
Endpoint: POST /api/auth/register
- Request Body:
{ "first_name": "John", "last_name": "Doe", "email": "johndoe@example.com", "password": "securepassword" } - Response:
{ "message": "User registered successfully", "token": "your_jwt_token" }
Endpoint: POST /api/auth/login
- Request Body:
{ "email": "johndoe@example.com", "password": "securepassword" } - Response:
{ "token": "your_jwt_token" }
Endpoint: POST /api/appointments
- Headers:
{ "Authorization": "Bearer your_jwt_token" } - Request Body:
{ "artisan_id": 3, "service_id": 2, "start_time": "2025-03-05 10:00:00", "end_time": "2025-03-05 12:00:00" } - Response:
{ "message": "Appointment booked successfully" }
Endpoint: PATCH /api/appointments/:appointmentId
- Headers:
{ "Authorization": "Bearer artisan_jwt_token" } - Request Body:
{ "status": "accepted" } - Response:
{ "message": "Appointment accepted" }
Endpoint: GET /api/artisans/appointments
- Headers:
{ "Authorization": "Bearer artisan_jwt_token" } - Response:
[ { "id": 1, "user_name": "John Doe", "service": "Plumbing", "start_time": "2025-03-05 10:00:00", "end_time": "2025-03-05 12:00:00", "status": "pending" } ]
- Fork the Repository
- Create a Feature Branch (
git checkout -b feature-name) - Commit Changes (
git commit -m "Add new feature") - Push to GitHub (
git push origin feature-name) - Open a Pull Request
This project is licensed under the MIT License.