Ranchi --:-- ISTRecruiter

Blogity

Blogging platform where writers sign in and publish posts with images, and readers can subscribe to a newsletter.

Year
2024
Role
Full-stack developer
Status
Live
Stack
Next.js, NextAuth, Prisma, PostgreSQL, UploadThing, Tailwind CSS
blogity-ten.vercel.app
Blogity screenshot 1 of 2
Screenshot 1 of 2

Overview

Problem

Writers wanted a clean place to publish without setting up and maintaining a full CMS.

What I built

A Next.js app with NextAuth sign-in, posts and categories in PostgreSQL through Prisma, image uploads through UploadThing, and newsletter sign-ups sent to Beehiiv from an API route. A post and its author load in one Prisma query.

What I learned

Using Next.js route handlers as the whole backend, and keeping a 404 for a missing post separate from real server errors.

What's next

Planned: markdown support, scheduled publishing and comment notifications.

Features

What the product does today.

01
AccountsSign-in with NextAuth
02
Writer dashboardEach writer manages their own posts
03
Image uploadsUploaded with each post through UploadThing
04
NewsletterReaders subscribe through Beehiiv

Architecture

How a request moves through the stack. Hover or tap a layer.

ClientNext.jsTailwind CSSServerNextAuthDataPrismaPostgreSQLServicesUploadThing

Each box is one layer of the app.

Request playgroundOpen a blog post
  1. 01ClientA reader opens a post. The page requests GET /api/posts/:id.
  2. 02ServerThe route handler parses the id from the URL.
  3. 03DataPrisma loads the post and its author in one query.
  4. 04ClientThe route answers 200 with the post, or 404 if it does not exist.

Traced from app/api/posts/[id]/route.ts ↗

Live metrics

Pulled from GitHub, a request to the live site and Google Lighthouse. Refreshed automatically.

Repositoryblogity ↗TypeScript
Last push23 months ago10 Jan 2025
Created19 Dec 2024
Forks · stars0 · 0
Live siteUp · HTTP 200Loaded in 0.60 s
Lighthouse · mobile

Being measured now. Scores appear on the next visit.

Code

Excerpts from this project's repo, with notes.

route.tsblogity › app › api › posts › [id] › route.ts
4export async function GET(request: NextRequest): Promise<Response> {5  const id = Number(request.url.split("/").pop());6 7  try {8    const post = await prisma.post.findUnique({9      where: { id },10      include: {11        author: true,12      },13    });14 15    if (!post) {16      return new Response(JSON.stringify({ error: "Post not found" }), {17        status: 404,18        headers: { "Content-Type": "application/json" },19      });20    }21 22    return new Response(JSON.stringify(post), {23      status: 200,24      headers: { "Content-Type": "application/json" },25    });26  } catch (error) {27    console.error("Error fetching post:", error);28    return new Response(JSON.stringify({ error: "Internal Server Error" }), {29      status: 500,30      headers: { "Content-Type": "application/json" },31    });32  }33}
TypeScriptLn 4, Col 1UTF-82 notes

Links

See it running or read the code.

Next projectGDG Recruitment PlatformRecruitment system for GDG on Campus HIT. Applicants apply through one form, recruiters track every application, and admins promote the people they select to team members.