https://github.com/khaledsaeed18/yalla-learn-backend
Yalla Learn - 🚀 Backend
https://github.com/khaledsaeed18/yalla-learn-backend
2fa backend expressjs jwt nodejs nodemailer nodemon postgresql prisma restful-api typescript zod
Last synced: 11 months ago
JSON representation
Yalla Learn - 🚀 Backend
- Host: GitHub
- URL: https://github.com/khaledsaeed18/yalla-learn-backend
- Owner: KhaledSaeed18
- License: mit
- Created: 2025-03-01T17:36:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-29T14:11:37.000Z (12 months ago)
- Last Synced: 2025-06-29T15:25:20.638Z (12 months ago)
- Topics: 2fa, backend, expressjs, jwt, nodejs, nodemailer, nodemon, postgresql, prisma, restful-api, typescript, zod
- Language: TypeScript
- Homepage:
- Size: 388 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Yalla Learn Backend
[](https://www.typescriptlang.org/)
[](https://nodejs.org/)
[](https://expressjs.com/)
[](https://www.prisma.io/)
[](https://www.postgresql.org/)
A comprehensive backend API for the Yalla Learn platform.
## 🏗️ Architecture
### Technology Stack
- **Runtime**: Node.js with TypeScript
- **Framework**: Express.js
- **Database**: PostgreSQL with Prisma ORM
- **Authentication**: JWT with speakeasy for 2FA
- **Validation**: Zod schemas
- **Email**: Nodemailer with Google OAuth2
- **Security**: bcryptjs, sanitize-html, express-rate-limit
### Project Structure
```bash
src/
├── api/ # API modules
│ ├── auth/ # Authentication endpoints
│ ├── blog/ # Blog management
│ ├── contact/ # Contact form
│ ├── expense-tracker/ # Financial tracking
│ ├── jobs/ # Job board
│ ├── kanban/ # Task management
│ ├── listings/ # Marketplace listings
│ ├── qa/ # Q&A platform
│ ├── services/ # Service directory
│ └── user/ # User management
├── constants/ # Application constants
├── middlewares/ # Express middlewares
├── types/ # TypeScript type definitions
└── utils/ # Utility functions
```
## 🚦 Getting Started
### Prerequisites
- Node.js (v18 or higher)
- PostgreSQL database
- SMTP credentials (for email functionality)
- Google OAuth2 credentials (for email service)
### Installation
1. **Clone the repository**
```bash
git clone https://github.com/KhaledSaeed18/yalla-learn-backend.git
cd yalla-learn-backend
```
2. **Install dependencies**
```bash
yarn install
```
3. **Environment Setup**
Configure the following variables in `.env`:
```env
# Server Configurations
PORT=
API_VERSION=
BASE_URL=
# App Configurations
SALT_ROUNDS=
# Database Configurations
DATABASE_URL=
# JWT Configurations
JWT_SECRET=
JWT_REFRESH_SECRET=
# Email Configurations
CLIENT_ID=
CLIENT_SECRET=
REFRESH_TOKEN=
USER_EMAIL=
REDIRECT_URI=
# AI Configurations
GEMINI_API_KEY=
```
4. **Database Setup**
```bash
npx prisma generate
npx prisma db push
```
5. **Start Development Server**
```bash
yarn dev
```
### Production Deployment
1. **Build the project**
```bash
yarn build
```
2. **Start production server**
```bash
yarn start
```
## 📚 API Documentation
### Base URL
```bash
Development: http://localhost:5000/api/v1
```
### Response Format
All API responses follow a consistent format:
```json
{
"status": "success" | "fail" | "error",
"statusCode": 200,
"message": "Operation completed successfully",
"data": { ... }
}
```
## 🛡️ Security Features
### Input Validation & Sanitization
- **Zod Schema Validation** for request data
- **HTML Sanitization** to prevent XSS attacks
- **SQL Injection Prevention** via Prisma ORM
- **Rate Limiting** to prevent abuse
### Authentication Security
- **Secure Password Hashing** using bcryptjs
- **JWT Token Security** with short-lived access tokens
- **2FA Implementation** using TOTP standard
- **Email Verification** for account security
### Data Protection
- **CORS Configuration** for cross-origin security
- **Security Headers** implementation
- **Environment Variable Protection**
- **Input Length Restrictions**
## 🔧 Development
### Code Standards
- **TypeScript** for type safety
- **ESLint** for code linting
- **Prisma** for database operations
- **Modular Architecture** with separation of concerns
### Available Scripts
```bash
yarn dev # Start development server with hot reload
yarn build # Build for production
yarn start # Start production server
yarn lint # Run ESLint
```
### Environment Variables
The application requires proper environment configuration for:
- Database connection
- JWT secrets
- Email service credentials
- CORS origins
- Rate limiting settings
## 🤝 Contributing
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
### Development Workflow
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request
### Code Review Process
- All changes require review
- Automated checks must pass
- Follow existing code patterns
- Update documentation as needed
## 📄 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## 📞 Support
- **Bug Reports**: [GitHub Issues](https://github.com/KhaledSaeed18/yalla-learn-backend/issues)
## 🌐 Visit Our Website
**Experience Yalla Learn in your browser!**
### [🚀 Try Yalla Learn →](https://yalla-learn.me)