Skip to content

Commit c023474

Browse files
committed
add llms only content
1 parent 183f430 commit c023474

File tree

1 file changed

+85
-21
lines changed

1 file changed

+85
-21
lines changed

fern/docs/pages/get-started/overview.mdx

Lines changed: 85 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,96 @@ The API is organized around four main capabilities, each handling a specific asp
4646

4747
## How it works
4848

49-
When a customer browses your catalog, the plant management system handles search and filtering. Creating an order triggers the order processing system, which validates payment. On successful payment, inventory tracking reserves stock and manages fulfillment. Throughout the process, customer management sends notifications and maintains order history. If payment fails, the system cancels the order and notifies the customer automatically.
49+
1. **Browse plants**: Customer searches and filters the catalog through the API.
50+
2. **Return results**: API returns matching plants with availability and pricing.
51+
3. **Create order**: Customer adds items to cart and submits the order.
52+
4. **Process payment**: API sends payment information to the payment gateway.
53+
5. **Confirm payment**: Payment gateway validates and confirms the transaction.
54+
6. **Reserve and fulfill**: Backend services reserve inventory and begin fulfillment.
55+
7. **Send updates**: Customer receives tracking information and order history is updated.
5056

57+
If payment fails at step 5, the system takes an alternate path: the payment gateway declines the transaction (step 5), the API cancels the order (step 6), and the customer receives a cancellation notice (step 7).
58+
59+
<llms-ignore>
5160
<Accordion title="Architecture diagram">
5261
```mermaid
53-
graph TD
54-
A[Customer browses plants] --> B[Plant Management]
55-
B --> C[Adds to cart]
56-
C --> D[Creates order]
57-
58-
D --> E[Order Processing]
59-
E --> F{Payment successful?}
60-
61-
F -->|Yes| G[Inventory Tracking]
62-
F -->|No| H[Cancel & notify]
63-
64-
G --> I[Reserve stock]
65-
I --> J[Fulfill order]
66-
J --> K[Update inventory]
67-
68-
K --> L[Customer Management]
69-
L --> M[Send notifications]
70-
L --> N[Update order history]
71-
72-
H --> L
62+
sequenceDiagram
63+
autonumber
64+
actor Customer
65+
participant API as Plant Store API
66+
participant Payment as Payment Gateway
67+
participant Backend as Backend Services
68+
69+
Customer->>API: Browse and search plants
70+
API-->>Customer: Return filtered results
71+
Customer->>API: Create order
72+
API->>Payment: Process payment
73+
alt Payment successful
74+
Payment-->>API: Payment confirmed
75+
API->>Backend: Reserve stock & fulfill
76+
Backend->>Customer: Send tracking & update history
77+
else Payment failed
78+
Payment-->>API: Payment declined
79+
API->>Customer: Send cancellation notice
80+
end
7381
```
7482
</Accordion>
83+
</llms-ignore>
84+
85+
<llms-only>
86+
87+
### Detailed system architecture
88+
89+
The Plant Store API is built on a microservices architecture with event-driven communication between bounded contexts.
90+
91+
**Database architecture:**
92+
- PostgreSQL for transactional data (Orders, Customers, Inventory)
93+
- MongoDB for plant catalog (flexible schema for varying plant attributes)
94+
- Redis for distributed caching and rate limiting
95+
- Each service owns its database schema (no shared databases)
96+
97+
**Event-driven communication:**
98+
- Apache Kafka for async event streaming between services
99+
- Events use CloudEvents specification for standardization
100+
- Dead letter queues for failed event processing with exponential backoff retry (max 3 attempts)
101+
- Event versioning via content-type headers (application/vnd.plantstore.v1+json)
102+
103+
**Consistency patterns:**
104+
- Strong consistency within service boundaries (ACID transactions)
105+
- Eventual consistency across services via events
106+
- Saga pattern for distributed transactions (e.g., order creation + payment + inventory reservation)
107+
- Compensating transactions for rollback (e.g., ReleaseReservation on payment failure)
108+
109+
**Inventory management:**
110+
- Pessimistic locking for stock reservation using PostgreSQL advisory locks
111+
- Reservation TTL of 15 minutes with automatic release
112+
- Stock levels denormalized to Redis for fast reads (write-through cache)
113+
- Inventory audit log captures all stock movements for reconciliation
114+
115+
**Idempotency:**
116+
- All mutation endpoints require `Idempotency-Key` header (UUID v4)
117+
- Keys stored in Redis with 24-hour TTL
118+
- Duplicate requests return cached response with 200 status (not 409)
119+
120+
**Payment processing:**
121+
- Integration with Stripe Payment Intents API
122+
- Webhook handlers for async payment confirmation
123+
- Retry logic with exponential backoff for webhook failures
124+
- Payment state machine: pending → processing → succeeded/failed
125+
126+
**Caching strategy:**
127+
- Plant catalog cached for 5 minutes (high read/write ratio)
128+
- Customer profiles cached until update event (low write frequency)
129+
- Cache invalidation via event subscribers
130+
- Cache-aside pattern with Redis
131+
132+
**API gateway features:**
133+
- Request/response transformation
134+
- Circuit breaker pattern (fail fast after 5 consecutive failures)
135+
- Rate limiting per API key (token bucket algorithm)
136+
- JWT validation for authentication
137+
- Request correlation IDs for distributed tracing
138+
</llms-only>
75139

76140
## Rate limits
77141

0 commit comments

Comments
 (0)