This is the backend for the API Predict App, built using Node.js and Express.js following the MVC architecture. It includes authentication, middleware, and various routes for handling user predictions.
- 🔑 User authentication (JWT-based)
- 🔐 Google OAuth authentication
- ✅ Data validation with Joi
- 🔒 Secure password handling with bcrypt
- 🛡️ Middleware for authentication and validation
- 🗄️ MongoDB integration with Mongoose
- 🌍 CORS support
ApiPredictApp/
│-- config/
│ ├── passport.js
│-- controllers/
│ ├── AuthController.js
│ ├── PredictController.js
│-- Middlewares/
│ ├── Auth.js
│ ├── AuthValidation.js
│ ├── middleware.js
│-- Models/
│ ├── PredictModeldb.js
│ ├── User.js
│-- Routes/
│ ├── AuthRouter.js
│ ├── predictRoute.js
│-- util/
│-- .env
│-- .gitignore
│-- package.json
│-- package-lock.json
│-- Server.js
- Node.js (v14+ recommended)
- MongoDB installed and running
- Clone the repository:
git clone https://github.com/Maymasi/ApiPredictApp.git cd ApiPredictApp - Install dependencies:
npm install
- Set up the environment variables in a
.envfile:PORT=8080 JWT_SECRET="secret-123" GOOGLE_CLIENT_ID=your_ID GOOGLE_CLIENT_SECRET=your_Key
- Start the server:
npm start
Middleware functions are used to validate and authenticate requests before processing them. They include:
Auth.js→ Handles authentication checks using JWTAuthValidation.js→ Validates input data using Joimiddleware.js→ General middleware for handling request modifications
{
"axios": "^1.7.9",
"bcrypt": "^5.1.1",
"body-parser": "^1.20.3",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
"express": "^4.21.2",
"nodemon": "^3.1.9",
"express-session": "^1.18.1",
"joi": "^17.13.3",
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.9.2",
"passport": "^0.7.0",
"passport-google-oauth20": "^2.0.0"
}This project is licensed under the MIT License.
If you'd like to suggest new features or contribute to the project, feel free to contact us on LinkedIn:
- Oussama Nouhar
- Omaima Siaf
- Souhayla Ghanem