Threadly is a backend application designed to mimic the functionality of Reddit. It provides APIs for user authentication, subreddit management, post creation, and comment handling.
To get started with Threadly, follow these steps:
- Ensure you have Node.js and npm installed on your system.
- Clone the repository and navigate to the project directory.
- Install the dependencies using
npm install. - Set up the
.envfile with the required environment variables. - Run the development server using
npm run dev.
For more details, refer to the Installation section.
- User registration and login with JWT-based authentication.
- Subreddit creation, update, and deletion.
- Post creation and retrieval by subreddit.
- Comment creation, update, and deletion with ownership validation.
-
Clone the repository:
git clone https://github.com/f0rsakeN-afk/Threadly.git cd Threadly -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in the root directory and configure the required variables (e.g., database connection, JWT secret). -
Run the development server:
npm run dev
-
Build for production:
npm run build
-
Start the production server:
npm start
| Method | Endpoint | Description | Protected |
|---|---|---|---|
| POST | / |
Vote on a post (upvote/downvote) | Yes |
Threadly is licensed under the MIT License. See the LICENSE file for details.
The project structure is organized as follows:
Threadly/
├── dist/ # Compiled JavaScript files
├── generated/ # Auto-generated files (e.g., Prisma client)
├── node_modules/ # Dependencies
├── prisma/ # Prisma schema and migrations
├── src/ # Source code
├── .gitignore # Git ignore rules
├── LICENSE # License information
├── README.md # Project documentation
├── package.json # Project metadata and scripts
├── tsconfig.json # TypeScript configuration
This structure ensures a clean separation of concerns and easy navigation.
We welcome contributions to Threadly! To contribute:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes with clear and concise messages.
- Push your branch and create a pull request.
Please ensure your code adheres to the project's coding standards and includes relevant tests.
| Method | Endpoint | Description | Protected |
|---|---|---|---|
| POST | /register |
Register a new user | No |
| POST | /login |
Login and get a JWT token | No |
| POST | /forgotPassword |
Request a password reset | No |
| POST | /resetPassword |
Reset the user's password | No |
| PATCH | /updatePassword |
Update the user's password | Yes |
| Method | Endpoint | Description | Protected |
|---|---|---|---|
| GET | / |
Get all subreddits | No |
| POST | / |
Create a new subreddit | Yes |
| PATCH | /:id |
Update a subreddit (ownership) | Yes |
| DELETE | /:id |
Delete a subreddit (ownership) | Yes |
| Method | Endpoint | Description | Protected |
|---|---|---|---|
| GET | /r/:slug |
Get posts by subreddit slug | No |
| POST | / |
Create a new post | Yes |
| Method | Endpoint | Description | Protected |
|---|---|---|---|
| GET | /:postId |
Get comments for a specific post | No |
| POST | / |
Create a new comment | Yes |
| PATCH | /:id |
Update a comment (ownership) | Yes |
| DELETE | /:id |
Delete a comment (ownership) | Yes |
- Node.js: Backend runtime.
- Express: Web framework.
- Prisma: ORM for database management.
- PostgreSQL: Relational database
- TypeScript: Type safety.
- JWT: Authentication.
- Zod: Schema validation.