{"id":26269443,"url":"https://github.com/codecanuj/draftly","last_synced_at":"2026-04-11T18:02:26.528Z","repository":{"id":282220151,"uuid":"944657435","full_name":"CodecAnuj/draftly","owner":"CodecAnuj","description":"Blog App","archived":false,"fork":false,"pushed_at":"2025-03-13T16:09:45.000Z","size":85,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T17:32:20.407Z","etag":null,"topics":["cloudflare","hono","postgresql","prisma","reactjs","typescript","zod"],"latest_commit_sha":null,"homepage":"https://draftly-beige.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodecAnuj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-07T18:27:55.000Z","updated_at":"2025-03-13T16:56:43.000Z","dependencies_parsed_at":"2025-03-13T17:32:28.874Z","dependency_job_id":"1312eba4-4ca3-4d84-a80c-ac68c92323f2","html_url":"https://github.com/CodecAnuj/draftly","commit_stats":null,"previous_names":["codecanuj/medium_project","codecanuj/draftly"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodecAnuj%2Fdraftly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodecAnuj%2Fdraftly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodecAnuj%2Fdraftly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodecAnuj%2Fdraftly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodecAnuj","download_url":"https://codeload.github.com/CodecAnuj/draftly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243526941,"owners_count":20305115,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare","hono","postgresql","prisma","reactjs","typescript","zod"],"created_at":"2025-03-14T05:14:13.852Z","updated_at":"2026-04-11T18:02:21.488Z","avatar_url":"https://github.com/CodecAnuj.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Draftly\nDraftly is a modern blogging application inspired by platforms like Medium, designed to empower users to share their ideas and stories with the world.\n\n## Tech Stack\n### Frontend\n- **React**: A JavaScript library for building user interfaces, providing a flexible and efficient way to create dynamic web applications.\n- **Zod**: A TypeScript-first schema declaration and validation library, enabling robust type checking and validation of frontend data.\n- **TypeScript**: A statically typed superset of JavaScript that enhances code quality, maintainability, and developer productivity.\n- **JWT (JSON Web Tokens)**: A standard for securely transmitting information between parties as a JSON object, commonly used for authentication in web applications.\n\n### Backend\n- **Cloudflare Workers**: A serverless execution environment that allows you to run JavaScript code at the edge of the Cloudflare network, providing scalable and efficient backend logic. [Hono](https://hono.dev/top)\n- **TypeScript**: Leveraged for backend development as well, ensuring consistent type safety and code integrity across the entire application.\n- **Prisma**: A modern ORM (Object-Relational Mapping) tool that simplifies database access and manipulation, offering type-safe database queries and schema migrations. [Prisma](https://www.prisma.io/)\n- **PostgreSQL**: A powerful open-source relational database management system, chosen for its reliability, scalability, and extensive feature set. [Aiven](https://aiven.io/)\n\n## Getting Started\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/CodecAnuj/draftly.git\n```\n2. Navigate to the project directory:\n```bash\ncd draftly\n```\n3. Install dependencies for both the frontend and backend using Bun:\n```bash\ncd frontend\nbun install\n```\n```bash\ncd ../backend\nbun install\n```\n4. Create a `.env` file inside `frontend` and `backend`.\n\n   - Inside **frontend** `.env`:\n    ```env\n    VITE_BACKEND_URL=\"YOUR_BACKEND_URL_HERE\"\n    ```\n    **Note:** Replace `YOUR_BACKEND_URL_HERE` with the actual backend URL when deploying.\n\n   - Inside **backend** `.env`:\n    ```env\n    DATABASE_URL=\"PASTE DATABASE URL\"\n    JWT_SECRET=\"prod_mysecret\"\n    ```\n    \n    #### Creating Connection Pool\n    - Move to [PRISMA](https://www.prisma.io/data-platform/accelerate) site, create a new Project, and click Enable Accelerate.\n    - Under Database Connection String, paste the **Aiven** DB URL created initially.\n    - Click ENABLE ACCELERATE, then Generate API KEY.\n    - A URL is generated, which will be used inside the `wrangler.jsonc` file.\n\n5. Create a `wrangler.jsonc` file inside `backend` and configure Cloudflare Workers:\n    ```jsonc\n    {\n      \"name\": \"backend\",\n      \"compatibility_date\": \"2025-03-04\",\n      \"vars\": {\n        \"DATABASE_URL\": \"PASTE the PRISMA URL (Connection Pool)\",\n        \"JWT_SECRET\": \"prod_mysecret\"\n      }\n    }\n    ```\n\n6. Start the `backend` server using Cloudflare Workers:\n```bash\nbun run dev\n```\n7. Start the `frontend` development server:\n```bash\nbun run dev\n```\n\n- **NOTE** If you make changes in the database (i.e., `schema.prisma` file), you need to migrate using the following command:\n```bash\nbunx prisma migrate dev --name init_schema\n```\n- It will generate a migration folder inside `prisma`.\n- Then generate the Prisma client:\n```bash\nbunx prisma generate --no-engine\n```\n\nAccess the project in your browser at http://localhost:3000.\n\n### To Deploy\n\n```bash\nbunx wrangler whoami\n```\n```bash\nbunx wrangler login\n```\n```bash\nbun run deploy\n```\n\n\u003e Cloudflare Workers do not take environment variables from `.env` files; they take them from `wrangler.jsonc`.\n\n\u003e - This project demonstrates the usage of Cloudflare Workers and the need for a connection pool when connecting to a database.\n\u003e - Cloudflare Workers create multiple instances worldwide. Each instance connects to the database, which can be inefficient.\n\u003e - To resolve this, a connection pool is used via Prisma, which helps efficiently manage database connections.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecanuj%2Fdraftly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodecanuj%2Fdraftly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecanuj%2Fdraftly/lists"}