Skip to content
/ chirpy Public

A lightweight, scalable CRUD (Create, Read, Update, Delete) webserver designed to mimic core functionalities of Twitter.

Notifications You must be signed in to change notification settings

tsyrdev/chirpy

Repository files navigation

Chirpy: A CRUD Web Server That Simulates a Twitter-Like Experience

License: MIT

Overview

The Chirpy app is a Twitter-like server that connects to a PostgreSQL database. The web server is written in Go. It is a lighweight and efficient server that uses Go's standard net/http library to handle requests with ease. It was designed for handling RESTful API requests, and managing user data. It leverages PostgreSQL as the backend database to ensure robust and reliable data storage. The interface between the two is generated using SQLC.

How to Install and Run

Prerequisites

  • Go must be installed (download it from golang.org.
  • Ensure your $GOPATH/bin is in your sytem's PATH.
  • PostgreSQL must be installed (download it using your preferred package manager)
  • Run all the migrations in your database (Goose makes this extremely easy).

Option 1: Install the Binary (Recommended)

Run the following command to install the binary globally:

go install github.com/tsyrdev/chirpy

Once installed, you can run the server using chirpy

Option 2: Build from Source

  1. Clone the repo:
git clone https://github.com/tsyrdev/chirpy.git
cd chirpy
  1. Build the project:
go build -o chirpy 
  1. Run the tool locally:
./chirpy
  1. If you want to run it globally, move the binary to your $GOPATH/bin:
mv chirpy ~/go/bin

How to use it

The chirpy server exposes the following endpoints for users to connect to:

  • POST /admin/reset - Resets the users in the database.
  • GET /api/healthz - Returns the status of the server.
  • POST /api/users - Creates a new user.
  • POST /api/chirps - Creates a new chirp.
  • GET /api/chirps - Gets all the chirps in the database.
  • GET /api/chirps/{chirpID} - Gets the specified chirp.
  • DELETE /api/chirps/{chirpID} - Deletes the specified chirp.
  • POST /api/login - Logs into a user account.
  • POST /api/revoke - Revokes a user's access token.
  • PUT /api/users - Updates a user's credentials.
  • POST /api/polka/webhooks - Third-party connection for users to upgrade their membership.

Credits

This project is from a Go Servers tutorial on boot.dev

License

This project is licensed under the MIT License

About

A lightweight, scalable CRUD (Create, Read, Update, Delete) webserver designed to mimic core functionalities of Twitter.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published