---
# System prepended metadata

title: Mesopro Project Guide

---

# Mesopro Project Guide

## Models
1. User
    * first_name
    * last_name
    * phone_number
    * country    
    * company_id
    * is_admin
        ### Roles
        Admin
            -can edit user
            -can add user
            -can delete user
        
2. Company
    * name
    * website
    * street address
    * zip code
    * city
    * country
    * business activity
    * company size
    * current number of contacts
    * from_user_email
    * from_username
3. Emails
    * uid
    * email text
    * recipient email
    * from name
    * from email
    * attachments
5. Api Keys
    * uid
    * name
    * key
    * revoked  
6. Sms
7. Account *
    * company_id
    * accouint_balance
    * account_identifier
8. Account recharge *
    * account_id
    * amount
    * mode_of_payment
    * paid_by
9. Templates
    * user_id
    * html_part
    * text_part
    * subject_part
    * tracking_id
10. Group
    * name
    * user_id
11. Email recipients
    * group_id
    * email
## Controllers
1. UserController
2. EmailController
3. SmsController
4. PaymentsController
5. TemplateController
6. EmailGroupController
## Migrations
1. user
2. organisation
3. emails
4. sms
5. api_keys
## Relationships
1. OneToMany-user:organization
2. OneToMany-Email:organization
3. OneToMany-user:api_keys
4. ManyToMany-email:attachments
## Packages
1. Laravel passport
2. Vue Js
3. phpmailer
4. aws php sdk
5. dropzone js
## Milestones
1. Project Setup
    * ~~laravel new project~~
    * ~~set database connections~~
    * ~~php artisan make:model Company -mc~~
    * ~~php artisan make:model Email -mc~~
    * ~~php artisan make:model ApiKey -mc~~
    * ~~set migration properties~~
    * ~~migrate~~
    * ~~define relationships~~
    * ~~write seeds~~
    * ~~scaffold vue files with laravel ui~~
    * ~~set welcome page, add a vue initial component~~
2. Authentication
    * download passport package
    * set all configurations
    * return access token
    * create personal grant tokens
    * assign the tokens to a company
    * create a middleware that checks for auth in the headers
    * create routes for email sending
    * fetch request header data $token = $request->bearerToken();
3. Test Email Api Endpoint
    * create routes for email sending
    * fetch request header data `$token = $request->bearerToken();`
## Routes
1. get user - `http://localhost/api/user` -> get
2. generate key
    url:`http://localhost/api/generate_key`
    method: `post`
    auth: `Bearer $token`
3. send email 
    url: `http://localhost/api/v1/enviar/email`
    auth: Either include the api key in the request body or in the request header.
    body: 
    ```
    {
        subject: 'Order receival',
        body:'Hello your order has been received',
        recipient_email: ['example@org.com'],
        from_email: 'example@email.com',
        from_name: 'example org',
        api_name: 'EM004556',
        api_key: 'iuye3456789siouyt789ihs8u9dwyh',
        attachment: '/home/dtel/documents/doc.doc'
    }
    ```
4. email status
## Policies
1. ApiKey Policy
    * only the admin can created an api key
    * only a user can delete an api key
    * only the user can update an api key
2. UserPolicy
    * create,update, patch
## Scenarios
1. Api send single message
2. Api send single message to many email addresses
3. Dashboard send email to single person
4. Dashboard send email to many people-Upload different file or use existing email groups
5. Api create a user group
6. Dashboard create a user group
7. If an email request contains a email from or email to, they automatically override the ones registered when registering the company.


## Good to note
1. When sending mail and you pass both the html data and raw data, html data will take precedence over the raw data. So its advisable to work with html data when sending mail.
2. Amazon ses currently does not support sending attachments with a templated email.
### Proposed solution
* pass template name each time you make a request.

## Mesopro Sms
### Routes
1. Api send sms
    * url: `http://localhost:8000/api/v1/enviar/email`
    * request body: 
        `to: +254706715363`,
        `from: Fulusi`,
        `message: 'Amazingly few discotheques provide jukeboxes'`,
        `api_key`: `jkdksj83939fjndionh3im23`,
        `api_username`: `EM001`,
        `t`
        
## Assets
### Tailwind
#### Standard classes
* Normal Fonts
    * font-light
    * text-sm 
* Headers
    * h3
* Backgrounds
    * bg-gray-200
    
        

        
     
    

