GithubHelp home page GithubHelp logo

happyfox's Introduction

HappyFox Interview Project

Introduction

This project is part of the HappyFox interview process. It includes functionality to fetch and process emails based on certain rules, using Python and the Gmail API.

Folder Structure

happyfox/
│
├── alembic/                  # Alembic migration scripts and settings
│   ├── env.py                # Alembic environment configuration
│   ├── script.py.mako        # Alembic script template
│   └── versions/             # Alembic migration versions
│
├── db/                       # Database models and engine setup
│   ├── __init__.py
│   ├── engine.py             # SQLAlchemy database engine setup
│   └── models.py             # SQLAlchemy database models
│
├── rule_processor/           # Rule processing logic
│   ├── __init__.py
│   ├── constants.py          # Rule processor constants
│   ├── rule_processor.py     # Main rule processing module
│   └── rules.json            # JSON file with rules for processing emails
│
├── docs/                         # Documentation files
│   ├── HappyFox_Backend_Assignment.pdf
│   ├── HappyFox_Interview_Task_FR_NFR.pdf
│   └── Setting_Up_OAuth_for_Gmail_and_Obtaining_Credentials.pdf
│
├── alembic.ini               # Alembic configuration file
├── constants.py              # Global constants
├── credentials.json          # Gmail API credentials (ignore using .gitignore)
├── docker-compose.yml        # Docker Compose file for running PostgreSQL
├── fetch_email.py            # Script to fetch emails
├── process_email.py          # Script to process emails
├── pyproject.toml            # Poetry project file
├── poetry.lock               # Poetry lock file (dependencies)
└── token.pickle              # Gmail API token (ignore using .gitignore)

Prerequisites

  • Python 3.10
  • Poetry for Python dependency management
  • Gmail API credentials in credentials.json
  • Docker and Docker Compose for running the PostgreSQL database
  • Virtual Env for this project setup

Setup and Installation

Installing Dependencies

  1. Install Poetry: Follow the instructions at Poetry Installation.
  2. Install project dependencies:
    poetry install

Database Setup with Docker Compose

  1. Ensure Docker is installed and running.
  2. Use Docker Compose to start a PostgreSQL instance:
    docker-compose up -d
  3. Update the DATABASE_URL in alembic.ini and db/engine.py to point to your Dockerized PostgreSQL instance.
  4. Run Alembic migrations to set up the database schema:
    poetry run alembic upgrade head

Gmail API Setup

  1. Place your credentials.json file from the Google Developers Console in the project root.
  2. The first run will open a browser to authenticate and generate token.pickle.

Running the Application

To fetch and process emails:

python fetch_email.py
python process_email.py

Testing

  • Unit tests can be added in a tests/ directory.
  • Use pytest to run tests:
    coverage run -m unittest discover -s tests

Note on Production Readiness

This project was developed as part of an interview task. While the code has been written with production setup and best practices in mind, it is not intended for deployment in a production environment as-is. This codebase serves as a demonstration of coding standards, design patterns, and practices suitable for a production-level application, but further testing, development, and security considerations are required before actual production use.

License

MIT

happyfox's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.