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.
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)
- 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
- Install Poetry: Follow the instructions at Poetry Installation.
- Install project dependencies:
poetry install
- Ensure Docker is installed and running.
- Use Docker Compose to start a PostgreSQL instance:
docker-compose up -d
- Update the
DATABASE_URL
inalembic.ini
anddb/engine.py
to point to your Dockerized PostgreSQL instance. - Run Alembic migrations to set up the database schema:
poetry run alembic upgrade head
- Place your
credentials.json
file from the Google Developers Console in the project root. - The first run will open a browser to authenticate and generate
token.pickle
.
To fetch and process emails:
python fetch_email.py
python process_email.py
- Unit tests can be added in a
tests/
directory. - Use
pytest
to run tests:coverage run -m unittest discover -s tests
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.
MIT