GoSocial is a lightweight, modular social networking backend built with Go, featuring:
- 🚀 RESTful API with Swagger documentation
 - ⚙️ Chi router for clean, fast routing
 - 🧠 Redis caching for performance
 - 🗄️ PostgreSQL (via Docker) for reliable data persistence
 - 📨 Email verification system
 - 🧩 Graceful shutdown and structured logging
 - ☁️ Deployable to Google App Engine (GAE)
 
✅ User Management
- Register, login, activate accounts via email
 - JWT-based authentication and authorization
 
✅ Post Management
- Create, update, and delete posts
 - Support for tags and versioning
 
✅ Comments
- Add comments to posts
 - Retrieve comments for a post
 
✅ Feeds
- 
View personalized feed:
- Your own posts
 - Posts from users you follow
 
 
✅ Follow System
- Follow or unfollow other users
 - Feed updates automatically reflect follow relationships
 
✅ Caching
- Frequently accessed posts and feeds cached in Redis
 
✅ Swagger API Docs
- Auto-generated via 
swaggo/swag - Viewable in the browser at 
api/v1/swagger/ 
| Component | Technology | 
|---|---|
| Language | Go (v1.23+) | 
| Web Framework | Chi Router | 
| Database | PostgreSQL (via Docker) | 
| Cache | Redis | 
| Documentation | Swagger (swaggo/swag) | 
| Logging | Uber Zap | 
| Deployment | Google App Engine | 
| CI/CD | GitHub Actions (optional) | 
Before running the application, export the following environment variables:
export PORT=8080
export SOCIAL_NETWORK_DB_DSN=postgres://admin:admin123@localhost/socialnetwork?sslmode=disable
export DB_MAX_OPEN_CONNS=30
export DB_MAX_IDLE_CONNS=30
export DB_MAX_IDLE_TIME=15m
export EXTERNAL_URL=localhost:8080
export ENV=development
# smtp Config (replace SMTP credentials)
export [email protected]
export SMTP_PORT=2525
export SMTP_HOST=sandbox.smtp.mailtrap.io
export USERNAME=your_mailtrap_username
export PASSWORD=your_mailtrap_password
# jwt Config
export AUTH_TOKEN_SECRET=supersecretkey
export AUD=social
export ISS=social
export EXP=3💡 Remember to replace the SMTP credentials and email with your own before running.
If you don’t have PostgreSQL installed locally, you can spin it up easily with Docker:
docker run --name social-postgres \
  -e POSTGRES_USER=admin \
  -e POSTGRES_PASSWORD=admin123 \
  -e POSTGRES_DB=socialnetwork \
  -p 5432:5432 \
  -d postgres:16Once it’s running, verify the connection:
psql postgres://admin:admin123@localhost:5432/socialnetworkThen run your migrations (if applicable) or let your app auto-migrate on startup.
For caching (if Redis is not already running):
docker run --name social-redis -p 6379:6379 -d redis:7Swagger docs are automatically generated from your Go annotations.
- View in browser: 👉 http://localhost:8080/api/v1/swagger/
 
To regenerate docs after changes:
make gen/docsYou can deploy this app to Google App Engine Standard or Flexible Environment.
Example app.yaml:
runtime: go123
env: standard
entrypoint: ./server
env_variables:
  PORT: 8080
  SOCIAL_NETWORK_DB_DSN: postgres://admin:admin123@/cloudsql/YOUR_INSTANCE_CONNECTION_NAME/socialnetwork
  AUTH_TOKEN_SECRET: supersecretkey
  ENV: productionThen deploy:
gcloud app deployThis project is licensed under the MIT License