This is template to Build the Server in the Microservices from the Start, It makes it easy to Deploy it in microservices in Future. This is not as complex to Setup and Really Easy to Use.
This has been made taking into consideration the following:
- The Server should be able to handle the large number of requests. (Whole Server is Asynchronous)
- Different Services Can Communication with Each other both in Request Response Method and also in Message Queue Method.
- It is easy for Anyone to Transfer the Files to the Remote Server and Deploy the Services.
- People can Choose Which Language they want to use to build the Services. (Python or JS)
- We are Using fastapi for the API and uvicorn for the server. (Python, Feel Free to Adjust the Framework that meet your needs)
- We are Using Rabbit MQ as our Messaging Queue System.
Note: We are Running Rabbit MQ using Docker at the default Port 5672, if you want to change the Port, you can change the Port in the Docker Compose File.
- Mention all the Dependencies in the Requirements.txt File.
- There Are Some Dependencies that are Project Dependent, You can mention them in the Requirements.txt File.
- Some of the Dependencies are Already Mentioned in the ServerScripts/setupServer.sh File, these are needed to run the Server with the Current Configuration.
- Mention all the Environment Variables in the env.json File.
- One Common Use would be mentioning the IP Address of the MongodDB server here.
- Can mention RabbitMQ ports and other service configurations here to notify all Services.
- Setup the Schema in the MongoSchema.json File.
- In Each service take the Reference from this file to Setup the Schema for the MongoDB in the Service.
Note: You Can pass this schema to the AI and Ask it to Complete a Function for the Service, hence making it Easy to Develop the Server.
- Create a new folder in the Services Folder. Idealy Follow the Naming Convention as service_
- Add the Service in the ServiceURLMapping.json File.
- Add all the Necesary files Needed for the Service in the Service Folder.
- Go the Folder Named ServerScripts
- Run the TerminalStartServer.sh File. (Note Use the TerminalRestartServer.sh to restart the Whole Server)
- Go the Folder Named Service_
- Run the TerminalStartServer.sh File.
- Go the Folder Named ServerScripts
- Read the setupServer.sh file, it contains Commands to Setup Different Components in the Server.
- Mention the Files you want to transfer to the Remote Server alongiside with the Remote Server IP Address and the Remote Server Directory
- Run the CopyFilesToRemoteServer.sh File.
- Go the Folder Named Testing
- Run the publisher.py file to send the message to the Server.
- Run the subscriber.py file to receive the message from the Server.
- Create Necessary Testing Files Here so that it is Easy to Review the Test and All
- Create a Venv inside the Local Directory itself and Use it rather than creating it in any other place
- If Need Different Environment for Different Services Create a venv inside each Service Folder and run the service using that ENV.