Skip to content

Commit 7e38981

Browse files
Initial commit: Backend API project
1 parent 6cd77a8 commit 7e38981

39 files changed

+4515
-0
lines changed

.env.sample

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
PORT=5000
2+
MONGO_URL=
3+
CORS_ORIGIN=
4+
ACCESS_TOKEN_SECRET=
5+
ACCESS_TOKEN_EXPIRY=1d
6+
REFRESH_TOKEN_SECRET=
7+
REFRESH_TOKEN_EXPIRY=10d
8+
CLOUDINARY_CLOUD_NAME=
9+
CLOUDINARY_API_KEY=
10+
CLOUDINARY_API_SECRET=
11+
ABSTRACT_API_KEY=

.gitignore

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Microbundle cache
58+
.rpt2_cache/
59+
.rts2_cache_cjs/
60+
.rts2_cache_es/
61+
.rts2_cache_umd/
62+
63+
# Optional REPL history
64+
.node_repl_history
65+
66+
# Output of 'npm pack'
67+
*.tgz
68+
69+
# Yarn Integrity file
70+
.yarn-integrity
71+
72+
# dotenv environment variables file
73+
.env
74+
.env.test
75+
.env.production
76+
77+
# parcel-bundler cache (https://parceljs.org/)
78+
.cache
79+
.parcel-cache
80+
81+
# Next.js build output
82+
.next
83+
out
84+
85+
# Nuxt.js build / generate output
86+
.nuxt
87+
dist
88+
89+
# Gatsby files
90+
.cache/
91+
# Comment in the public line in if your project uses Gatsby and not Next.js
92+
# https://nextjs.org/blog/next-9-1#public-directory-support
93+
# public
94+
95+
# vuepress build output
96+
.vuepress/dist
97+
98+
# Serverless directories
99+
.serverless/
100+
101+
# FuseBox cache
102+
.fusebox/
103+
104+
# DynamoDB Local files
105+
.dynamodb/
106+
107+
# TernJS port file
108+
.tern-port
109+
110+
# Stores VSCode versions used for testing VSCode extensions
111+
.vscode-test
112+
113+
# yarn v2
114+
.yarn/cache
115+
.yarn/unplugged
116+
.yarn/build-state.yml
117+
.yarn/install-state.gz
118+
.pnp.*
119+
120+
# End of https://mrkandreev.name/snippets/gitignore-generator/#Node

