A private, curated collection of moments and thoughts visible only to people you allow. Secure APIs for STIlLS Built using Node.js, Express.js, and MySQL. The project implements authentication, user profiles, posts, and relationship management (follow, block, remove connection).
This backend focuses on clean architecture, modular routing, and secure authentication using JWT tokens.
- Node.js
- Express.js
- MySQL
- User registration
- User login
- Secure password hashing
- JWT access token generation
- Refresh token support
- follow your friends
- Read profile data
- Update profile information
- Create posts
- Read posts
- Update posts
- Delete posts
Users can interact with other users through relationship APIs:
- Follow a user
- Block a user
- Remove connection
reet
├── public
│ ├── images
│ ├── javascripts
│ └── stylesheets
│ └── style.css
│
├── routes
│ ├── auth
│ │ ├── login.js
│ │ ├── refreshtoken.js
│ │ └── register.js
│ │
│ ├── index.js
│ ├── rels.js
│ ├── users.js
│ └── users_posts.js
│
├── services
│ ├── auth.services.js
│ └── user.services.js
│
├── utils
│ ├── hashToken.js
│ └── jwt.js
│
├── views
│ ├── error.jade
│ ├── index.jade
│ └── layout.jade
│
├── .env
├── .gitignore
├── app.js
├── db.js
├── middleware.js
├── package.json
├── package-lock.json
├── sql.sql
└── readme.md
The project follows a layered backend architecture:
Handles HTTP requests and maps them to appropriate service functions.
Contains core business logic and database queries.
Helper utilities for:
- JWT generation and verification
- Refresh token hashing
Centralized middleware for:
- Authentication verification
- Error handling
- Request validation
MySQL database storing:
- users
- posts
- relationships
- posts
-
Create a MySQL database.
-
Import schema:
mysql -u username -p database_name < sql.sql
- Configure environment variables.
Create a .env file:
PORT=3000
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=yourpassword
DB_NAME=social_media
JWT_SECRET=your_jwt_secret
REFRESH_SECRET=your_refresh_secret
Clone the repository:
git clone https://github.com/naina35/reet.git
cd reet
Install dependencies:
npm install
Run the server:
npm start
For development:
npm run dev
- Password hashing using bcrypt
- JWT authentication
- Refresh token rotation
- Token hashing before storing
- Environment variable protection
- Notifications system - DECIDED AGAINST IT because i am designing this app to be anti addiction, calm platform
- Maybe chat feature? Not sure if it matches the vibe?
- Password reset functionality
- add email to user schema. Allow user to add email
- Feed API (timeline generation) - DONE
- Pagination for posts - DONE
- Input validation middleware - DONE IN FRONTEND
- Image upload support - DONE