acupedia-api/README.md

134 lines
3.9 KiB
Markdown

# Acupedia API - Backend Services
FastAPI Backend Platform for Acupedia Learning Content, Subscriptions, Pricing, and Payments.
<!-- START_TEST_STATUS -->
[![Tests](https://img.shields.io/badge/tests-6%20failed-red)](#test-status--coverage) [![Coverage](https://img.shields.io/badge/coverage-73%25-yellow)](#test-status--coverage)
| Metric | Status |
| :--- | :--- |
| **Test Suite** | `FAILED` |
| **Tests Passing** | `92` |
| **Tests Failing** | `6` |
| **Core Coverage** | `73%` |
| **Last Updated** | `2026-10-22 06:02:56 UTC` |
<!-- END_TEST_STATUS -->
---
## Features & Services
- **Authentication & Security:** JWT tokens, bcrypt password hashing, password strength validation, OTP flow.
- **Cart & Pricing Engine:** Dynamic currency resolution (INR / USD), multi-unit volume discounts, returning user loyalty discounts, coupon redemption rules, and convenience fee calculations.
- **Content & Curriculum:** Acupoints, channels, topics, clinical modules with preview capabilities.
- **Checkout & Payments:** Razorpay orders, automatic invoice creation, payment status verification.
- **Webhooks:** Cryptographically validated Razorpay webhook listener for real-time payment captures and failures.
- **Administrative Portal:** Role-Based Access Control (`super_admin`, `admin`, `finance_admin`), refund processing, catalog status toggles.
- **Search System:** Faceted multi-scope search with typeahead and category filtering.
---
## Test Suite & Automation
The test suite is powered by `pytest` with asynchronous testing via `httpx.AsyncClient` and mocked dependencies for rapid execution (under 4 seconds) without external live service dependencies.
### Running Tests
```bash
# Run all tests
.venv/bin/pytest
# Run tests with verbose output
.venv/bin/pytest -v
# Run tests with code coverage report
.venv/bin/pytest --cov=app --cov-report=term-missing
```
> **Note:** Running `pytest` automatically updates the test status table and badges above in this `README.md`.
---
<details>
<summary><b>Appendix: Legacy Seed Plans Reference</b></summary>
```json
{
"version": 1,
"plans": [
{
"code": "POINTS_ACU",
"name": "Acu Points Module (1 Yr)",
"plan_type": "one_time",
"billing_period": "yearly",
"module_fee": "300.00",
"currency_code": "INR",
"country": "India",
"is_active": true,
"sort_order": 10,
"modules": [
{ "module_code": "M0001" }
]
},
{
"code": "POINTS_SCALP",
"name": "Scalp Points Module (1 Yr)",
"plan_type": "one_time",
"billing_period": "yearly",
"module_fee": "100.00",
"currency_code": "INR",
"country": "India",
"is_active": true,
"sort_order": 20,
"modules": [
{ "module_code": "M0003" }
]
},
{
"code": "POINTS_EAR",
"name": "Ear Points Module (1 Yr)",
"plan_type": "one_time",
"billing_period": "yearly",
"module_fee": "200.00",
"currency_code": "INR",
"country": "India",
"is_active": true,
"sort_order": 30,
"modules": [
{ "module_code": "M0002" }
]
},
{
"code": "POINTS_TUNG",
"name": "Tung Points Module (1 Yr)",
"plan_type": "one_time",
"billing_period": "yearly",
"module_fee": "300.00",
"currency_code": "INR",
"country": "India",
"is_active": false,
"sort_order": 40,
"modules": [
{ "module_code": "M0004" }
]
},
{
"code": "LIFETIME_ALL_USD",
"name": "Lifetime All-Access Plan (USD)",
"plan_type": "bundle",
"billing_period": "lifetime",
"module_fee": "350.00",
"currency_code": "USD",
"country": "USA",
"is_active": true,
"sort_order": 310,
"modules": [
{ "module_code": "M0001" },
{ "module_code": "M0002" },
{ "module_code": "M0003" }
]
}
]
}
```
</details>