Hi there,
The intention of the system is quite clear and straightforward but the description is rather confusing. There're some places that could use further explanation, hope you don't mind.
On page 2 step 4, mg_postcall table is mentioned. My understanding from those steps is that emails are parsed into mg_autoemail first. Then emails are sent with the correct template variables based on the Subject. Right after an email is sent its record is moved from mg_autoemail to its respective table, one of mg_postcall, mg_welcome and mg_record based on Subject.
There'll be 2 endpoints; postcall on 8002 and billingcodes on 8001. Mailgun will send the received email details to postcall endpoint. On specifications step 5 it says that email data sent to postcall endpoint will be parsed into mg_autoemail, mg_welcome and mg_record based on the subject. But previously emails were being stored in mg_autoemail first, which one is true? On the next step it talks about polling the tables. I guess the emails were supposed to be stored in mg_autoemail first, then by polling it every 3min. and comparing the tokens with other tables it's finding new emails to be processed.
Finally, after correct replacements/additions/removals with the right template the email is sent then it's parsed from mg_autoemail into its respective table based on subject.
Anyway, general view is clear but I'll need some help for the details like above. I'll use flask with mysql and expect this to take a week, thanks.