80 lines
3.5 KiB
Markdown
80 lines
3.5 KiB
Markdown
# EAMCO Playground
|
|
|
|
**EAMCO Playground** is a non-production, sandboxed microservice used for development, testing, and experimentation. It provides a safe and isolated environment for prototyping new features and refining complex algorithms before they are integrated into the core production services.
|
|
|
|
Think of this as the R&D department's workshop. It often contains experimental or alternative versions of logic found in other services like `eamco_auto_api`.
|
|
|
|
[](https://www.python.org/)
|
|
[](https://fastapi.tiangolo.com/)
|
|
[](https://www.postgresql.org/)
|
|
|
|
---
|
|
|
|
## Purpose
|
|
|
|
The primary purpose of the Playground is to facilitate development and testing without affecting live data. Key use cases include:
|
|
|
|
- **Algorithm Refinement**: Testing new versions of the "K-Factor" (house consumption factor) calculation, as seen in `app/script/update_auto.py`.
|
|
- **New Integrations**: Evaluating new third-party services, such as testing the `pyowm` library as an alternative for weather data.
|
|
- **API Simulation**: Mimicking the endpoints of other microservices to test interactions and data flow in a controlled environment.
|
|
- **Debugging**: Providing a space to replicate and diagnose complex issues found in the production system without the risk of data corruption.
|
|
|
|
**This service should NOT be deployed to a production environment.**
|
|
|
|
---
|
|
|
|
## Key Components
|
|
|
|
- **Experimental Scripts**: The `app/script/` directory contains experimental logic. For example, `update_auto.py` holds a specific implementation of the K-Factor refinement algorithm.
|
|
- **Weather API Integration**: Uses the `pyowm` library to connect to the OpenWeatherMap API, likely for testing purposes.
|
|
- **Simulated API Routers**: Includes routers for `/main`, `/delivery`, `/confirm`, and `/info` that mirror the structure of other services, allowing developers to test frontend interactions or service-to-service communication.
|
|
|
|
---
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.10+
|
|
- A PostgreSQL database (preferably a dedicated development or test instance).
|
|
|
|
### Installation
|
|
|
|
1. **Clone the repository and navigate into it.**
|
|
|
|
2. **Create a virtual environment and install dependencies:**
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. **Configure your environment:**
|
|
The application's configuration is managed by environment variables set in `settings_local.py`, `settings_dev.py`, or `settings_prod.py`. Ensure your database connection URI and any API keys (like for OpenWeatherMap) are set correctly in your chosen settings file.
|
|
|
|
### Running the Service
|
|
|
|
This service is intended for development use.
|
|
|
|
```bash
|
|
export MODE=DEVELOPMENT
|
|
uvicorn main:app --reload --host 0.0.0.0 --port <your_port>
|
|
```
|
|
|
|
---
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
eamco_playground/
|
|
├── app/
|
|
│ ├── models/ # SQLAlchemy ORM models
|
|
│ ├── routers/ # API endpoint definitions for simulating other services
|
|
│ ├── schema/ # Pydantic models
|
|
│ └── script/ # Experimental scripts and algorithms
|
|
├── config.py # Logic for loading environment-specific settings
|
|
├── database.py # SQLAlchemy engine and session setup
|
|
├── main.py # FastAPI application entry point
|
|
├── requirements.txt # Python dependencies
|
|
└── README.md # This file
|
|
``` |