This is the server side or the Back End of AM Store project (e-commerce),
Which is the server that handles the business logic of the e-commerce and provides the services to the clients
(AM Store Client site and
AM Store Admin Pandel).
This API is a RESTful API
, And it follows the MVC
architectural pattern for separation of concerns and organizing the code to make it more modular, maintainable and easier to test.
This project built with the Javascript Runtime Environment Node.js
and Docker
,
So you need to have Node.js
and Docker
installed in your machine to be able to install the project and run it.
- If you don't have
Node.js
, Go to the official website of Node.js and install it. - If you don't have
Docker
, Go to Docker official website and install it.
Follow these steps to install and run AM Store's Server in your machine 👇:
Open the terminal on your machine whenever you want and run the following command to clone the repository:
git clone https://github.com/AbdulrhmanGoni/AM-store-server.git
First open AM-store-server
folder by running this command
cd AM-store-server
And then create .env.development
files using the following command:
If you use Linux or Mac operating systems run this command:
touch .env.development
If you use Windows operating system run this command:
echo "" > .env.development
Open .env.development
file and add these variables to it:
Note
You can left these variables empty and go to run the server directlty in development mode and it will work, but know that there are some features and functionalites may don't work because the variables that they depend on are missing.
HASHING_SALT_ROUNDS=
JWT_SECRET_KEY=""
STORE_EMAIL=""
EMAIL_APP_PASSWORD=""
VERIFY_EMAIL_API_KEY=""
DB_CONNECTION_TYPE=""
DB_USERNAME=""
DB_PASSWORD=""
DB_NAME=""
DB_HOST=""
REDIS_CONNECTION_TYPE=""
REDIS_USERNAME=""
REDIS_PASSWORD=""
REDIS_HOST=""
REDIS_PORT=
A quick description of these environment variable:
VARIABLE | DESCRIPTION |
---|---|
HASHING_SALT_ROUNDS | The number rounds that hashing algorithm should take to encrypt users paswords |
JWT_SECRET_KEY | The secret key of the tokens that will used to generat users access tokens |
STORE_EMAIL | The official email of the store |
EMAIL_APP_PASSWORD | The pasword of the app that should be created from Google cloud platform for store's email |
VERIFY_EMAIL_API_KEY | The API key of hunter.io platform for using Email Verifier service to verify users emails existence |
DB_CONNECTION_TYPE | Specifies how the server connects to the database (use "remote" or let it empty) |
DB_USERNAME | The name of the user who has access to the mongo database of the project (it used only if DB_CONNECTION_TYPE variable is specified to "remote") |
DB_PASSWORD | The password of the user who has access to the mongo database of the project (it used only if DB_CONNECTION_TYPE variable is specified to "remote") |
DB_NAME | The name of the mongo database of the project (it used only if DB_CONNECTION_TYPE variable is specified to "remote") |
DB_HOST | The host name of the database of the project, in other words, where is the database hosted?, (it used only if DB_CONNECTION_TYPE variable is specified to "remote") |
REDIS_CONNECTION_TYPE | Specifies how the server connects to redis database (use "remote" or let it empty) |
REDIS_USERNAME | The name of redis database that used for caching in the project (it used only if REDIS_CONNECTION_TYPE variable is specified to "remote") |
REDIS_PASSWORD | The password of redis database that used for caching in the project (it used only if REDIS_CONNECTION_TYPE variable is specified to "remote") |
REDIS_HOST | The host name of redis database, in other words, where is redis database hosted?, (it used only if REDIS_CONNECTION_TYPE variable is specified to "remote") |
REDIS_PORT | The port that redis database should listen to (it used only if REDIS_CONNECTION_TYPE variable is specified to "remote") |
Run the server using the following command:
npm run docker-dev
And congratulations 🎉, Your AM Store Server is up and running on your http://localhost:7000.
You can browse the Endpoints and the Documentation of the API on Postman 👇
This API uses JSON Web Tokens ( JWT ) for users authentication.
Users can log in or sign up with their credentials (e.g., email and password or google authentication)
to obtain a JWT token, And then this token will be included in subsequent requests to authenticate the user
and authorize him to access the protected resources (e.g his data, orders, shopping cart, favorites, etc. ).
This project uses a combination of unit and integration tests written with Jest
to test the functionality of the API.
To run all tests use the following command:
npm test
To run specific tests files add an argumant matches files names, For example orders
npm test orders
To run a specific tests file add the full name of the file as an argumant, For example products_addDiscount_post
npm test products_addDiscount_post
You can go to tests code coverage report stie to see the full information about tests code coverage report of this project.
Tests process is included in continuous-deployment.yml
workflow to ensure that all tests passed successfully
and the new changes didn't make any errors before building and deploying the project to production environment.
If all tests in continuous-deployment.yml
workflow passed successfully, Jest
using istanbul
will create
a new code coverage report for the tests and this new report will be pushed to AM-store-server-tests-code-coverage-report
repository.
I welcome any feedback or suggestions you might have!
if you faced any problem in the project or you have any suggestion improves it,
or even you have some advices to improve me and my skills,
Please feel free to open an issue and discuss it with me or contact me directly on my LinkedIn account
or throuth my email [email protected]
Thank you for stopping by! 🌟