The NovelNest Order Service is a microservice responsible for managing orders in the NovelNest application. NovelNest is a scalable platform for book enthusiasts to buy, sell, and exchange books. This service handles order creation, updates, and status management, ensuring seamless transactions between buyers and sellers.
- Node.js: Backend runtime environment
- Express.js: Web framework for building APIs
- Prisma: ORM for database interactions
- PostgreSQL: Relational database
- RabbitMQ: Message broker for asynchronous communication
- Docker: Containerization platform
- Kubernetes: Orchestration for deploying and managing services
order-service/
├── docker-compose.yaml # Docker Compose configuration
├── Dockerfile # Docker image definition
├── package.json # Node.js dependencies and scripts
├── prisma/ # Prisma schema and migrations
│ ├── schema.prisma # Database schema definition
│ └── migrations/ # Database migration files
├── src/ # Source code
│ ├── index.ts # Entry point of the service
│ ├── middleware.ts # Middleware definitions
│ ├── rabbitmq.ts # RabbitMQ integration
│ ├── routes/ # API route handlers
│ └── types.ts # TypeScript type definitions
└── tsconfig.json # TypeScript configuration
- Order management: Create, update, and retrieve orders
- Integration with RabbitMQ for event-driven communication
- PostgreSQL database for persistent storage
- Prisma ORM for database operations
Ensure the following tools are installed:
- Node.js (v16 or higher)
- Docker
- Docker Compose
- kubectl
- Kind (optional for local Kubernetes cluster)
-
Clone the repository:
git clone https://github.com/NovelNestHQ/order-service cd NovelNestHQ/order-service
-
Install dependencies:
npm install
-
Set up the database:
npx prisma migrate dev --name init npx prisma generate
-
Start the service:
npm run dev
The service will be running at http://localhost:5010
.
-
Ensure your Kubernetes cluster is running and
kubectl
is configured. -
Apply the Kubernetes manifests:
kubectl apply -f ../k8s-manifests/order-service/order-service.yaml
-
Verify the deployment:
kubectl get pods
-
Access the service:
-
Use
kubectl port-forward
to forward the service port locally:kubectl port-forward svc/order-service 5010:5010
-
The service will be accessible at
http://localhost:5010
.
-
The following environment variables are required:
DATABASE_URL
: Connection string for the PostgreSQL databasePORT
: Port on which the service runs (default: 5010)
- Use the provided Prisma migrations to initialize the database schema.
- Test the API endpoints using tools like Postman or cURL.
To delete the Kubernetes resources:
kubectl delete -f ../k8s-manifests/order-service/order-service.yaml
Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.
This project is licensed under the MIT License.