Git Product home page Git Product logo

vibranthive's Introduction

Vibranthive

Vibranthive is a modern blogging application inspired by platforms like Medium, designed to empower users to share their ideas and stories with the world.

Tech Stack

Frontend

  • React: A JavaScript library for building user interfaces, providing a flexible and efficient way to create dynamic web applications.
  • Zod: A TypeScript-first schema declaration and validation library, enabling robust type checking and validation of frontend data.
  • TypeScript: A statically typed superset of JavaScript that enhances code quality, maintainability, and developer productivity.
  • JWT (JSON Web Tokens): A standard for securely transmitting information between parties as a JSON object, commonly used for authentication in web applications.

Backend

  • 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
  • TypeScript: Leveraged for backend development as well, ensuring consistent type safety and code integrity across the entire application.
  • Prisma: A modern ORM (Object-Relational Mapping) tool that simplifies database access and manipulation, offering type-safe database queries and schema migrations. Prisma
  • PostgreSQL: A powerful open-source relational database management system, chosen for its reliability, scalability, and extensive feature set. Aiven

Getting Started

  1. Clone the repository:
git clone https://github.com/chandanck22/vibranthive.git
  1. Navigate to the project directory:
cd vibranthive
  1. Install dependencies for both the frontend and backend:
cd frontend
npm install
cd ../backend
npm install
  1. Create a .env and wrangler.toml file inside backend.

    • inside .env - Use AIVEN postgres database
    DATABASE_URL="PASTE DATABASE URL"
    

    Creating Connection Pool

    • Move to PRISMA site create a new Project. Click Enable Accelerate.
    • Under Database Connection String PASTE THE AIVEN DB URL created initially.
    • Click ENABLE ACCELERATE
    • Click Generate API KEY
    • A URL is generated paste inside wrangler.toml file

    It create a POOL url which we give to our backend not the orginal DB url. It help to connect to our database.

    name = "backend"
    compatibility_date = "2023-12-01"
    
    [vars]
    DATABASE_URL="PASTE the PRISMA URL (Connection Pool)"
    
    JWT_SECRET="mytoken"
    
  2. Start the backend server using Cloudflare Workers:

npm run dev
  1. Start the frontend development server:
npm run dev
  • NOTE If you make changes in the database i.e schema.prisma file you need to migrate using the follwing command to tell the database the the table you had added is been altered.
npx prisma migrate dev --name init_schema
  • It will generate migration folder inside prisma.
  • And then Generate the prisma client
npx prisma generate --no-engine

Access in your browser at http://localhost:3000.

To Deploy

npx wrangler whoami
npx wrangler login
npm run deploy

cloudflare worker not take environment variable from .env file it takes from wrangle.toml file

  • This code snippet demonstrates the usage of Cloudflare Workers and the need for a connection pool when connecting to a database.
  • Cloudflare Workers create multiple instances distributed throughout the world. When deploying the code, each instance connects to the database, which can be inefficient and potentially overload the database.
  • To address this issue, it is recommended to use a connection pool. In this code, the prisma library is used for managing the connection pool and connecting to the database.

vibranthive's People

Contributors

chandanck22 avatar

Stargazers

 avatar Dinesh Kumar avatar

Watchers

 avatar

Forkers

rahulbhardwaj01

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.