From 0fffbcfba4718a649697d970d879aba4fc552593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pelletier?= Date: Sun, 11 May 2025 05:23:24 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=9F=20Initial=20project=20setup=20with?= =?UTF-8?q?=20backend=20(FastAPI),=20frontend=20(Streamlit),=20Milvus,=20a?= =?UTF-8?q?nd=20Flowise=20in=20Docker=20=F0=9F=A7=B1=F0=9F=93=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added backend infrastructure (FastAPI, Dockerfile, requirements) * Set up frontend (Streamlit, Dockerfile, requirements) * Configured docker-compose with Milvus and Flowise services * Created project structure with .env.template and .dockerignore * Added initial gitignore and project metadata --- .env.template | 4 +++ .gitignore | 1 + 000-create-directories.sh | 16 ++++++++++ README.md | 13 +++++++- backend/.dockerignore | 12 +++++++ backend/Dockerfile | 17 ++++++++++ backend/main.py | 67 +++++++++++++++++++++++++++++++++++++++ backend/requirements.txt | 3 ++ backend/run.sh | 1 + docker-compose.yml | 44 +++++++++++++++++++++++++ frontend/.dockerignore | 12 +++++++ frontend/Dockerfile | 20 ++++++++++++ frontend/requirements.txt | 2 ++ pyproject.toml | 6 ++++ 14 files changed, 217 insertions(+), 1 deletion(-) create mode 100644 .env.template create mode 100644 000-create-directories.sh create mode 100644 backend/.dockerignore create mode 100644 backend/Dockerfile create mode 100644 backend/main.py create mode 100644 backend/requirements.txt create mode 100644 backend/run.sh create mode 100644 docker-compose.yml create mode 100644 frontend/.dockerignore create mode 100644 frontend/Dockerfile create mode 100644 frontend/requirements.txt create mode 100644 pyproject.toml diff --git a/.env.template b/.env.template new file mode 100644 index 0000000..cd85ba0 --- /dev/null +++ b/.env.template @@ -0,0 +1,4 @@ +MILVUS_HOST= +MILVUS_PORT= +BACKEND_URL= +FLOWISE_PORT= diff --git a/.gitignore b/.gitignore index ab3e8ce..5566902 100644 --- a/.gitignore +++ b/.gitignore @@ -162,3 +162,4 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +/.idea/ diff --git a/000-create-directories.sh b/000-create-directories.sh new file mode 100644 index 0000000..eb52994 --- /dev/null +++ b/000-create-directories.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Create core directories +mkdir -p backend frontend + +# Create Dockerfiles for each service +touch backend/Dockerfile frontend/Dockerfile + +# Create placeholder for environment files +touch .env + +# Create directory for Milvus data persistence +mkdir -p ./volumes/milvus + +# Create directory for Flowise data persistence +mkdir -p ./volumes/flowise diff --git a/README.md b/README.md index 56b4a9f..135b0c8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ # systeme-retro-contenu -Système de création de contenu rétrospectif \ No newline at end of file +Système de création de contenu rétrospectif + +## Frontend + +## Backend + +| Route | Method | Description | +|--------------------|--------|----------------------| +| /import/data | POST | Import raw data | +| /analyse/{data_id} | GET | Analyse stored data | +| /export/{data_id} | GET | Export analysed data | +| /generate/content | POST | Generate new content | \ No newline at end of file diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..0736209 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,12 @@ +# Python build and runtime artifacts +__pycache__/ +*.pyc +*.pyo +venv/ +requirements/ + +# Version control +.git + +# OS-specific files +.DS_Store diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..5487e76 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,17 @@ +# Use the official Python 3.13 image as the base +FROM python:3.13-slim + +# Set the working directory inside the container +WORKDIR /app + +# Expose the port the app will run on +EXPOSE 5000 + +# Copy the current directory contents into the container +COPY . . + +# Install dependencies (ensure you have a requirements.txt file) +RUN pip install --no-cache-dir -r requirements.txt + +# Command to run the app using Uvicorn +CMD ["uvicorn", "main:app", "--reload", "--host", "0.0.0.0", "--port", "5000"] diff --git a/backend/main.py b/backend/main.py new file mode 100644 index 0000000..794ca49 --- /dev/null +++ b/backend/main.py @@ -0,0 +1,67 @@ +from fastapi import FastAPI, APIRouter, HTTPException +import uuid + +app = FastAPI(title="Retro API", description="Retro content management system") + +# Routers +import_router = APIRouter(prefix="/import", tags=["Import"]) +analyse_router = APIRouter(prefix="/analyse", tags=["Analyse"]) +export_router = APIRouter(prefix="/export", tags=["Export"]) +generate_router = APIRouter(prefix="/generate", tags=["Generate"]) + +# Sample data storage (replace with Milvus/DB integration) +data_store = {} + +# Import Router +@import_router.post("/data") +def import_data(data: dict): + """ + Import data (e.g., text, files, or structured data). + """ + data_id = str(uuid.uuid4()) + data_store[data_id] = data + return {"message": "Data imported successfully", "data_id": data_id} + +# Analyse Router +@analyse_router.get("/{data_id}") +def analyse_data(data_id: str): + """ + Analyse imported data (e.g., sentiment, keywords, or patterns). + """ + if data_id not in data_store: + raise HTTPException(status_code=404, detail="Data not found") + # Placeholder for analysis logic + return { + "data_id": data_id, + "analysis": {"word_count": len(data_store[data_id].get("text", ""))}, + } + +# Export Router +@export_router.get("/{data_id}") +def export_data(data_id: str): + """ + Export analysed data (e.g., as JSON, CSV, or PDF). + """ + if data_id not in data_store: + raise HTTPException(status_code=404, detail="Data not found") + return { + "data_id": data_id, + "content": data_store[data_id], + "status": "exported", + } + +# Generate Router +@generate_router.post("/content") +def generate_content(prompt: str): + """ + Generate new content (e.g., text, images, or summaries). + """ + # Placeholder for generation logic (e.g., LLM, AI model) + generated = {"response": f"Generated content based on: {prompt}"} + return {"message": "Content generated", "data": generated} + +# Include routers in the main app +app.include_router(import_router) +app.include_router(analyse_router) +app.include_router(export_router) +app.include_router(generate_router) diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..81a4930 --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,3 @@ +fastapi +uvicorn +pydantic \ No newline at end of file diff --git a/backend/run.sh b/backend/run.sh new file mode 100644 index 0000000..3a7b15d --- /dev/null +++ b/backend/run.sh @@ -0,0 +1 @@ +uvicorn main:app --reload --host 0.0.0.0 --port 8000 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ce48176 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,44 @@ +version: '3.8' + +services: + backend: + build: + context: ./backend + dockerfile: Dockerfile + ports: + - "5000:5000" + environment: + - MILVUS_HOST=${MILVUS_HOST} + - MILVUS_PORT=${MILVUS_PORT} + depends_on: + - milvus + + frontend: + build: + context: ./frontend + dockerfile: Dockerfile + ports: + - "8501:8501" + environment: + - BACKEND_URL=${BACKEND_URL} + depends_on: + - backend + + milvus: + image: milvusdb/milvus:latest + ports: + - "19530:19530" + volumes: + - milvus_data:/var/lib/milvus + + flowise: + image: flowiseai/flowise:latest + ports: + - "3000:3000" + environment: + - PORT=3000 + depends_on: + - backend + +volumes: + milvus_data: diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..0736209 --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,12 @@ +# Python build and runtime artifacts +__pycache__/ +*.pyc +*.pyo +venv/ +requirements/ + +# Version control +.git + +# OS-specific files +.DS_Store diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..86fc090 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,20 @@ +# Use an official Python runtime as a parent image +FROM python:3.13-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy requirements file first to leverage Docker layer caching +COPY requirements.txt . + +# Install any needed packages (e.g., streamlit and dependencies) +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the current directory contents into the container at /app +COPY . . + +# Make port 8501 available (Streamlit default port) +EXPOSE 8501 + +# Run the Streamlit app +CMD ["streamlit", "run", "app.py"] diff --git a/frontend/requirements.txt b/frontend/requirements.txt new file mode 100644 index 0000000..917c82a --- /dev/null +++ b/frontend/requirements.txt @@ -0,0 +1,2 @@ +streamlit + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..dc04b0e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[project] +name = "systeme-retro-contenu" +version = "0.1.0" +description = "Système de création de contenu rétrospectif - Backend" +requires-python = ">=3.13" +dependencies = []