Orange County Lettings is a real estate rental and user profile management web application built with Django.
This project (Version 2.0) introduces a modern, modular architecture, transitioning from a monolithic structure to independent Django apps (lettings, profiles, and oc_lettings_site). It also integrates DevOps practices, including automated testing, CI/CD pipelines, containerization, and error tracking.
- Modular Architecture: Codebase separated into logical Django apps for better maintainability.
- Code Quality: Enforced PEP8 standards using
Flake8and comprehensive unit testing viaPytest(Coverage > 80%). - Error Tracking: Integrated with Sentry for real-time error logging and performance monitoring.
- Containerization: Fully Dockerized application for consistent environments across local and production.
- CI/CD Pipeline: Automated testing, building, and deployment using GitHub Actions.
- Documentation: Project documentation generated with Sphinx and hosted on Read the Docs.
- Python 3.10
- Git
- Docker (optional, for local container testing)
-
Clone the repository:
git clone https://github.com/Mnr04/OCLettings.git cd oclettings -
Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate
#On Windows use:
venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
SECRET_KEY=your_local_secret_key
SENTRY_DSN=your_sentry_dsn_url- Run the application:
python manage.py runserverThe site will be available at http://localhost:8000.
This project uses pytest for unit testing and flake8 for linting.
Run tests and check coverage:
python -m pytest --cov=.Run linting:
flake8The technical documentation is built with Sphinx and hosted on Read the Docs. To build the documentation locally:
cd doc
make html
open build/html/index.htmlThe deployment process is fully automated using GitHub Actions, Docker Hub, and Render.
High-Level Architecture
-
Continuous Integration (CI): On every push or pull request to any branch, GitHub Actions runs flake8 to check code style and pytest to ensure test coverage is above 80%.
-
Continuous Delivery/Deployment (CD): If a push is made to the master branch and the tests pass, GitHub Actions builds a Docker image and pushes it to Docker Hub. Finally, it triggers a webhook to inform Render that a new image is available.
-
Hosting: Render pulls the latest Docker image from Docker Hub and deploys the updated application. Static files are served efficiently using WhiteNoise.
Required Configuration
For the deployment pipeline to work, the following secrets must be configured in your GitHub
Repository Secrets:
-
DOCKER_USERNAME: Your Docker Hub username.
-
DOCKER_PASSWORD: Your Docker Hub access token.
-
RENDER_DEPLOY_HOOK: The unique deploy hook URL provided by Render.
Additionally, the following environment variables must be configured in your Render Web Service settings:
-
SECRET_KEY: A strong, random secret key for Django production.
-
SENTRY_DSN: Your Sentry DSN key for error tracking.
How to Deploy To release a new version of the application:
-
Create a new branch for your feature or bug fix (git checkout -b feature-name).
-
Commit your changes and push the branch to GitHub.
-
Verify that the GitHub Actions tests pass on your branch.
-
Merge your branch into the master branch.
-
The pipeline handles the rest! Monitor the GitHub Actions tab to watch the build, and check your Render dashboard to see the app go live.