Chirpy allows users to create short text posts ("chirps"), manage accounts, and interact with a clean RESTful API.
- User Management: Registration, login, and profile updates with JWT authentication
- Chirp Posts: Create, read, and delete short messages (max 140 characters)
- Profanity Filtering: Automatic content moderation for chirps
- JWT Authentication: Secure token-based authentication with refresh tokens
- Premium Memberships: Chirpy Red subscription support via webhooks
- PostgreSQL Database: Type-safe queries using SQLc
- Database Migrations: Version-controlled schema changes with Goose
- Language: Go 1.24.5
- Database: PostgreSQL
- Authentication: JWT tokens with Argon2id password hashing
- Code Generation: SQLc for type-safe database queries
- Key Libraries:
github.com/golang-jwt/jwt/v5- JWT implementationgithub.com/alexedwards/argon2id- Password hashinggithub.com/lib/pq- PostgreSQL drivergithub.com/google/uuid- UUID generation
- Go 1.24.5 or higher
- PostgreSQL
- Goose for migrations
- SQLc for code generation (optional, code is pre-generated)
- Clone the repository:
git clone https://github.com/grainme/Chirpy.git
cd Chirpy- Install dependencies:
go mod download- Set up environment variables (create a
.envfile):
DB_URL=postgres://username:password@localhost:5432/chirpy?sslmode=disable
JWT_SecretToken=your-secret-key-here
PLATFORM=dev
POLKA_KEY=your-polka-api-key- Run database migrations:
make migrate-up- Start the server:
go run main.goThe server will start on http://localhost:8080
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/healthz |
Health check |
| GET | /admin/metrics |
View metrics |
| POST | /admin/reset |
Reset database (dev only) |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/users |
No | Create new user |
| PUT | /api/users |
JWT | Update user email/password |
| POST | /api/login |
No | Login and receive JWT + refresh token |
| POST | /api/refresh |
Refresh Token | Get new JWT token |
| POST | /api/revoke |
Refresh Token | Revoke refresh token |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/chirps |
JWT | Create a new chirp |
| GET | /api/chirps |
No | Get all chirps (supports ?author_id=UUID&sort=desc/asc) |
| GET | /api/chirps/{chirpID} |
No | Get specific chirp |
| DELETE | /api/chirps/{chirpID} |
JWT | Delete chirp (owner only) |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/polka/webhooks |
API Key | Upgrade user to Chirpy Red |
Chirps are automatically filtered for profanity. The following words are replaced with asterisks:
- kerfuffle
- sharbert
- fornax
- Maximum body length: 140 characters
- Users can only delete their own chirps
- Chirps are linked to users via foreign key with cascade delete
Users can be upgraded to "Chirpy Red" premium status via the Polka webhook integration.
Built as part of learning Go and RESTful API design.