RESTful backend for a Q&A platform similar to Quora. This application handles user management, questions, answers, comments, and social interactions like following and liking.
Built with Java and Spring Boot.
- User Management: Register, update profiles, and view user details.
- Q&A Engine: Post questions, search by tag/text, and provide answers.
- Nested Comments: Comment on answers and reply to other comments.
- Social Interactions: Follow other users and "Like" content (Questions, Answers, Comments).
- Topics: Create and manage topics/tags for questions.
- Language: Java 17
- Framework: Spring Boot 3.5.10
- Build Tool: Gradle
- Database: MySQL
- Utilities: Project Lombok
Version: 1.0.0
Base URL: /api/v1
Base Path: /users
Register a new user in the system.
-
Endpoint:
POST /users -
Request Body:
{ "username": "johndoe", "email": "john@example.com", "bio": "Software Engineer and Tech Enthusiast" } -
Response (201 Created):
{ "id": "123e4567-e89b-12d3-a456-426614174000", "username": "johndoe", "email": "john@example.com", "bio": "Software Engineer and Tech Enthusiast", "questions": [], "answers": [], "comments": [], "followers": [], "follows": [] }
Retrieve a list of all registered users.
-
Endpoint:
GET /users -
Response (200 OK):
List<UserResponse>
Retrieve public profile information for a specific user.
-
Endpoint:
GET /users/{userId} -
Path Parameters:
userId: UUID of the user -
Response (200 OK):
UserResponse
Update profile details for an existing user.
-
Endpoint:
PUT /users/{userId} -
Request Body:
{ "username": "john_updated", "email": "john_new@example.com", "bio": "Updated bio text" } -
Response (200 OK):
UserResponse
Base Path: /questions
Post a new question to the platform.
-
Endpoint:
POST /questions -
Request Body:
{ "title": "How does Spring Boot handle dependency injection?", "body": "I am trying to understand the internal working of IoC container...", "userId": "123e4567-e89b-12d3-a456-426614174000", "topics": ["Java", "Spring Boot", "Programming"] } -
Response (201 Created):
{ "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "title": "How does Spring Boot handle dependency injection?", "body": "I am trying to understand the internal working of IoC container...", "username": "johndoe", "topics": ["Java", "Spring Boot"], "answers": [], "likes": [] }
Search for questions by text content or specific topic tags.
-
Endpoint:
GET /questions/search -
Query Parameters:
text (optional): Keyword search for title/body
tag (optional): Filter by topic
- Response (200 OK):
List<QuestionResponse>
Base Path: /answers
Retrieve all answers available in the database.
-
Endpoint:
GET /answers -
Response (200 OK):
List<AnswerResponse>
Submit an answer to a specific question.
-
Endpoint:
POST /answers/{questionId} -
Path Parameters:
questionId: UUID of the question being answered
-
Request Body:
{ "userId": "123e4567-e89b-12d3-a456-426614174000", "text": "Spring Boot uses the ApplicationContext to manage beans..." } -
Response (201 Created):
{ "answerId": "987fcdeb-5432-10fe-ba98-765432101234", "text": "Spring Boot uses the ApplicationContext to manage beans...", "user": "johndoe", "question": "How does Spring Boot handle dependency injection?", "comments": [], "likes": [] }
Modify the text of an existing answer.
-
Endpoint:
PUT /answers/{answerId} -
Request Body:
(String) "Updated answer text content..." -
Response (200 OK):
AnswerResponse
- Base Path:
/comments
Add a comment directly to an answer.
-
Endpoint:
POST /comments/{answerId}/answer -
Request Body:
{ "userId": "123e4567-e89b-12d3-a456-426614174000", "answerId": "987fcdeb-5432-10fe-ba98-765432101234", "text": "Great explanation!", "parentCommentId": null } -
Response (201 Created):
CommentResponse
Add a nested reply to an existing comment.
-
Endpoint:
POST /comments/{commentId}/comment -
Request Body:
{ "userId": "123e4567-e89b-12d3-a456-426614174000", "answerId": "987fcdeb-5432-10fe-ba98-765432101234", "text": "I agree with this point.", "parentCommentId": "existing-comment-uuid" } -
Response (201 Created):
CommentResponse
Retrieve a single comment by ID.
-
Endpoint:
GET /comments/{commentId} -
Response (200 OK):
{ "commentId": "uuid-string", "user": "username", "answer": "answer-text-preview", "text": "Great explanation!", "parentComment": "parent-username-or-null", "childComments": [] }
Base Path: /topics
Create a new topic tag for categorizing questions.
-
Endpoint:
POST /topics -
Request Body:
(String) "Microservices" -
Response (201 Created):
(String) "Microservices"
Retrieve a list of all available topics.
-
Endpoint:
GET /topics -
Response (200 OK):
["Java", "Microservices", "Spring Boot"]
Create a follower relationship between two users.
-
Endpoint:
POST /follow/{userId}/follows/{targetUserId} -
Path Parameters:
userId: UUID of the follower
targetUserId: UUID of the user being followed
Response: 201 Created (Empty Body)
Add a like to a Question, Answer, or Comment.
-
Endpoint:
POST /likes/{type}/{id} -
Path Parameters:
type: The type of entity (e.g., question, answer, comment)
id: The UUID of the specific entity
-
Request Body:
{ "userId": "123e4567-e89b-12d3-a456-426614174000" } -
Response:
201 Created (Empty Body)
com.example.QuoraAPI
├── controllers # REST Controllers (Endpoints)
├── dto # Data Transfer Objects (Request/Response models)
├── services # Business Logic
├── repositories # Database Access (JPA Interfaces)
└── models # JPA Entities (Database Tables)