https://github.com/obaa10/stack-overflow
Stack Overflow-like platform where users can post questions and answers, including features like voting, AI-generated answers, and similarity-based search.
https://github.com/obaa10/stack-overflow
Last synced: about 1 month ago
JSON representation
Stack Overflow-like platform where users can post questions and answers, including features like voting, AI-generated answers, and similarity-based search.
- Host: GitHub
- URL: https://github.com/obaa10/stack-overflow
- Owner: Obaa10
- Created: 2024-12-27T11:16:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-27T11:33:12.000Z (over 1 year ago)
- Last Synced: 2025-01-25T10:12:11.167Z (over 1 year ago)
- Language: TypeScript
- Size: 142 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Stack Overflow Clone
This project is a Stack Overflow-like platform where users can post questions and answers, including features like voting, AI-generated answers, and similarity-based search.
## Features
### Mandatory Requirements
1. **User Registration & Login**:
- Users can register and log in to the platform.
2. **Question CRUD**:
- Create, read, update, and delete questions.
3. **Answer CRUD**:
- Create, read, update, and delete answers.
4. **Question Search**:
- Search for questions by keywords or related topics.
5. **Edit Requests**:
- Users can submit edit requests for questions or answers.
- Owners can approve or reject edit requests.
### Optional Features
1. **Voting System**:
- Users can vote on questions and answers (upvote/downvote).
2. **AI-Generated Answers**:
- An AI-generated answer is automatically created whenever a question is posted using open-ai.
3. **Similarity-Based Search**:
- Search for similar questions using vector-based search using TfIdf.
4. **Dockerization**:
- The application is Dockerized for easy deployment.
## Installation
### Prerequisites
- Node.js (>=16.x)
- NestJS CLI (optional)
- Docker (if running with Docker)
- MySQL database
### Steps
1. Install dependencies:
```bash
npm install
```
2. Set up environment variables:
Create a `.env` file in the root of the project with the following values:
```env
DATABASE_HOST=
DATABASE_PORT=
DATABASE_USER=
DATABASE_PASSWORD=
DATABASE_NAME=
REDIS_HOST=
REDIS_DB=
REDIS_PORT=
OPENAI_API_KEY=
EMAIL_USER=
EMAIL_PAS=
AUTH_TOKEN_JWT_SECRET=
AUTH_TOKEN_JWT_EXPIRATION=
AUTH_REFRESH_TOKEN_JWT_SECRET=
AUTH_REFRESH_TOKEN_JWT_EXPIRATION=
```
3. Run database migrations:
```bash
npm run typeorm migration:run
```
4. Start the development server:
```bash
npm run start:dev
```
5. Access the application at `http://localhost:3000`.
## Running with Docker
1. Build and start the Docker container:
```bash
docker-compose up --build
```
2. Access the application at `http://localhost:3000`.
## Project Structure
```
src/
├── app/ # Main application modules (auth, questions, answers, etc.)
├── libs/ # Shared libraries and utilities
├── main.ts # Application entry point
```
## API Endpoints
### Authentication
- `POST /auth/register` - Register a new user.
- `POST /auth/login` - Log in and obtain tokens.
### Questions
- `POST /questions` - Create a question.
- `GET /questions` - List all questions.
- `GET /questions/:id` - Retrieve a single question.
- `PUT /questions/:id` - Update a question.
- `DELETE /questions/:id` - Delete a question.
### Answers
- `POST /answers` - Create an answer.
- `GET /answers/:id` - Retrieve an answer.
- `PUT /answers/:id` - Update an answer.
- `DELETE /answers/:id` - Delete an answer.
### Voting
- `POST /vote/question/:id` - Vote on a question.
- `POST /vote/answer/:id` - Vote on an answer.
### Similar Questions Search
- `GET /search/questions` - Query base search with filter.
- `GET /search/questions/similar` - Search for similar questions.