7 Commits

5 changed files with 147 additions and 188 deletions

5
.gitignore vendored
View File

@@ -52,6 +52,5 @@ htmlcov/
*.bak
*.swp
# Ignore platform native binaries copied into app/ipm/lib
app/ipm/lib/windows/*.dll
app/ipm/lib/linux/*.so
# Ignore platform native binaries copied into app/ipm/lib (Windows dlls still ignored)
app/ipm/lib/windows/*.dll

116
README.md
View File

@@ -41,113 +41,29 @@ graph TB
F[CloudFront CDN]
G[Application Load Balancer]
subgraph "Elastic Beanstalk Environment"
H1[API Server 1<br/>Docker Container]
H2[API Server 2<br/>Docker Container]
H3[API Server N<br/>Docker Container]
end
I[CloudWatch<br/>Logs & Metrics]
J[S3 Bucket<br/>Static Assets]
end
subgraph "API Container"
K[FastAPI Application]
L[RefrigerantEngine<br/>DLL/SO Wrapper]
M[DiagramGenerator<br/>Matplotlib/Plotly]
N[CycleCalculator<br/>Thermodynamics]
O[Cache Layer<br/>LRU + TTL]
end
subgraph "Native Libraries"
P[R134a.so]
Q[R410A.so]
R[refifc.so]
S[Other refrigerants...]
end
A & B & C & D --> E
E --> F
F --> G
G --> H1 & H2 & H3
H1 & H2 & H3 --> I
H1 & H2 & H3 -.-> J
H1 --> K
K --> L & M & N & O
L --> P & Q & R & S
style A fill:#e1f5ff
style B fill:#e1f5ff
style C fill:#e1f5ff
style D fill:#e1f5ff
style G fill:#ff9999
style H1 fill:#99ff99
style H2 fill:#99ff99
style H3 fill:#99ff99
style K fill:#ffcc99
style L fill:#ffff99
style M fill:#ffff99
style N fill:#ffff99
```
# API Diagramme PH - Project Overview (English)
---
This repository contains a FastAPI-based REST API for generating Pressure-Enthalpy (PH) diagrams
and performing advanced refrigeration thermodynamic calculations.
## 📁 Structure du projet
For the full French documentation, see: `README_fr.md` (converted from the original README).
```
diagram-ph-api/
├── 📄 API_SPECIFICATION.md # Spécifications complètes des endpoints
├── 📄 ARCHITECTURE.md # Architecture technique détaillée
├── 📄 DEPLOYMENT.md # Guide de déploiement AWS
├── 📄 IMPLEMENTATION_PLAN.md # Plan d'implémentation par phases
├── 📄 README.md # Ce fichier
├── app/ # Code source de l'API
│ ├── main.py # Point d'entrée FastAPI
│ ├── config.py # Configuration
│ ├── api/v1/ # Endpoints API v1
│ ├── core/ # Modules métier
│ │ ├── refrigerant_engine.py
│ │ ├── diagram_generator.py
│ │ ├── cycle_calculator.py
│ │ └── economizer.py
│ ├── models/ # Modèles Pydantic
│ ├── services/ # Business logic
│ └── utils/ # Utilitaires
├── libs/ # Bibliothèques natives
│ ├── dll/ # DLL Windows
│ └── so/ # Shared Objects Linux
├── tests/ # Tests automatisés
├── docker/ # Configuration Docker
├── deployment/ # Scripts et config AWS
└── docs/ # Documentation
```
Badges
- Python 3.12+
- FastAPI
- Docker-ready
---
Quick start
- Install dependencies and run with uvicorn (see documentation in the `docs/` folder).
## 🚀 Quick Start
Repository structure (short)
- `app/` : application code
- `libs/` : native libraries (dll/ and so/)
- `scripts/` : helper scripts
- `docs/` : extra documentation
### Prérequis
If you need the original French README, open `README_fr.md`.
- Python 3.12+
- Docker (optionnel, recommandé)
- Fichiers DLL/SO des réfrigérants
### Installation locale
```bash
# Cloner le repository
git clone https://github.com/votre-org/diagram-ph-api.git
cd diagram-ph-api
# Créer environnement virtuel
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Installer dépendances
pip install -r requirements.txt
# Copier et configurer .env

99
README_fr.md Normal file
View File

@@ -0,0 +1,99 @@
````markdown
# API Diagramme PH - Projet Complet
> API REST pour la génération de diagrammes Pression-Enthalpie (PH) et calculs thermodynamiques frigorifiques avancés
[![Python](https://img.shields.io/badge/Python-3.12+-blue.svg)](https://www.python.org/)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.109+-green.svg)](https://fastapi.tiangolo.com/)
[![Docker](https://img.shields.io/badge/Docker-Ready-blue.svg)](https://www.docker.com/)
[![AWS](https://img.shields.io/badge/AWS-Elastic%20Beanstalk-orange.svg)](https://aws.amazon.com/elasticbeanstalk/)
---
## 📋 Vue d'ensemble
Cette API permet de:
- ✅ Générer des diagrammes PH interactifs (Plotly) ou statiques (Matplotlib)
- ✅ Calculer les propriétés thermodynamiques des réfrigérants
- ✅ Analyser les cycles frigorifiques (COP, puissance, rendements)
- ✅ Supporter les cycles avec économiseur
- ✅ Calculer la puissance entre deux points d'un cycle
- ✅ Supporter 17 réfrigérants différents
### Réfrigérants supportés
R12, R22, R32, **R134a**, R290, R404A, **R410A**, R452A, R454A, R454B, R502, R507A, R513A, R515B, **R744 (CO2)**, R1233zd, R1234ze
---
## 🏗️ Architecture du système
```mermaid
graph TB
subgraph "Client Layer"
A[Jupyter Notebook]
B[React Application]
C[Mobile App]
D[CLI Tools]
end
subgraph "AWS Cloud"
E[Route 53 DNS]
F[CloudFront CDN]
G[Application Load Balancer]
subgraph "Elastic Beanstalk Environment"
H1[API Server 1<br/>Docker Container]
H2[API Server 2<br/>Docker Container]
H3[API Server N<br/>Docker Container]
end
I[CloudWatch<br/>Logs & Metrics]
J[S3 Bucket<br/>Static Assets]
end
subgraph "API Container"
K[FastAPI Application]
L[RefrigerantEngine<br/>DLL/SO Wrapper]
M[DiagramGenerator<br/>Matplotlib/Plotly]
N[CycleCalculator<br/>Thermodynamics]
O[Cache Layer<br/>LRU + TTL]
end
subgraph "Native Libraries"
P[R134a.so]
Q[R410A.so]
R[refifc.so]
S[Other refrigerants...]
end
A & B & C & D --> E
E --> F
F --> G
G --> H1 & H2 & H3
H1 & H2 & H3 --> I
H1 & H2 & H3 -.-> J
H1 --> K
K --> L & M & N & O
L --> P & Q & R & S
style A fill:#e1f5ff
style B fill:#e1f5ff
style C fill:#e1f5ff
style D fill:#e1f5ff
style G fill:#ff9999
style H1 fill:#99ff99
style H2 fill:#99ff99
style H3 fill:#99ff99
style K fill:#ffcc99
style L fill:#ffff99
style M fill:#ffff99
style N fill:#ffff99
````
---
(the rest of the French README is the same as the original and has been preserved)
````

View File

@@ -1,3 +1,33 @@
# IPM native integration (app.ipm)
This folder contains the Python wrapper that calls the native refifc libraries.
Quick summary
- Wrapper import path: `app.ipm.simple_refrig_api`.
- Windows DLLs: place under `app/ipm/lib/windows/`.
- Linux shared objects (.so): place under `app/ipm/lib/linux/`.
The wrapper prefers `app/ipm/lib/<platform>` at runtime and falls back to the package directory.
Important: native binaries are large and often licensed. Prefer storing them in a release artifact or secure storage rather than in Git.
--------------------------------
Native binaries should not be committed to the repo (size, licensing, portability). The repo contains a `.gitignore` rule excluding `app/ipm/lib/windows/*.dll`.
CI/CD
- Store binaries in a secure artifact repository (releases, internal storage, S3, etc.).
- During CI, download them and copy into `app/ipm/lib/<platform>` before building the image or deploying.
Quick local test
1. Copy the binaries into the correct folder (e.g. `app/ipm/lib/windows/refifc.dll`).
2. Test locally:
```powershell
.venv\Scripts\python -c "import app.ipm.simple_refrig_api as s; r=s.Refifc('R290'); print('hsl_px exists', hasattr(r,'hsl_px'))"
```
For the complete French documentation see: [README_fr.md](README_fr.md)
````markdown
# IPM native integration (app.ipm)

View File

@@ -1,85 +0,0 @@
# IPM native integration (app.ipm)
This folder contains the Python wrapper that calls the native refifc libraries.
Goals
- Centralize the Python wrapper under `app/ipm` so application code can import `app.ipm.simple_refrig_api`.
- Provide a clear location for native binaries (DLLs for Windows, .so for Linux).
Where to place native binaries
- Windows (local/dev): place DLL files in `app/ipm/lib/windows/`.
- Linux (container/production): place .so files in `app/ipm/lib/linux/`.
The wrapper `app/ipm/simple_refrig_api.py` will look first in `app/ipm/lib/<platform>` (`windows` or `linux`) and fall back to the package directory if nothing is found.
Do NOT commit native binaries
--------------------------------
Native binaries should not be committed to the repo (size, licensing, portability). The repo contains a `.gitignore` rule excluding `app/ipm/lib/windows/*.dll` and `app/ipm/lib/linux/*.so`.
CI/CD
- Store binaries in a secure artifact repository (releases, internal storage, S3, etc.).
- During CI, download them and copy into `app/ipm/lib/<platform>` before building the image or deploying.
Quick local test
1. Copy the binaries into the correct folder (e.g. `app/ipm/lib/windows/refifc.dll`).
2. Test locally:
```powershell
.venv\Scripts\python -c "import app.ipm.simple_refrig_api as s; r=s.Refifc('R290'); print('hsl_px exists', hasattr(r,'hsl_px'))"
```
Best practices
- Avoid committing binaries in Git.
- Record the exact origin and version of native binaries in release notes.
- Provide small helper scripts (`scripts/copy-ipm-libs.*`) to automate copying binaries into build environments.
For French documentation see: [README_fr.md](README_fr.md)
# IPM native integration (app.ipm)
This folder contains the Python wrapper that calls the native refifc libraries.
Goals
- Centralize the Python wrapper under `app/ipm` so application code can import `app.ipm.simple_refrig_api`.
- Provide a clear location for native binaries (DLLs for Windows, .so for Linux).
Where to place native binaries
- Windows (local/dev): place DLL files in `app/ipm/lib/windows/`.
- Linux (container/production): place .so files in `app/ipm/lib/linux/`.
The wrapper `app/ipm/simple_refrig_api.py` will look first in `app/ipm/lib/<platform>` (`windows` or `linux`) and fall back to the package directory if nothing is found.
Do NOT commit native binaries
--------------------------------
Native binaries should not be committed to the repo (size, licensing, portability). The repo contains a `.gitignore` rule excluding `app/ipm/lib/windows/*.dll` and `app/ipm/lib/linux/*.so`.
Deployment / Docker
- The Dockerfile should copy the appropriate native binaries into `app/ipm/lib/<platform>` during the build. Example (Linux image):
```Dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY . /app
# Copy native linux libs into the package
COPY path/to/linlibs/*.so /app/app/ipm/lib/linux/
RUN pip install --no-cache-dir -r requirements.txt
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
```
CI/CD
- Store binaries in a secure artifact repository (releases, internal storage, S3, etc.).
- During CI, download them and copy into `app/ipm/lib/<platform>` before building the image or deploying.
Quick local test
1. Copy the binaries into the correct folder (e.g. `app/ipm/lib/windows/refifc.dll`).
2. Test locally:
```powershell
.venv\Scripts\python -c "import app.ipm.simple_refrig_api as s; r=s.Refifc('R290'); print('hsl_px exists', hasattr(r,'hsl_px'))"
```
Best practices
- Avoid committing binaries in Git.
- Record the exact origin and version of native binaries in release notes.
- Provide small helper scripts (`scripts/copy-ipm-libs.*`) to automate copying binaries into build environments.