new readme #25
@@ -1,93 +1,106 @@
|
|||||||
# birdcam2
|
# BirdCam2: A Flask-Based Camera Monitoring System
|
||||||
|
|
||||||
|
A lightweight, Python-based system for monitoring and managing Raspberry Pi cameras using Flask, SQLAlchemy, and modern Python best practices.
|
||||||
|
|
||||||
|
## 🚀 Overview
|
||||||
|
|
||||||
## Getting started
|
BirdCam2 is a simple yet robust application designed to monitor camera status and log events in real time. Built with Flask and SQLAlchemy, it provides:
|
||||||
|
- Real-time camera status tracking (`running` state).
|
||||||
|
- Event logging for camera actions (`start`, `stop`) with IP addresses and timestamps.
|
||||||
|
- A clean, maintainable architecture using modern Python 3.12 features and type hints.
|
||||||
|
|
||||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
It's ideal for hobbyists, developers, or IoT projects where you need to track camera activity from a central dashboard or script.
|
||||||
|
|
||||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
## 🔧 Key Features
|
||||||
|
|
||||||
## Add your files
|
- ✅ Real-time camera status (e.g., whether a camera is running or not).
|
||||||
|
- ✅ Event logging with full metadata (action, IP address, timestamp).
|
||||||
|
- ✅ Automatic creation of status records if missing.
|
||||||
|
- ✅ Type-safe, well-documented code with full type hints.
|
||||||
|
- ✅ Modern Python practices:
|
||||||
|
- Uses Python 3.12 with `__future__.annotations`.
|
||||||
|
- Leverages `dataclasses`-like patterns with `Mapped` and `mapped_column`.
|
||||||
|
- Includes comprehensive linting via **Black**, **Ruff**, and **Mypy**.
|
||||||
|
- ✅ Automated test coverage with `pytest` and `pytest-cov`.
|
||||||
|
|
||||||
* [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
|
## 📦 Dependencies
|
||||||
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
|
||||||
|
|
||||||
```
|
| Package | Version | Purpose |
|
||||||
cd existing_repo
|
|----------------------|---------------|------------------------------------------|
|
||||||
git remote add origin https://gitlab.com/akettel/birdcam2.git
|
| `Flask` | `^3.0` | Web framework for serving the app |
|
||||||
git branch -M main
|
| `Flask-SQLAlchemy` | `^3.1.1` | ORM for database interactions |
|
||||||
git push -uf origin main
|
| `Pillow` | `^12.1.1` | Image processing (for camera previews) |
|
||||||
|
| `Gunicorn` | `^25.1.0` | Production WSGI server |
|
||||||
|
| `Pytest` | `^9.0.3` | Testing framework |
|
||||||
|
| `Pytest-Cov` | `^7.1.0` | Test coverage reporting |
|
||||||
|
| `Black` / `Ruff` | `^26.0` / `^0.4` | Code formatting and linting |
|
||||||
|
| `Mypy` | `^1.10` | Static type checking |
|
||||||
|
|
||||||
|
> ✅ All dependencies are pinned for stability and compatibility.
|
||||||
|
|
||||||
|
## 🛠️ Setup & Installation
|
||||||
|
|
||||||
|
1. Clone the repository:
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/your-username/birdcam2.git
|
||||||
|
cd birdcam2
|
||||||
```
|
```
|
||||||
|
|
||||||
## Integrate with your tools
|
2. Install dependencies:
|
||||||
|
```bash
|
||||||
|
pip install -e .
|
||||||
|
```
|
||||||
|
|
||||||
* [Set up project integrations](https://gitlab.com/akettel/birdcam2/-/settings/integrations)
|
3. Run the app:
|
||||||
|
```bash
|
||||||
|
gunicorn -w 1 -b 0.0.0.0:5000 app:app
|
||||||
|
```
|
||||||
|
|
||||||
## Collaborate with your team
|
Or use Flask’s built-in dev server:
|
||||||
|
```bash
|
||||||
|
flask run
|
||||||
|
```
|
||||||
|
|
||||||
* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
|
## 📝 How It Works
|
||||||
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
|
|
||||||
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
|
|
||||||
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
|
|
||||||
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
||||||
|
|
||||||
## Test and Deploy
|
### Camera Status
|
||||||
|
- The `CameraStatus` model tracks a single camera’s running state.
|
||||||
|
- On startup, it ensures a status record exists (ID = 1).
|
||||||
|
- The `get()` and `set_running()` methods allow safe access and updates.
|
||||||
|
|
||||||
Use the built-in continuous integration in GitLab.
|
### Camera Events
|
||||||
|
- Every time a camera action occurs (`start` or `stop`), an event is logged.
|
||||||
|
- Events include:
|
||||||
|
- Action type (`start` / `stop`)
|
||||||
|
- Client IP address
|
||||||
|
- Timestamp with timezone support
|
||||||
|
- The `recent()` method allows retrieval of the latest events (e.g., for logging or dashboard display).
|
||||||
|
|
||||||
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
|
## 🧪 Testing
|
||||||
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
|
|
||||||
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
|
|
||||||
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
|
|
||||||
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
|
|
||||||
|
|
||||||
***
|
The project includes full test coverage using `pytest` with coverage reporting:
|
||||||
|
|
||||||
# Editing this README
|
```bash
|
||||||
|
pytest --cov=src --cov-report=term-missing
|
||||||
|
```
|
||||||
|
|
||||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
Tests are located in the tests/ directory and cover:
|
||||||
|
- Status retrieval and updates.
|
||||||
## Suggestions for a good README
|
- Event logging and retrieval.
|
||||||
|
- Edge cases (e.g., missing status records).
|
||||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
## 📝 Development Workflow
|
||||||
|
✅ Code is formatted with Black and linted with Ruff.
|
||||||
## Name
|
✅ Static type checking is enforced using Mypy.
|
||||||
Choose a self-explaining name for your project.
|
✅ All code uses consistent naming and formatting.
|
||||||
|
✅ All public APIs are documented with docstrings.
|
||||||
## Description
|
## ⚙️ Future Improvements
|
||||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
- Add support for multiple cameras.
|
||||||
|
- Integrate with a web dashboard (e.g., using Vue.js or Streamlit).
|
||||||
## Badges
|
- Add camera preview functionality via HTTP endpoints.
|
||||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
- Support for MQTT or other event-driven systems.
|
||||||
|
- Add user authentication or role-based access.
|
||||||
## Visuals
|
## 📚 License
|
||||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
This project is open-source and available under the MIT License.
|
||||||
|
## 🙌 Contributing
|
||||||
## Installation
|
Contributions are welcome! Please open an issue or submit a pull request with clear descriptions and tests.
|
||||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
📬 Contact: Andrew Kettel andrew.kettel@gmail.com
|
||||||
|
|
||||||
## Usage
|
|
||||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
||||||
|
|
||||||
## Support
|
|
||||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
||||||
|
|
||||||
## Roadmap
|
|
||||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
State if you are open to contributions and what your requirements are for accepting them.
|
|
||||||
|
|
||||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
||||||
|
|
||||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
||||||
|
|
||||||
## Authors and acknowledgment
|
|
||||||
Show your appreciation to those who have contributed to the project.
|
|
||||||
|
|
||||||
## License
|
|
||||||
For open source projects, say how it is licensed.
|
|
||||||
|
|
||||||
## Project status
|
|
||||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
||||||
Reference in New Issue
Block a user