This is a web application for a fictional bike store, built using the following technology stack:
- Framework - Next.js (App Router)
- Language - TypeScript
- Database - Postgres
- Storage - Blob
- Deployment - Vercel
- Styling - Tailwind CSS
- Components - Shadcn UI
This web application uses the new Next.js App Router. Including functionality to Create, Read, Update, and Delete bikes from the inventory as if you were the shop owner.
Follow these steps to set up this project on your own GitHub repository and deploy it on your own Vercel account.
- Git installed on your local machine
- A GitHub account
- A Vercel account
Start by cloning this project to your local machine:
git clone <repository-url>
cd <project-directory>
Replace <repository-url>
with the URL of this repository and <project-directory>
with the folder where you’d like to save the project files.
- Go to GitHub and log in.
- Create a new, blank repository on your account. Do not initialize it with a README or
.gitignore
file.
Now, link your local project to your new GitHub repository by updating the remote URL.
git remote set-url origin https://github.com/your-username/your-new-repository.git
Replace your-username
and your-new-repository
with your actual GitHub username and the name of the new repository.
Push the project files to your new GitHub repository:
git push -u origin main
This command sets main
as the default branch and uploads all files to your new repository.
- Go to the Vercel Dashboard and click Add New… > Project.
- Import your GitHub repository into Vercel.
- During the setup, ensure that you link the repository to the correct project on Vercel.
- Create a Postgres Database:
- Go to the Vercel Dashboard and navigate to the Storage section.
- Click Create Database and choose Postgres.
- Connect this database to your vercel project.
- Click Show secret in the Vercel Postgres Database Dashboard and find
POSTGRES_URL
environment variable in .env.local and copy it to your project.
- Create Database Table:
-
In the Vercel Postgres database dashboard, create the
products
table andstatus
type using the following SQL commands:CREATE TYPE status AS ENUM ('active', 'draft', 'archived'); CREATE TYPE type AS ENUM ('road bike', 'mountain bike', 'racing bike'); CREATE TABLE products ( id SERIAL PRIMARY KEY, name TEXT NOT NULL, description TEXT NOT NULL, rating NUMERIC(10, 2) NOT NULL, price NUMERIC(10, 2) NOT NULL, quantity INTEGER NOT NULL, type type NOT NULL, status status NOT NULL, image_url TEXT NOT NULL, available_at TIMESTAMP NOT NULL );
- Set Up Blob Storage:
- In the same Storage section, click Create Storage and select Blob Storage.
- Connect this storage to your vercel project.
- Click Show secret in the Vercel Blob Store Dashboard and find
BLOB_READ_WRITE_TOKEN
environment variable in .env.local and copy it to your project, enabling read/write access to the storage bucket.
To run the project locally, install dependencies and start the server:
pnpm install
pnpm dev
You should now be able to access the application at http://localhost:3000.
Uncomment app/api/seed.ts
in the project code, then navigate to http://localhost:3000/api/seed
to seed your database with initial product data.
Once your repository and storage setup are complete, deploy the project on Vercel:
- Go to your project in the Vercel Dashboard.
- Click on the Deploy button if the project has not been deployed automatically.
- Vercel will use the environment variables and configurations to deploy your project.
Once deployed, you will see a live URL for your web application. Any subsequent changes pushed to the main branch will automatically redeploy the project.
After setting up the repository and deploying on Vercel, you can continue developing and pushing changes to GitHub. To update the project on GitHub, use:
git add .
git commit -m "Your commit message"
git push origin main
Feel free to open issues or submit pull requests if you have suggestions for improvements!