You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+59-8Lines changed: 59 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,11 @@
1
1
# URL Shortener
2
2
3
-
A production-style distributed URL shortener with a FastAPI backend and a lightweight React frontend, built using PostgreSQL, Redis, Docker, pytest, and GitHub Actions CI.
4
-
5
-
This project emphasizes backend engineering beyond basic CRUD, focusing on scalability, performance optimization, fault tolerance, and production-ready system design.
3
+
A production-style distributed URL shortener demonstrating caching, rate limiting, load balancing, and horizontal scalability. Built with a FastAPI backend, React frontend, PostgreSQL, Redis, Docker, and CI/CD (GitHub Actions).
@@ -30,7 +28,7 @@ The frontend communicates with the deployed FastAPI backend via REST APIs, enabl
30
28
## Quick Test
31
29
32
30
- Frontend:
33
-
Open the web UI: https://your-frontend-url.onrender.com
31
+
-Open the web UI: https://url-shortener-frontend-av1x.onrender.com
34
32
35
33
- Backend API:
36
34
```bash
@@ -45,6 +43,7 @@ curl -X POST "https://url-shortener-gfp0.onrender.com/shorten" \
45
43
This project was built to simulate a production-style distributed system incorporating real-world backend and system design principles, rather than a simple CRUD application.
46
44
47
45
Key goals:
46
+
48
47
- Design a scalable API with clear request/response contracts
49
48
- Introduce caching and rate limiting as core system-level concerns
50
49
- Support multiple runtime environments (local, Docker, cloud)
@@ -69,6 +68,24 @@ Key goals:
69
68
- Run the full stack locally using Docker Compose
70
69
- Validate system behavior with pytest and GitHub Actions CI
71
70
- Support horizontal scaling via stateless application instances behind a load balancer
71
+
- Benchmark cache performance (miss vs. hit latency)
72
+
73
+
## Cache Performance Benchmark
74
+
75
+
To validate the effectiveness of Redis caching, redirect latency was measured for cache misses (first request) and cache hits (subsequent requests).
76
+
77
+
Run locally:
78
+
```bash
79
+
python scripts/benchmark_cache.py
80
+
```
81
+
82
+
Example results:
83
+
84
+
- Cache miss latency: ~30–45 ms
85
+
- Average cache hit latency: ~6 ms
86
+
- Approximate speedup: ~5–7×
87
+
88
+
This demonstrates that Redis caching significantly reduces redirect latency and minimizes repeated database queries in read-heavy workloads.
72
89
73
90
## Backend Highlights
74
91
@@ -79,6 +96,7 @@ Key goals:
79
96
- Built automated test coverage with pytest to validate core workflows
80
97
- Configured GitHub Actions CI to run tests on every push and pull request
81
98
- Introduced Nginx as a load balancer to distribute traffic across multiple FastAPI instances
99
+
- Validated Redis caching effectiveness using benchmark measurements (cache miss vs. hit latency)
82
100
83
101
## Tech Stack
84
102
@@ -96,11 +114,30 @@ Key goals:
96
114
## Project Structure
97
115
98
116
```text
99
-
app/ # FastAPI application code
117
+
app/ # FastAPI backend application
118
+
__init__.py
119
+
main.py # application entrypoint
120
+
core/ # application configuration and environment setup
121
+
__init__.py
122
+
config.py
123
+
services/ # external services and infrastructure logic
124
+
__init__.py
125
+
cache.py
126
+
rate_limiter.py
127
+
crud.py # database operations
128
+
database.py # database connection and setup
129
+
models.py # SQLAlchemy models
130
+
schemas.py # Pydantic schemas
131
+
utils.py # helper utilities
132
+
100
133
frontend/ # React frontend (Vite, API integration)
101
134
nginx/ # Nginx configuration for load balancing
102
135
tests/ # automated tests
103
-
scripts/ # helper scripts (e.g., seed data)
136
+
137
+
scripts/
138
+
seed.py # sample data loader
139
+
benchmark_cache.py # measures cache miss vs. hit latency
0 commit comments