- Anup Sedhain (UF ID - 92896347)
- Dinank Bista (UF ID - 41975568)
This project implements a distributed Reddit-like platform combining two key architectural components:
- A REST API interface for client-server communication
- An Actor-based backend system using Proto.Actor framework in Go
The system enables users to create communities (subreddits), share content, and interact through comments and votes, all while maintaining data consistency across concurrent operations.
The backend is built on several specialized actors:
- EngineActor // Coordinates system operations
- PostActor // Manages posts and voting
- SubredditActor // Handles subreddit operations
- CommentActor // Manages comments and replies
- UserActor // Handles user operations
The system exposes RESTful endpoints that follow Reddit-like API patterns:
Authentication:
- POST /register
- POST /login
Content:
- POST /post
- GET /post/:postId
- POST /comment
- GET /feed
Communities:
- POST /subreddit
- GET /subreddits
- POST /subreddit/:name/join
type PostActor struct {
posts map[string]*messages.Post // PostId -> Post
subredditPosts map[string][]string // SubredditName -> []PostId
votes map[string]map[string]bool // PostId -> UserId -> IsUpvote
}type UserActor struct {
karma map[string]int // UserId -> Karma
joinedSubreddits map[string][]string // UserId -> []SubredditName
}-
Registration
- Username/password validation
- Account creation
- Initial state setup
-
Login
- Credential verification
- JWT token generation
- Session management
-
Post Creation
- Authorization check
- Content validation
- Actor message dispatch
- Response handling
-
Comment Management
- Nested comment support
- Vote tracking
- Real-time updates
Client Request -> REST Handler -> Engine Actor -> Specialized Actor -> Response
- Isolated actor states
- Concurrent access control
- Message-based updates
- Real-time consistency
We validate the system using three distinct user personas:
- Creates programming content
- Participates in technical discussions
- Tests post creation and editing
- Manages gaming communities
- Creates gaming-related content
- Tests cross-posting capabilities
- Manages movie discussions
- Tests content interaction
- Demonstrates multi-subreddit usage
1. User Creation and Authentication
2. Subreddit Creation and Joining
3. Content Creation and Interaction
4. Search and Feed Generation
5. Edit and Delete Operations
POST /register
- Request: {username, password}
- Response: {token, userId}
POST /login
- Request: {username, password}
- Response: {token}
POST /post
- Auth: Required
- Request: {title, content, subredditName}
- Response: {postId, success}
POST /comment
- Auth: Required
- Request: {postId, content}
- Response: {commentId, success}
POST /subreddit
- Auth: Required
- Request: {name, description}
- Response: {subredditId, success}
POST /subreddit/:name/join
- Auth: Required
- Response: {success}
GET /feed
- Auth: Required
- Response: {posts[], subreddits[]}
GET /search?q=query
- Auth: Required
- Response: {posts[], relevance}
- Average response time: 2.5s for content operations
- Authentication operations: ~10μs
- Search operations: 2.7s
- Concurrent user handling: 96.5% success rate
- Successful requests: 96.5%
- Failed requests: 3.5%
- Error distribution analysis
- Concurrent user capacity
The system implements comprehensive message passing:
type Post struct {
PostId string
Title string
Content string
AuthorId string
SubredditName string
Timestamp int64
ActorPID *actor.PID
}Reddit-like voting mechanism:
func (state *PostActor) handleVote(msg *messages.Vote) *messages.VoteResponse {
if _, exists := state.posts[msg.TargetID]; !exists {
return &messages.VoteResponse{Success: false, Error: "Post not found"}
}
if state.votes[msg.TargetID] == nil {
state.votes[msg.TargetID] = make(map[string]bool)
}
previousVote, hasVoted := state.votes[msg.TargetID][msg.UserID]
if hasVoted {
if previousVote == msg.IsUpvote {
delete(state.votes[msg.TargetID], msg.UserID)
} else {
state.votes[msg.TargetID][msg.UserID] = msg.IsUpvote
}
} else {
state.votes[msg.TargetID][msg.UserID] = msg.IsUpvote
}
return &messages.VoteResponse{Success: true}
}- Go 1.16 or higher
- Proto.Actor framework
- Git
-
Build and run the main server:
go build -o reddit ./reddit
This will start the server on port 8080
-
Run the test script:
go run script/test_script.go
This will execute the test scenarios with different user personas
- Clone the repository
- Install dependencies:
go mod tidy - Start the server:
go run main.go - Run tests:
go run test_script.go
- Public key-based digital signatures
- Enhanced authentication
- Rate limiting
- Content verification
- Media content support
- Real-time notifications
- Enhanced search capabilities
- Content recommendation system
- Database integration
- Caching layer
- Load balancing improvements
- Response time optimization
This project demonstrates a practical implementation of a distributed system using the Actor model with REST API integration. Its modular design and message-passing architecture provide a solid foundation for a scalable social platform. The implementation successfully showcases key concepts of distributed systems and concurrent programming while maintaining clean REST principles.
-
Build and run the main server:
go build -o reddit or go build ./reddit or go run main.go
This will start the server on port 8080. Now in a separate terminal run the test script
-
Run the test script:
go run script/test_script.go
This will execute the test scenarios with different user personas
- Clone the repository
- Install dependencies:
go mod tidy