How bt2701/facebook-be-v2 works
Facebook Backend V2 is a Kong-fronted Go microservice backend for a social platform. A typical request enters through the gateway and a service’s inbound adapter, passes through its application layer, and reaches a repository. Product workflows include account/authentication, posts and interactions, friendships, messaging, media, notifications, games, and an AI chatbox. The README documents Redis events from friend and post actions to notification persistence, and friend suggestions calling user-service. Most service internals were not sampled; their links follow the documented adapter pattern, while uncertain cross-service wiring is omitted.
Main entry points: app/service Friend services · app/service Post services · ai_service.go AI service · inbound User API
Components 34
Accounts and friends
- User API
user-service/internal/adapters/inbound - User service
user-service/internal/app/services - User repository
user-service/internal/adapters/outbound/user_repository.go - User database
user-service/pkg/database/db.go - Friend APIs
friend-service/internal/adapters/inbound - Friend services
friend-service/internal/app/service - Friend repositories
friend-service/internal/adapters/outbound - Friend database
friend-service/pkg/database/mongodb.go
Social content
- Post APIs
post-service/internal/adapters/inbound - Post services
post-service/internal/app/service - Post repositories
post-service/internal/adapters/outbound - Post database
post-service/pkg/database/mongodb.go - Notification API
notification-service/internal/adapters/inbound/notification_handler.go - Notification service
notification-service/internal/app/services/notification_service.go - Notification repository
notification-service/internal/adapters/outbound/notification_repository.go - Notification database
notification-service/pkg/database/mongodb.go
Messaging and AI
- Chat APIs
chat-service/internal/adapters/in - Chat service
chat-service/internal/app/service/chat_service.go - Message repository
chat-service/internal/adapters/out/db_message_repository.go - Chat database
chat-service/pkg/database/mongodb.go - AI chat API
ai-service/internal/adapters/inbound/ai_handler.go - AI service
ai-service/internal/app/service/ai_service.go - Conversation storage
ai-service/internal/adapters/outbound/conversation_repository.go - AI database
ai-service/pkg/database/mongodb.go - LLM provider
Media and games
- Image API
media-service/internal/adapters/inbound/image_handler.go - Image service
media-service/internal/app/services/image_service.go - Image repository
media-service/internal/adapters/outbound/image_repository.go - Media database
media-service/pkg/database/db.go - Game APIs
game-service/internal/adapters/inbound - Game services
game-service/internal/app/service
Events and gateway
- Kong gateway
- Redis events
shared/events/bus.go
Other components
- Frontend client
Connections 36
- Frontend client → Kong gateway: sends requests
- Kong gateway → User API: routes requests
- Kong gateway → Friend APIs: routes requests
- Kong gateway → Post APIs: routes requests
- Kong gateway → Notification API: routes requests
- Kong gateway → Chat APIs: routes requests
- Kong gateway → AI chat API: routes requests
- Kong gateway → Image API: routes requests
- Kong gateway → Game APIs: routes requests
- User API → User service: invokes
- User service → User repository: calls
- User repository → User database: reads/writes
- Friend APIs → Friend services: invokes
- Friend services → Friend repositories: calls
- Friend repositories → Friend database: reads/writes
- Friend services → User API: fetches suggestions
- Post APIs → Post services: invokes
- Post services → Post repositories: calls
- Post repositories → Post database: reads/writes
- Notification API → Notification service: invokes
- Notification service → Notification repository: calls
- Notification repository → Notification database: reads/writes
- Friend services → Redis events: publishes actions
- Post services → Redis events: publishes actions
- Redis events → Notification service: delivers events
- Chat APIs → Chat service: invokes
- Chat service → Message repository: calls
- Message repository → Chat database: reads/writes
- AI chat API → AI service: invokes
- AI service → Conversation storage: calls
- Conversation storage → AI database: reads/writes
- AI service → LLM provider: requests completion
- Image API → Image service: invokes
- Image service → Image repository: calls
- Image repository → Media database: reads/writes
- Game APIs → Game services: invokes