README.md

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Backend API Project
2+
3+
This repository contains the backend code for a **video-sharing and social media platform**.
4+
It is built with **Node.js, Express.js, and MongoDB**, and provides **RESTful APIs** for user management, video uploads, comments, likes, playlists, subscriptions, tweets, and email validation.
5+
6+
---
7+
8+
## Features
9+
10+
- **User Management** – Registration, authentication (JWT), profile management
11+
- **Video Uploads** – Upload, stream, and manage videos (**Multer + Cloudinary**)
12+
- **Comments & Likes** – Add comments and likes to videos
13+
- **Playlists** – Create and manage playlists
14+
- **Subscriptions** – Subscribe/unsubscribe to channels
15+
- **Tweets** – Post and manage short tweets
16+
- **File Uploads** – Handled via Multer middleware
17+
- **Cloud Storage** – Integrated with Cloudinary
18+
- **Email Validation** – Validates email addresses using [Abstract API](https://mailmeteor.com/tools/email-reputation)
19+
```js
20+
https://emailreputation.abstractapi.com/v1/?api_key=${ABSTRACT_API_KEY}&email=${email}
21+
```
22+
- **Error Handling** – Custom ApiError and ApiResponse classes
23+
24+
---
25+
26+
## Project Structure
27+
28+
```
29+
src/
30+
app.js # Main Express app setup
31+
constants.js # Application constants
32+
index.js # Entry point
33+
controllers/ # Route controllers for each feature
34+
comment.controller.js
35+
like.controller.js
36+
playlist.controller.js
37+
subscription.controller.js
38+
tweet.controller.js
39+
user.controller.js
40+
video.controller.js
41+
db/
42+
index.js # Database connection setup
43+
middlewares/ # Custom Express middlewares
44+
auth.middleware.js
45+
emailValidator.middleware.js
46+
multer.middleware.js
47+
models/ # Mongoose models for MongoDB
48+
comment.model.js
49+
like.model.js
50+
playlist.model.js
51+
subscription.model.js
52+
tweet.model.js
53+
user.model.js
54+
video.model.js
55+
routes/ # API route definitions
56+
comment.routes.js
57+
like.routes.js
58+
playlist.routes.js
59+
subscription.routes.js
60+
tweet.routes.js
61+
user.routes.js
62+
video.routes.js
63+
utils/ # Utility classes and functions
64+
ApiError.js
65+
ApiResponse.js
66+
asyncHandler.js
67+
Cloudinary.js
68+
public/
69+
temp/ # Temporary files (e.g., uploads)
70+
```
71+
72+
---
73+
74+
## Technologies Used
75+
76+
- **Node.js** (JavaScript runtime)
77+
- **Express.js** (backend framework)
78+
- **MongoDB + Mongoose** (database & ORM)
79+
- **Multer** (file upload handling)
80+
- **Cloudinary** (media storage)
81+
- **JWT** (authentication & authorization)
82+
- **Bcrypt** (password hashing)
83+
- **Dotenv** (environment variable management)
84+
- **Nodemon** (development server auto-restart)
85+
- **mailmeteor** (email validation)
86+
87+
---
88+
89+
## Installation & Setup
90+
91+
### 1. Clone the repository
92+
93+
```sh
94+
git clone https://github.com/rahul-vyas-dev/social-media-Backend-Project
95+
cd social-media-Backend-Project
96+
```
97+
98+
### 2. Install dependencies
99+
100+
```sh
101+
npm install
102+
```
103+
104+
> You don’t need to run `npm init` since this project already includes a `package.json` with `"type": "module"` set.
105+
106+
### 3. Environment Configuration
107+
108+
You must create a `.env` file in the root directory.
109+
A sample configuration is provided in **`.env.sample`**.
110+
111+
### 4. Run the server
112+
113+
Development mode (auto-reload with nodemon):
114+
115+
```sh
116+
npm run dev
117+
```
118+
119+
Production mode:
120+
121+
```sh
122+
node src/index.js
123+
```
124+
125+
---
126+
127+
## API Endpoints
128+
129+
**Base URL:** `http://localhost:5000/api/v1`
130+
131+
| Endpoint | Description |
132+
| ------------------------ | ------------------------------------------ |
133+
| `/api/v1/users` | User operations (register, login, profile) |
134+
| `/api/v1/videos` | Video upload & management |
135+
| `/api/v1/comments` | Comment operations |
136+
| `/api/v1/likes` | Like/unlike videos |
137+
| `/api/v1/playlists` | Playlist CRUD |
138+
| `/api/v1/subscriptions` | Subscribe/unsubscribe users |
139+
| `/api/v1/tweets` | Tweet CRUD |
140+
| `/api/v1/email/validate` | Validate email addresses |
141+
142+
---
143+
144+
## Development Scripts
145+
146+
From `package.json`:
147+
148+
```sh
149+
npm run dev # Start backend in development mode with nodemon
150+
npm start # Start normally with Node.js (if added)
151+
```
152+
153+
---
154+
155+
## Contributing
156+
157+
1. Fork the repo
158+
2. Create a new branch (`feature/your-feature`)
159+
3. Commit your changes
160+
4. Push to your fork
161+
5. Create a Pull Request
162+
163+
---
164+
165+
## License
166+
167+
This project is licensed under the **MIT License**.
168+
169+
---
170+
171+
## Quick Start
172+
173+
Now anyone can:
174+
175+
1. **Clone**`git clone`
176+
2. **Install**`npm install`
177+
3. **Configure**`.env` (check `.env.sample` for reference)
178+
4. **Run**`npm run dev` or `node src/index.js`
179+
180+
### Developer Notes
181+
182+
This project took me a good amount of time and effort to build. During development, I:
183+
184+
- Carefully structured the backend from scratch.
185+
- Implemented and tested **every route** one by one.
186+
- Learned a lot about Node.js, Express, MongoDB, and integrations like Cloudinary and Abstract API.
187+
- Focused on **clean error handling** and modular code organization.
188+
189+
I’m proud of the learning journey this project represents

data.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"email_address": "[email protected]",
3+
"email_deliverability": {
4+
"status": "deliverable",
5+
"status_detail": "valid_email",
6+
"is_format_valid": true,
7+
"is_smtp_valid": true,
8+
"is_mx_valid": true,
9+
"mx_records": [
10+
"gmail-smtp-in.l.google.com",
11+
"alt1.gmail-smtp-in.l.google.com",
12+
"alt2.gmail-smtp-in.l.google.com",
13+
"alt3.gmail-smtp-in.l.google.com",
14+
"alt4.gmail-smtp-in.l.google.com"
15+
]
16+
},
17+
"email_quality": {
18+
"score": "0.95",
19+
"is_free_email": true,
20+
"is_username_suspicious": false,
21+
"is_disposable": false,
22+
"is_catchall": false,
23+
"is_subaddress": false,
24+
"is_role": false,
25+
"is_dmarc_enforced": true,
26+
"is_spf_strict": false,
27+
"minimum_age": null
28+
},
29+
"email_sender": {
30+
"first_name": "Rahul",
31+
"last_name": "Vyas",
32+
"email_provider_name": "Google",
33+
"organization_name": "Gmail",
34+
"organization_type": "commercial"
35+
},
36+
"email_domain": {
37+
"domain": "gmail.com",
38+
"domain_age": 10973,
39+
"is_live_site": true,
40+
"registrar": "MarkMonitor Inc.",
41+
"registrar_url": "https://markmonitor.com",
42+
"date_registered": "1995-08-13",
43+
"date_last_renewed": "2024-07-11",
44+
"date_expires": "2025-08-12",
45+
"is_risky_tld": false
46+
},
47+
"email_risk": { "address_risk_status": "low", "domain_risk_status": "low" },
48+
"email_breaches": {
49+
"total_breaches": 0,
50+
"date_first_breached": null,
51+
"date_last_breached": null,
52+
"breached_domains": []
53+
}
54+
}

0 commit comments

Comments
 (0)