Pan Afric Store -- An express based application, focused on currency conversion and locking in four major African currencies (NGN, GHS, ZAR, KES) and USD.
# π Pan-Afrik Store API
**Pan-Afrik Store** is a high-performance cross-border e-commerce backend engine. It solves the critical challenge of currency volatility in African trade by implementing automated exchange rate synchronization, rate-locking at checkout, and decoupled merchant payout logic.
---
## π Key Technical Features
- **Automated Currency Sync**: Integrated `RateService` that fetches, caches, and manages exchange rates via a PostgreSQL-backed `RateCache`.
- **Atomic Checkout**: A robust transaction-based checkout system that locks exchange rates to prevent price fluctuations during payment.
- **Merchant Payout Management**: Automatically calculates merchant earnings in their local `baseCurrency`, ensuring sellers receive exact amounts regardless of the buyer's currency.
- **Security & Resilience**:
- **JWT & Role-Based Access**: Strict boundaries for `merchant` and `customer` roles.
- **Rate Limiting**: Protects sensitive checkout and auth endpoints from brute-force attacks.
- **Cloudinary Integration**: Secure handling and storage of product imagery.
---
## ποΈ Project Architecture
```
βββ config/ # Cloudinary, CORS, Prisma, and Redis setups
βββ controllers/ # Express handlers (Auth, Cart, Order, Product, Rate, User)
βββ coverage/ # LCOV and Jest test coverage reports
βββ middleware/ # Hash, JWT Auth, Rate Limiter, and Role Check logic
βββ prisma/
β βββ migrations/ # SQL migration history
β βββ schema.prisma # PostgreSQL relational schema
βββ routes/ # Unified API route definitions
βββ services/ # Business Logic: Currency, Rates, Webhooks, Image Uploads
βββ test/ # Comprehensive Jest integration and unit test suites
βββ utils/ # AppError, catchAsyncErrors, Logger, and Validators
βββ app.js # Express application configuration
βββ server.js # Server entry point
```
# API Documentation
**Base URL:**
panafrik-store.on β¦