A minimalist e-commerce backend built with Rust and Actix-web, featuring product management, shopping cart functionality, and Paystack payment integration.
- Product catalog (name and price)
- Shopping cart management
- Order placement and management
- Paystack payment integration
- RESTful API design
- Backend: Rust with Actix-web framework
- Database: PostgreSQL with SQLx
- Payment: Paystack API
- Environment: dotenvy for configuration management
src/
├── main.rs # Application entry point
├── models/ # Data models
│ ├── mod.rs
│ ├── user.rs
│ ├── product.rs
│ ├── cart.rs
│ └── order.rs
├── handlers/ # Request handlers
│ ├── mod.rs
│ ├── product.rs
│ ├── cart.rs
│ ├── order.rs
│ └── payment.rs
├── routes/ # Route definitions
│ ├── mod.rs
│ ├── product.rs
│ ├── cart.rs
│ ├── order.rs
│ └── payment.rs
└── services/ # Business logic
├── mod.rs
├── database.rs
└── payment.rs
GET /api/products- List all productsGET /api/products/{id}- Get product details
POST /api/cart- Add item to cartGET /api/cart- View cart contentsPUT /api/cart/{id}- Update cart itemDELETE /api/cart/{id}- Remove item from cart
POST /api/orders- Place an orderGET /api/orders/{id}- Get order details
POST /api/payment/initialize- Initialize paymentPOST /api/payment/verify- Verify payment
- Clone the repository
- Copy
.env.exampleto.envand update with your configuration - Set up your PostgreSQL database
- Run
cargo buildto build the project - Run
cargo runto start the server
PORT: Server port (default: 3000)HOST: Server host (default: 127.0.0.1)DATABASE_URL: PostgreSQL connection stringPAYSTACK_SECRET_KEY: Your Paystack secret keyPAYSTACK_PUBLIC_KEY: Your Paystack public key
The application uses the following main entities:
- Users (for order tracking)
- Products (name and price)
- Cart Items (product reference and quantity)
- Orders (user reference and items)
- Payments (order reference and status)
- User adds items to cart
- User places an order
- Payment is initialized with Paystack
- User completes payment on Paystack's platform
- Payment is verified and order is confirmed
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.