The Online Library project aims to build a low-cost serverless platform for storing and distributing content (PDF/ePub) for a small user group (initially ~100 users, primarily students/labs needing controlled internal research-material sharing). The solution prioritizes security, content moderation (Admin Approval), and transparent, linear operating costs as it scales.
The architecture uses a fully AWS Serverless stack (Amplify, Cognito, API Gateway, Lambda, S3, CloudFront, DynamoDB).
Estimated cost for the MVP (excluding Free Tier) is ≈ $9.80/month, with predictable scaling to 5,000–50,000 users.
Documents and books are scattered; there is no secure content delivery system with access control; the process of adding or moderating user-generated content (UGC) is slow and has high friction.
Build a serverless pipeline on AWS:
Users upload files via Presigned PUT URL to temporary S3; Admin approves → Lambda moves the file to a protected public folder; Readers access content via Signed GET URL (from CloudFront/CDN) to ensure speed and controlled access.


| Service | Primary Role | Specific Tasks |
|---|---|---|
| Amplify Hosting | CI/CD + FE Hosting | Build & Deploy Next.js, domain management |
| Cognito | Authentication | Sign-up/Login, JWT issuance, refresh tokens |
| API Gateway | API Entry Point | Receive requests, validate JWT, route to Lambda |
| Lambda | Business Logic | Handle upload/approval, generate signed URLs, write metadata |
| S3 | Object Storage | Store original and approved files, served via CloudFront Signed URL |
| CloudFront | CDN | Fast content delivery, blocks direct S3 access via OAC |
| DynamoDB | Database | Store metadata (title, uploader, approval status) |
| Route 53 | DNS | Domain mapping to Amplify, API Gateway, CloudFront |
| CloudWatch | Monitoring | Lambda logs, anomaly alerts |
Simple search fields (titles, author) using DynamoDB GSIs.
uploads/.uploads/ → public/books/ upon approval.title and author (example: GSI1: PK=TITLE#{normalizedTitle}, SK=BOOK#{bookId}; GSI2: PK=AUTHOR#{normalizedAuthor}, SK=BOOK#{bookId}).GET /search?title=...&author=... to query GSI instead of Scan.
Admins group.cognito:groups: ["Admins"].approveBook, takedownBook) check this claim and return 403 Forbidden otherwise.PENDING), Admin approval logic.title, author, implement GET /search.Objective: Set up infrastructure and allow user login.
uploads, public, logs) + OAC.git push automatically deploys FE.Objective: Allow authenticated users to upload files and Admins to approve them.
createUploadUrl Lambda:
uploads/.PENDING).approveBook:
uploads/ → public/books/.APPROVED).PENDING, button “Approve”.Objective: Allow reading & searching approved books.
getReadUrl: generate Signed GET URL (short TTL).title, author.searchBooks.searchBooks.react-pdf).validateMimeType: read magic bytes to verify PDF/ePub.takedownBook (Admin), deleteUpload (auto cleanup after 72h).Budget comes from AWS Pricing Calculator.
Monthly cost (strict, no Free Tier, ~100 users): ≈ $9.80/month.
| # | AWS Service | Region | Monthly (USD) | Notes |
|---|---|---|---|---|
| 0 | Amazon CloudFront | Asia Pacific (Singapore) | 0.86 | 10 GB data egress + 10 000 HTTPS requests |
| 1 | AWS Amplify | Asia Pacific (Singapore) | 1.31 | 100 build min + 0.5 GB storage + 2 GB served |
| 2 | Amazon API Gateway | Asia Pacific (Singapore) | 0.01 | ~10 000 HTTP API calls/tháng |
| 3 | AWS Lambda | Asia Pacific (Singapore) | 0.00 | 128 MB RAM × 100 ms × 10 000 invokes |
| 4 | Amazon S3 (Standard) | Asia Pacific (Singapore) | 0.05 | 2 GB object storage for books/images |
| 5 | Data Transfer | Asia Pacific (Singapore) | 0.00 | Included in CloudFront cost |
| 6 | DynamoDB (On-Demand) | Asia Pacific (Singapore) | 0.03 | Light metadata table (0.1 GB, few reads/writes) |
| 7 | Amazon Cognito | Asia Pacific (Singapore) | 5.00 | 100 MAU, Advanced Security enabled |
| 8 | Amazon CloudWatch | Asia Pacific (Singapore) | 1.64 | 5 metrics + 0.1 GB logs/tháng |
| 9 | Amazon Route 53 | Asia Pacific (Singapore) | 0.90 | 1 Hosted Zone + DNS queries |
| ≈ 9.80 USD / month | No Free Tier applied |
This cost model demonstrates the efficiency of serverless architecture: costs are primarily centered on the value delivered to the user (Cognito MAU), rather than paying for ‘idle servers’.
| Risk | Impact | Mitigation |
|---|---|---|
| Cost spike due to sudden user growth | High | Limit MAU, cache metadata via CloudFront |
| Abuse of uploads | Medium | Limit ≤ 50MB; auto-delete after 72h |
| Fake/malicious file types | Medium | S3 Event → Lambda MIME validation |
| Monitoring overload | Low | CloudWatch alerts, 14-day retention |
uploads/ after 72h.file-type library) to verify correct PDF/ePub; if incorrect, automatically delete and write REJECTED_INVALID_TYPE status to DynamoDB.uploaderID, uploadTimestamp, adminApproverID, approvalTimestamp for traceability.TAKEDOWN; optionally move the object from public/books/ to quarantine/books/ (do not delete completely) to preserve traces.If costs exceed budget, enable Invite-Only mode to cap Cognito MAU and reduce load.
This system proves the ability to build a platform that securely, cost-effectively, and scalably easy by AWS Serverless services - that suitable to apply for small groups or communities.