How dan1el-19/chmura-blokserwis works
Project type and purpose
• This is a full-stack, cloud-native file-management web platform built with Next.js (App Router) for the frontend and serverless API routes for the backend.
• It uses Firebase Authentication for identity, Cloudflare R2 for object storage (S3-compatible), and role-based access control (basic, plus, admin).
Main architectural components
a. Client (Web / PWA)
• Next.js React pages & components (src/app, src/components)
• Service Worker (public/sw.js), PWA manifest (public/manifest.json)
b. Next.js Serverless Layer
• UI rendering: SSR/SSG via Next.js App Router
• API Routes (src/app/api/*) handling file operations, user profile, admin endpoints
• Middleware (src/middleware.ts) for auth checks, rate limiting
c. Authentication & Authorization
• Firebase Authentication (Google, email/password)
• JWT validation on each API route via Firebase Admin SDK (src/lib/firebaseAdmin.ts)
• Role enforcement in API handlers
d. Object Storage
• Cloudflare R2 bucket (via AWS-S3 compatible SDK in src/lib/storage.ts)
• Multipart upload workflow (src/lib/multipartUpload*, scripts/*.mjs)
e. Data & Logging
• Activity logs (could be stored in R2 or Firebase/Firestore – adjust if needed)
• Storage and usage statistics gathered by API
f. Admin Panel
• Next.js pages under src/app/admin-panel for user management and logs
• Admin API under src/app/api/admin/*
Relationships & interactions
1. User (Browser) → Next.js UI
• Navigates to login, storage, file preview, admin pages
2. UI ↔ Next.js Serverless API
• API calls: /api/auth/*, /api/files/*, /api/user/profile, /api/admin/*
• Requests carry Firebase JWT in headers
3. API → Firebase Auth
• Validates incoming JWT, resolves user identity & role
4. API → Cloudflare R2
• Executes file operations (upload, download, delete, presign URLs)
• Manages multipart uploads and bucket operations
5. API → (Optional) Logging/Analytics store
• Persistence of usage stats, upload analytics, queue logs
6. Admin API → User DB / Logs
• CRUD operations on users, password resets, roles
Architectural patterns & principles
• Serverless API per feature (each route in its own folder)
• Separation of concerns: UI vs API vs storage vs auth
• Role-based access control enforced at the API edge
• Modular lib layer for cross-cutting concerns (auth, storage, notifications, rate-limit)
• Scripts folder for maintenance tasks (e.g., abort-multipart, set-admin)
Essential details to capture
• All API route groups and their domain responsibilities
• The multipart upload workflow (scripts + lib) interacting with R2
• Middleware/pass-through for JWT & RBAC
• PWA features (offline.html, sw.js) connecting back to API