A social media backend clone written in Go!
- User Authentication: Secure signup and login using JWTs and refresh tokens.
- Chirps: Create, read, and delete short text posts ("chirps").
- Sorting: Fetch chirps in ascending or descending order by creation time.
- Author Filtering: Retrieve all chirps from a specific user.
- Chirpy Red: A premium membership tier managed via webhooks.
- Admin Metrics: Track server hits and manage database resets (dev mode only).
- Language: Go (Golang)
- Database: PostgreSQL
- SQL Generator: sqlc
- Migrations: goose
- Router: Standard library
net/http
-
Clone the repository:
git clone https://github.com/ifeanyiBatman/chirpy.git cd chirpy -
Set up the environment: Create a
.envfile in the root directory with the following variables:DB_URL="postgres://postgres:postgres@localhost:5432/chirpy?sslmode=disable" PLATFORM="dev" JWT_SECRET="your-jwt-secret-key" POLKA_KEY="your-polka-api-key"
-
Run migrations:
goose postgres "postgres://postgres:postgres@localhost:5432/chirpy" up -
Run the server:
go run .The server works on
http://localhost:8080.
For detailed API documentation, including request bodies and headers, please see API.md.
GET /api/healthzGET /api/chirpsGET /api/chirps/{chirpID}POST /api/usersPOST /api/loginPOST /api/chirpsDELETE /api/chirps/{chirpID}PUT /api/usersPOST /api/refreshPOST /api/revokePOST /api/polka/webhooks