This is a full-stack project that provides a service where users can access knowledge about stocks, including which stocks to invest in and their analysis. The application includes role-based authentication, allowing an editor to add and manage content, while general users can view the information.
The backend is built using Node.js, Express, and MongoDB. It includes features for user authentication, role management, and stock data handling.
Clone the Repository
git clone https://github.com/yourusername/stock-analysis-backend.git
cd stock-analysis-backend
Install Dependencies
npm install
Setup Environment Variables
Create a .env
file in the root directory and add the following:
MONGO_URI=mongodb://localhost:27017/stockDB
JWT_SECRET=your_jwt_secret
PORT=5000
Run the Server
npm start
/api/users/register
- Register a new user/api/users/login
- Login a user/api/health
- Health check endpoint , used to check if the server is running/api/users/registerbymail
- Register a new user by mail validation/api/stocks
- Create a new stock (Editor only)/api/stocks
- Get all stocksbackend/
├── config/
│ └── db.js
├── controllers/
| ├── healthCheckController.js
│ ├── stockController.js
│ └── userController.js
├── middleware/
│ └── auth.js
| └── multer.middleware.js
| └── validator.middleware.js
├── models/
| ├── validation/
| | └──login.validation.schema.js
| | └──register.validation.schema.js
│ ├── stock.model.js
│ └── user.model.js
├── routes/
│ ├── healthCheckRoutes.js
│ ├── stockRoutes.js
│ └── userRoutes.js
├── util/
│ └── nodemailer.js
| └── EmailValidation.js
| └── cloudinary.js
| └── constants.js
| └── validator.js
├── .env
├── package.json
└── server.js
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
By following these instructions, you should be able to set up and run both the backend and frontend for the Stock Analysis Service. Feel free to contribute to the project to make it better!