CoffeeChain is a backend system designed to provide API endpoints for tracking the journey of coffee products from farm to cup. This project leverages a blockchain-inspired architecture to ensure transparency, traceability, and fairness in the coffee supply chain. The backend serves as the foundation for the CoffeeChain platform, enabling farmers, companies, and consumers to interact with immutable data about coffee products and their production stages.
- API Endpoints:
- Retrieve blockchain data for coffee products.
- Verify the integrity of blockchain chains.
- Add new coffee products and production stages.
- Generate scannable QR codes for product verification.
- Blockchain Layer:
- Simulated private blockchain for immutability and audit trail.
- Tracks production stages such as farming, harvesting, roasting, packaging, and retail.
- Data Security:
- Ensures tamper-proof data storage using cryptographic hashing.
- Logging:
- Comprehensive logging system using Winston for debugging and monitoring.
- Validation:
- Input validation using Zod schemas for robust API requests.
http://localhost:5000/api
- Backend: Node.js + Express
- Blockchain Layer: Simulated private blockchain
- Validation: Zod for schema validation
- Logging: Winston for logging
- QR Integration: QR code generation for product verification
- Database:
- Node.js (v16 or higher)
- npm or yarn
- Clone the repository:
git clone https://github.com/your-repo/coffee-chain.git
- Navigate to the project directory:
cd coffee-chain - Install dependencies:
npm install
- Create a .env file and configure environment variables:
PORT=5000 NODE_ENV=development - Start the development server:
npm run dev
npm run build # Compile TypeScript files into JavaScript.
npm run start # Build and start the server.
npm run dev # Start the server in development mode using nodemon.src/
├── controllers/ # API controllers
├── database/ # Database connection and queries
├── models/ # TypeScript models for blockchain and products
├── routes/ # API route definitions
├── schemas/ # Zod schemas for validation
├── services/ # Business logic and blockchain services
├── utils/ # Utility functions (e.g., logger)
├── middlewares/ # Custom middleware (e.g., error handling)
├── server.ts # Entry point for the backendLogging The project uses Winston for logging. Logs are stored in the logs/ directory:
combined.log - All logs. error.log - Error logs only. Validation All incoming requests are validated using Zod schemas to ensure data integrity. Example schemas include:
- CoffeeProductSchema - Validates coffee product data.
- JourneyStageSchema - Validates production stage data.
- Yabets Zekaryas
For questions or support, please contact:
- Email: yabetszekaryas07@gmail.com
- GitHub: CoffeeChain Repository