Leads Management UI is a comprehensive web application designed to manage leads effectively. It integrates with Google SSO and Google Drive APIs to offer a seamless and efficient user experience. The application is built using Python, Django, PostgreSQL, Docker, and AWS services.
- User Authentication: Secure login with Google SSO.
- Lead Management: Create, read, update, and delete leads.
- Google Drive Integration: Sync leads data with Google Drive and Docs.
- Secure Storage: Store leads information securely in a PostgreSQL database.
- Scalable Deployment: Deploy on AWS ECS and EC2 with PostgreSQL compatibility and KMS Secrets Manager.
- Backend: Python, Django
- Frontend: HTML, CSS, JavaScript
- Database: PostgreSQL
- Authentication: Google SSO
- Integration: Google Drive API, Google Docs API
- Deployment: Docker, AWS ECS, EC2, AWS Aurora (Postgres compatibility), AWS KMS
- Python 3.x
- Docker
- AWS account with necessary permissions
- Google Cloud Platform account for API access
-
Google Console Project Setup:
- Set up a project on the Google Cloud Console.
- Enable the Google Drive and Google Docs APIs.
- Create OAuth 2.0 Client IDs for web applications to get your
GOOGLE_CLIENT_ID
andGOOGLE_CLIENT_SECRET
. - Follow the instructions provided by the django-allauth library to configure Google OAuth.
-
AWS Account:
- Create an ECR repository named
leads-management
. - Ensure you have an S3 bucket for storing deployment configurations.
- Ensure you have the necessary IAM roles and policies.
- Create an ECR repository named
-
Clone the repository:
git clone https://github.com/YourUsername/Leads-Management-UI.git cd Leads-Management-UI
-
Set up a virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Create a
.env
file in the project root and add the following environment variables:
GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret GOOGLE_API_KEY=your_google_api_key AWS_ACCESS_KEY_ID=your_aws_access_key_id AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key DATABASE_URL=your_database_url
- Create a
-
Run the Django migrations:
python manage.py migrate
-
Start the development server:
python manage.py runserver
-
Build the Docker image:
docker build -t leads-management-ui .
-
Run the Docker container:
docker run -p 8000:8000 --env-file .env leads-management-ui
-
Build the Docker image:
docker build -t leads-management-ui .
-
Run the Docker container:
docker run -p 8000:8000 --env-file .env leads-management-ui
This project uses GitHub Actions to automate the deployment process to AWS ECS. Follow these steps to set up and deploy the application:
-
Fork the repository:
git clone https://github.com/YourUsername/Leads-Management-UI.git cd Leads-Management-UI
-
Set up AWS Resources:
- Create an ECR repository named
leads-management
. - Ensure you have an S3 bucket for storing deployment configurations.
- Ensure you have the necessary IAM roles and policies.
- Create an ECR repository named
-
Populate GitHub Secrets:
- Go to your GitHub repository.
- Navigate to Settings > Secrets and variables > Actions.
- Add the following secrets:
AWS_ACCESS_KEY_ID
: Your AWS Access Key ID.AWS_SECRET_ACCESS_KEY
: Your AWS Secret Access Key.DBKMSKEYID
: Your AWS KMS Key ID for database encryption.BUCKET_NAME
: The name of your S3 bucket for deployment files.DEPLOYMENTS_PATH
: The path within your S3 bucket for deployment files.
-
Populate GitHub Variables:
- Go to your GitHub repository.
- Navigate to Settings > Secrets and variables > Actions.
- Add the following variables:
AWS_REGION
: Your preferred AWS region, e.g.,ap-south-1
.
-
GitHub Actions Workflow:
- The GitHub Actions workflow is defined in the file located at
<repo root>/.github/workflows/deploy.yml
. - This workflow will automatically build and deploy your application to AWS ECS on every push to the
wip
ormaster
branch.
- The GitHub Actions workflow is defined in the file located at
The workflow performs the following steps:
- Check out code: Checks out the code from the repository.
- Configure AWS credentials: Configures AWS credentials using IAM role for GitHub Actions.
- Login to Amazon ECR: Logs into Amazon ECR.
- Sync AWS deployment config files: Syncs deployment configuration files to S3.
- Ensure ECR Repository: Ensures the ECR repository exists using CloudFormation.
- Build, tag, and push image to Amazon ECR: Builds the Docker image, tags it, and pushes it to Amazon ECR.
- Deploy CloudFormation stack: Deploys the CloudFormation stack using the parameters and template stored in S3.
name: Build and Deploy to ECS
on:
push:
branches:
- wip
- master
env:
AWS_REGION: ap-south-1 # set this to your preferred AWS region, e.g. us-west-1
ECR_REPOSITORY: leads-management # set this to your Amazon ECR repository name
ECS_TASK_DEFINITION: ./.aws/task-definition.json
CONTAINER_NAME: ${{ github.event.repository.name }}
PROJECT_NAME: ${{ github.event.repository.name }}
PROJECT_DEPLOYMENTS_S3_URL: https://${{ vars.BUCKET_NAME }}.s3.${{ vars.AWS_REGION }}.amazonaws.com/${{ vars.DEPLOYMENTS_PATH }}/${{ github.event.repository.name }}
permissions:
id-token: write # required to use OIDC authentication
contents: read # required to checkout the code from the repo
jobs:
build:
name: Build Image
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/[email protected]
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::129190006344:role/Github-Actions
role-duration-seconds: 900 # the ttl of the session, in seconds.
aws-region: ap-south-1 # use your region here.
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Sync AWS deployment config files
id: sync-deployment-files
run: |
aws s3 sync .aws/ s3://${{ vars.BUCKET_NAME }}/${{ vars.DEPLOYMENTS_PATH }}/${{ env.PROJECT_NAME }}
- name: Ensure ECR Repository
id: ensure-ecr-repository
uses: aws-actions/aws-cloudformation-github-deploy@v1
with:
name: ecr-repository-${{ env.PROJECT_NAME }}
template: ${{ env.PROJECT_DEPLOYMENTS_S3_URL }}/cf/ecr.yaml
parameter-overrides: RepositoryName=${{ env.ECR_REPOSITORY }}
no-fail-on-empty-changeset: "1"
termination-protection: "1"
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ steps.ensure-ecr-repository.outputs.RepositoryUri }}
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Deploy cloudformation stack
id: deploy-cloudformation-stack
uses: aws-actions/aws-cloudformation-github-deploy@v1
with:
name: ${{ env.PROJECT_NAME }}-stack
template: ${{ env.PROJECT_DEPLOYMENTS_S3_URL }}/${{ vars.DEPLOYMENTS_PATH }}/${{ env.PROJECT_NAME }}/cf/master.yaml
parameter-overrides: ProjectName=${{ env.PROJECT_NAME }},ECRImage=${{ steps.build-image.outputs.image }},DbKmsKeyId=${{secrets.DBKMSKEYID}},ProjectDeploymentsS3Url=${{ env.PROJECT_DEPLOYMENTS_S3_URL }}
no-fail-on-empty-changeset: "1"
termination-protection: "1"
This setup ensures that your application is automatically built, tagged, pushed to ECR, and deployed to ECS whenever changes are pushed to the specified branches. Adjust the IAM role ARN and other variables according to your setup.
- Login: Use your Google account to log in.
- Manage Leads: Add, view, update, and delete leads.
- Sync with Google Drive: Automatically sync your leads data with Google Drive and Docs for easy access and sharing.
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature
). - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Thanks to Google Cloud Platform for providing robust APIs.
- Special thanks to AWS for their cloud services.