Hein Lin Zaw, home
All projects
Project 03 / 032025

Yaycha API

A REST API for a small social feed, with JWT authentication, password hashing, Prisma models, seed data, and relational posts and comments.

Year
2025
Role
API design & data modeling
Stack

Yaycha is a REST API for a small social application. Users can register, log in, create posts, and comment on other people’s posts. I built it to practice the parts of a backend that sit outside the happy path: authentication, relational data, validation, and graceful failure.

The data model

There are three Prisma models:

  • User — a unique name and username, an optional bio, a hashed password, and relations to posts and comments.
  • Post — text content, an author, and a list of comments.
  • Comment — text content, an author, and the post it belongs to.

The relations are the core of the project. Deleting or querying a post requires thinking about its comments and its author, and the schema makes those connections explicit.

Authentication and API surface

The API uses Express with cors, JSON body parsing, and two routers: one for content and one for users.

Registration hashes passwords with bcrypt. Login returns a JWT, which is used to identify the user on protected routes. The API also includes seed scripts built with Faker so the database can be populated with realistic users, posts, and comments during development.

The server handles SIGINT and SIGTERM by disconnecting Prisma and closing the HTTP server, which avoids leaving database connections open during development.

What was hard

  • Designing the Prisma schema so posts and comments could be queried without excessive nesting.
  • Getting the seed order right: users first, then posts, then comments.
  • Keeping authentication concerns separate from the content routes.
  • Handling errors consistently instead of returning a different shape from every endpoint.

The project also made me appreciate how much a good ORM does. Prisma’s generated client and migrations removed a lot of repetitive SQL, but I still had to understand the relations to use it well.

What I’d do next

  • Add request validation with Zod and a consistent error format.
  • Write integration tests for the auth and content routes.
  • Document the endpoints with OpenAPI.
  • Add refresh tokens, pagination, and a proper role model.
  • Move from SQLite to PostgreSQL and containerize the development environment.

Building it gave me a useful mental model for how a backend is layered: routes, auth, data access, and the database underneath.