Before you begin, ensure you have the following installed:
Node.js (v14 or higher)
MongoDB (local or accessible via connection string)
The project structure is organized as follows:
Sona3/
│
├── configs/
│ ├── database.js # MongoDB connection configuration
│ ├── app.js # Express application configuration
│ ├── server.js # Entry point of the app
│ ├── socket.js # Socket.io Server configuration
│
├── controllers/
│ ├── admin/ # Controllers for the admin panel app (web UI)
│ │ ├── auth.controller.js # Authentication controller
│ │ ├── admin.controller.js # CRUD controllers for admins
│ │ ├── customer.controller.js # CRUD controllers for customers
│ │ ├── seller.controller.js # CRUD controllers for sellers
│ │ ├── product.controller.js # CRUD controllers for products
│ │ # ... Add more controllers as needed
│ ├── customer/ # Controllers for the customer app (mobile and web UI)
│ │ # ... Controllers similar to the admin app
│ ├── seller/ # Controllers for the Seller app (mobile and web UI)
│ │ # ... Controllers similar to the admin app
│
├── helpers/
│ ├── cors.helper.js # Helper methods for custom CORS policies
│ ├── jwt.helper.js # JWT helper methods for token generation and decoding
│ ├── settings.helper.js # Methods for reading and writing data to settings.js
│ ├── uploader.helper.js # Multer method for file upload with validation
│ ├── validation.helper.js # Joi-based validation of request data
│ # ... Add more helper methods as needed
│
├── locales/
│ ├── ar.json # Keys with Arabic translations of messages as values
│ ├── en.json # Keys with English translations of messages as values
│
├── models/
│ ├── Admin/
│ │ ├── admin.model.js # Mongoose schema for admins
│ │ ├── admin.repo.js # Methods for CRUD operations on admin data
│ ├── Customer/
│ │ # ... Models and repos for customers, sellers, products, etc.
│ ├── Seller/
│ │ # ... Models and repos for sellers, categories, coupons, etc.
│ ├── Wishlist/
│ │ # ... Models and repos for wishlists, if applicable
│ # ... Add more models and repos as needed
│
├── tests/ # Unit Tests for all APIs exposed for all apps using jest and supertest
│ ├── admin/
│ │ ├── index.test.js # Aggregates all admin app tests
│ │ ├── auth.test.js # Authentication endpoints
│ │ ├── admin.test.js # Endpoints for admins
│ │ ├── customer.test.js # Endpoints for customers
│ │ ├── seller.test.js # Endpoints for sellers
│ │ ├── product.test.js # Endpoints for products
│ │ # ... Add more test files for other features
│ ├── customer/
│ │ # ... Test files for the customer app
│ ├── seller/
│ │ # ... Test files for the Seller app
│ ├── index.test.js # Aggregates all index.test.js files from all 3 folders
│
├── routes/
│ ├── admin/
│ │ ├── index.route.js # Aggregates all admin app endpoints
│ │ ├── auth.route.js # Authentication endpoints
│ │ ├── admin.route.js # Endpoints for admins
│ │ ├── customer.route.js # Endpoints for customers
│ │ ├── seller.route.js # Endpoints for sellers
│ │ ├── product.route.js # Endpoints for products
│ │ # ... Add more route files for other features
│ ├── customer/
│ │ # ... Route files for the customer app
│ ├── seller/
│ │ # ... Route files for the Seller app
│ ├── index.route.js # Aggregates all endpoints
|
├── sockets/
│ ├── admin/
│ │ ├── admin.socket.js # socket.io events for admins
│ │ # ... Add more socket files for other features
│ ├── customer/
│ │ ├── customer.socket.js # socket.io events for customers
│ │ # ... Add more socket files for other features
│ ├── seller/
│ │ ├── seller.socket.js # socket.io events for sellers
│ │ # ... Add more socket files for other features
│ ├── index.socket.js # Aggregates all sockets
│
├── utils/
│ ├── batchSchedule.util.js # Methods for handling cron jobs and batch processing
│ ├── s3FileStorage.util.js # Methods for reading and writing files to AWS S3
│ ├── stripePayment.util.js # Payment operations with Stripe
│ # ... Add more utility methods for various purposes
│
├── validations/
│ ├── admin.validation.js # Validation schemas for admin data
│ ├── customer.validation.js # Validation schemas for customer data
│ # ... Add more validation schemas as needed
│
├── .env # Environment variables
├── .gitignore # Gitignore file
├── jest.config.js # Jest configuration
├── package-lock.json # Project dependencies lockfile
├── package.json # Project dependencies file
├── Procfile # Heroku deployment configuration
├── README.md # This documentation
├── settings.js # File for storing application settings
Follow these steps to get started with the Sona3 project:
Follow these steps to get started with the Sona3 project:
-
Clone this repository:
git clone https://github.com/Sona3App/APIs.git
-
Navigate to the project directory:
cd Sona3- Install the required dependencies:
npm installCustomize your application's configuration by making changes to the following files:
- configs/database.js: Configure your MongoDB connection settings.
- configs/app.js: Customize your Express application settings.
- Set environment variables in the .env file to store sensitive information like API keys and secrets.
To run the Sona3 application, execute the following command:
npm startThe application will be accessible at http://localhost:your-port. You can access the API endpoints and the frontend (if applicable) from this URL.
We welcome contributions to the Sona3 project. To contribute, please follow these steps:Fork the repository.
Create a new branch for your feature or bug fix. Implement your changes and thoroughly test them. Submit a pull request with a detailed description of your changes.This project is licensed under the MIT License. For more details, see the LICENSE file.