The Shortener Project is a URL shortener application that allows users to generate shortened links for long URLs. Built with modern web technologies, this project demonstrates full-stack development using:
- Generate shortened URLs
- Track usage statistics for shortened links
- Responsive design for mobile and desktop
- Easy deployment with Vercel
Follow the steps below to clone, install, and run the project locally.
- Node.js (v18 or later recommended)
- npm or yarn
- A Prisma-supported database (SQLite for development, PostgreSQL for production)
-
Clone the repository:
git clone https://github.com/AlexCode04/Shortener.git cd shortener-project -
Install dependencies:
npm install # or yarn install -
Set up environment variables: Create a
.envfile in the root directory and add the following:DATABASE_URL="<provider>://<username>:<password>@localhost:<port>/<database>
Replace
your-database-connection-urlwith the connection string for your Prisma database andyour-next-auth-secretwith a random secret key. -
Initialize Prisma:
npx prisma init npx prisma migrate dev --name init
This creates the database schema and applies the initial migration.
-
Seed the database (optional): If your
prisma/seed.jsfile exists, you can run:npx prisma db seed
Start the development server:
npm run dev
# or
yarn devThe application will be available at http://localhost:3000.
-
Install Prisma CLI: If Prisma is not already installed globally:
npm install prisma --save-dev
-
Schema Configuration: Open
prisma/schema.prismaand customize your database settings. Example for SQLite:generator client { provider = "prisma-client-js" } datasource db { provider = "mysql" url = env("DATABASE_URL") } model link { id String @id @default(cuid()) url String @unique shortUrl String @unique createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }
-
Generate Prisma Client:
npx prisma generate
-
Run Migrations: Apply schema changes with:
npx prisma migrate dev
The project is configured to be deployed on Vercel.
- Push your code to a GitHub repository.
- Import the repository into Vercel.
- Set up environment variables in the Vercel dashboard.
- Deploy the project with a single click.
- React.js
- Tailwind CSS
- Next.js
- Prisma ORM
- Mysql (development and production)
Contributions are welcome! Please fork the repository, make changes, and submit a pull request.
This project is licensed under the MIT License.
