Skip to content

Commit b1ff29c

Browse files
committed
docs: add sections
1 parent 80dcd15 commit b1ff29c

1 file changed

Lines changed: 94 additions & 5 deletions

File tree

README.md

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A **modern, scalable, and production-ready REST API** for a Markdown-based blogg
44

55
This project demonstrates **real-world backend engineering practices** including authentication, authorization, modular architecture, cursor pagination, security hardening, and clean API design — built with **TypeScript, Express 5, PostgreSQL, Drizzle ORM, and Zod**.
66

7-
> Designed as a portfolio-grade backend to showcase job-ready backend skills.
7+
> This backend is intentionally over-engineered for a portfolio project to demonstrate real-world backend engineering decisions.
88
99
---
1010

@@ -27,15 +27,18 @@ If you’re reviewing this repo:
2727

2828
## 🚀 Features
2929

30-
### 🔐 Authentication & Security
30+
### 🔐 Authentication & Account Lifecycle
3131

3232
- JWT **access tokens** (short-lived)
3333
- **Refresh tokens** via HTTP-only cookies
34-
- Secure logout & token rotation
34+
- Secure logout & refresh token rotation
35+
- Refresh tokens are **hashed before storage**
36+
- Token reuse detection & family revocation
3537
- Role-based access control (**USER / AUTHOR / ADMIN**)
36-
- Rate limiting on sensitive routes
38+
- Email verification with expiring, one-time tokens
39+
- Rate limiting on authentication & write endpoints
3740
- Security headers via **Helmet**
38-
- Proper CORS for multiple frontends
41+
- Strict CORS allowlist (no wildcard origins with credentials)
3942

4043
### ✍️ Blogging System
4144

@@ -95,6 +98,63 @@ If you’re reviewing this repo:
9598

9699
---
97100

101+
## 👤 Users & Admin Management
102+
103+
The API includes a complete user management system designed for real-world applications.
104+
105+
### User Capabilities
106+
107+
- View authenticated user profile
108+
- Update own profile (username, bio)
109+
- Upload profile picture via signed uploads
110+
- Email verification workflow
111+
112+
### Admin Capabilities
113+
114+
- List all users with cursor-based pagination
115+
- Filter users by role and active status
116+
- Update user roles and activation state
117+
- Moderate platform access without hard deletes
118+
119+
User operations follow strict **role-based authorization policies** and avoid destructive actions to preserve data integrity.
120+
121+
---
122+
123+
## 🖼️ Profile Picture Uploads (Signed Upload Pattern)
124+
125+
Profile images are handled using an industry-standard **signed upload** pattern:
126+
127+
1. Client requests an upload signature from the backend
128+
2. Image is uploaded **directly** to Cloudinary
129+
3. Backend stores only the final image URL
130+
131+
### Why this approach?
132+
133+
- Backend never processes files
134+
- No memory or DOS risk
135+
- Scales independently of API servers
136+
- Automatic image optimization & CDN delivery
137+
138+
This mirrors how modern SaaS products handle user-generated media.
139+
140+
---
141+
142+
## 🛡️ Security Hardening
143+
144+
This API applies multiple layers of security best practices:
145+
146+
- Email verification required for write operations
147+
- Rate limiting tuned per route category
148+
- `Cache-Control: no-store` on authenticated API responses
149+
- Refresh token cleanup strategy for expired sessions
150+
- Helmet-based security headers
151+
- Server fingerprinting disabled (`x-powered-by`)
152+
- No public API documentation in production
153+
154+
Security decisions are intentional and documented, not defaults.
155+
156+
---
157+
98158
## 📁 Project Structure
99159

100160
```txt
@@ -275,6 +335,35 @@ pnpm db:studio
275335

276336
---
277337

338+
## 🧪 Testing Strategy
339+
340+
- Integration-style API tests using **Vitest** and **Supertest**
341+
- Database reset between tests for isolation
342+
- Auth helpers for role-based test scenarios
343+
- Coverage includes:
344+
- Authentication flows
345+
- Role-based access control
346+
- Posts, comments, and likes
347+
- Admin-only operations
348+
349+
Tests focus on **behavior and guarantees**, not implementation details.
350+
351+
---
352+
353+
## 🐳 Docker & Deployment
354+
355+
The project includes a production-ready Docker setup:
356+
357+
- Multi-stage Docker build
358+
- Non-root runtime user
359+
- Native dependency handling (Argon2)
360+
- Separate development and production configurations
361+
- Environment-driven database driver selection (pg / Neon)
362+
363+
This allows the API to be deployed consistently across local, staging, and production environments.
364+
365+
---
366+
278367
## 🧠 Design Decisions
279368

280369
- Policy-based authorization instead of hardcoded checks

0 commit comments

Comments
 (0)