A modern blogging platform where ideas find their home. Built with Cloudflare Workers backend and React frontend.
- π JWT Authentication with Bcrypt hashing
- βοΈ CRUD Operations for Blog Posts
- πΌοΈ Image Uploads with Cloudflare R2 Storage
- π‘οΈ Zod Validation for all endpoints
- ποΈ Prisma ORM with PostgreSQL
- π Rich Text Editor (React Quill)
- β¨ Beautiful UI with shadcn components
- π Real-time updates
- π Light/Dark mode
- π± Fully responsive design
Backend:
- Hono.js
- Cloudflare Workers
- TypeScript
- Prisma
- PostgreSQL
- Zod
- JWT + Bcrypt
- R2 Storage
Frontend:
- React 18
- tanstack-query
- TypeScript
- Tailwind CSS
- shadcn/ui
- React Quill
- React Router
- Node.js v18+
- npm/pnpm/yarn
- Cloudflare account
- PostgreSQL database
- Clone the repository:
git clone https://github.com/riazahmedshah/wordnest.git
cd wordnest- Install dependencies:
# Install backend dependencies
cd backend
npm install
# Install frontend dependencies
cd ../frontend
npm install- Set up environment variables:
Backend (.env):
DATABASE_URL="your-postgresql-connection-string"Backend (.dev.vars):
JWT_SECRET="your-jwt-secret-key"
CLOUDFLARE_ACCOUNT_ID="your-cloudflare-account-id"
CLOUDFLARE_ACCESS_KEY_ID="your-r2-access-key"
CLOUDFLARE_SECRET_ACCESS_KEY="your-r2-secret-key"
R2_BUCKET_NAME="your-r2-bucket-name"Frontend (.env):
VITE_API_URL="https://your-worker-subdomain.your-subdomain.workers.dev"- Set up the database:
cd backend
npx prisma generate
npx prisma db push- Deploy the backend to Cloudflare Workers:
cd backend
npm run deploy- Start the frontend development server:
cd frontend
npm run dev- Install Wrangler CLI:
npm install -g wrangler- Login to Cloudflare:
wrangler login- Update
wrangler.tomlwith your configuration:
name = "wordnest-backend"
main = "src/index.ts"
compatibility_date = "2023-12-01"
[env.production]
vars = { ENVIRONMENT = "production" }The application uses the following main entities:
- User: Authentication and user management
- Post: Blog posts with rich content
- Category: Post categorization
- Comment: User comments on posts [future..]
POST /api/v1/user/register- User registrationPOST /api/v1/user/login- User loginGET /api/v1/user/me- Get current user
GET /api/v1/blog/bulk- Get all postsGET /api/v1/blog/:id- Get specific postPOST /api/v1/blog/create- Create new postPUT /api/v1/blog/:id- Update postDELETE /api/v1/blog/:id- Delete post
/api/v1/user/update- Upload images to R2 storage
The frontend uses shadcn/ui components for a consistent design system:
- Button: Primary and secondary actions
- Card: Content containers
- Input: Form inputs
- Textarea: Multi-line text input
- Dialog: Modal dialogs
- Toast: Notification messages
- User registers/logs in
- JWT token is generated and stored
- Token is included in API requests
- Middleware validates token on protected routes
- User session is maintained client-side
Images are uploaded to Cloudflare R2 storage:
- User selects image in editor
- Image is uploaded to
/api/v1/user/updateendpoint with other update details, also - Image is uploaded to
/api/v1/blog/createendpoint with other fields - File is stored in R2 bucket
- Public URL is returned
- URL is embedded in post content
cd backend
npm run deploycd frontend
npm run build
# Upload dist folder to Cloudflare Pages- Register/Login: Create an account or sign in
- Create Post: Use the rich text editor to write posts
- Add Images: Upload images directly in the editor
- Publish: Share your posts with the community
| Variable | Description | Required |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | β |
JWT_SECRET |
Secret key for JWT tokens | β |
CLOUDFLARE_ACCOUNT_ID |
Cloudflare account ID | β |
CLOUDFLARE_ACCESS_KEY_ID |
R2 access key ID | β |
CLOUDFLARE_SECRET_ACCESS_KEY |
R2 secret access key | β |
R2_BUCKET_NAME |
R2 bucket name for images | β |
| Variable | Description | Required |
|---|---|---|
VITE_API_URL |
Backend API URL | β |
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Pagination** (DONE β )
- Statefull -> RBA Auth(Admin/user)
- oauth(google).
- Admin panel
- list all users.
- list all blogs and blogs of users
- Delete user/blog
- Image optimization.
- Tanstack query optimization.
If you have any questions or need help with setup, please:
- Create a new issue if your problem isn't already reported
- Contact: riyazsh360@example.com
Built with β€οΈ by Riaz Ahmed Shah