BlogApp is a full-stack web application designed for creating and managing blog posts. It provides users with an intuitive interface to write and view posts while showcasing dynamic features like server-side rendering and a modern user experience.
- Create and view blog posts
- Comment on blog posts
- Responsive and clean UI for a seamless user experience
- Integrated database for storing blog posts
- Google Login with OAuth for user authentication
- Server-side rendering for optimal performance
- Next.js: React framework for server-side rendering and static site generation
- Prisma: Next-generation ORM for database interaction
- PostgreSQL: Relational database for structured data
- Tailwind CSS: Utility-first CSS framework for styling
- NextAuth.js: Authentication library for handling OAuth
- TypeScript: Typed JavaScript for enhanced code reliability
Follow these steps to set up and run BlogApp locally on your machine.
Make sure you have the following installed on your system:
- Node.js (version 16 or higher recommended)
- PostgreSQL (Ensure you have a running database)
- Git
-
Clone the repository:
git clone https://github.com/marinactonci/BlogApp.git cd BlogApp -
Install dependencies:
npm install
-
Set up environment variables:
DATABASE_URL=postgresql://<username>:<password>@localhost:5432/<your-database-name> GOOGLE_CLIENT_ID=<your-google-client-id> GOOGLE_CLIENT_SECRET=<your-google-client-secret> NEXTAUTH_URL=http://localhost:3000 NEXTAUTH_SECRET=<your-generated-secret>
- Replace
<your-google-client-id>and<your-google-client-secret>with your actual Google OAuth credentials (see below how to obtain them). - Generate the
NEXTAUTH_SECRETby running the following command:
openssl rand -base64 32
- Replace
- Go to the Google Developer Console and create a new project or select an existing one.
- Navigate to APIs & Services > Credentials and click on Create Credentials > Oauth client ID.
- Select Web Application as the application type.
- Add the following to the Authorized redirect URIs:
http://localhost:3000/api/auth/callback/google. - Download the client ID and client secret, and save them in the
.envfile asGOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET, respectively.
-
Initialize Prisma: If not already initialized, generate the Prisma schema:
npx prisma init
-
Migrate Database: Apply migrations to create the database tables:
npx prisma migrate dev
-
Seed the Database: Populate the database with initial data:
npx ts-node prisma/seed.ts
-
View the database using Prisma Studio:
npx prisma studio
- Start the development server:
npm run dev- Open your browser and navigate to http://localhost:3000.