Skip to content

Commit f7c2828

Browse files
Docs/create architecture md (JhaSourav07#638)
* docs: add architecture overview * style: format architecture document * style: apply prettier formatting
1 parent f89d184 commit f7c2828

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

ARCHITECTURE.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Architecture
2+
3+
This document explains how a request flows through the SVG rendering pipeline.
4+
5+
## Request → Response Flow
6+
7+
```mermaid
8+
flowchart TD
9+
A[Client Request] --> B[app/api/streak/route.ts]
10+
B --> C[lib/github.ts]
11+
C --> D[lib/calculate.ts]
12+
D --> E[lib/svg/generator.ts]
13+
E --> F[SVG Response]
14+
```
15+
16+
## Layer Responsibilities
17+
18+
### API Layer
19+
20+
**File:** `app/api/streak/route.ts`
21+
22+
Receives incoming requests and handles request validation. It acts as the entry point for the SVG generation pipeline.
23+
24+
### GitHub Data Layer
25+
26+
**File:** `lib/github.ts`
27+
28+
Fetches contribution and activity data from GitHub APIs and prepares the required information.
29+
30+
### Calculation Layer
31+
32+
**File:** `lib/calculate.ts`
33+
34+
Processes fetched data and calculates statistics such as contribution streaks and related values.
35+
36+
### SVG Generation Layer
37+
38+
**File:** `lib/svg/generator.ts`
39+
40+
Converts processed data into SVG elements and generates the final visual output.
41+
42+
## Caching Strategy
43+
44+
Caching reduces repeated API requests and improves performance.
45+
46+
The system can cache GitHub responses and calculated results to:
47+
48+
- Reduce unnecessary API calls
49+
- Improve response speed
50+
- Reduce server load
51+
- Prevent repeated processing for frequently requested data
52+
53+
## Summary
54+
55+
Pipeline flow:
56+
57+
1. Client sends request
58+
2. API route receives request
59+
3. GitHub data is fetched
60+
4. Data calculations are performed
61+
5. SVG is generated
62+
6. Response is returned

0 commit comments

Comments
 (0)