From a4d73efa77831f219ad92ca07e44cbfd47ebe262 Mon Sep 17 00:00:00 2001 From: ReLoia Date: Sun, 12 Apr 2026 00:27:30 +0200 Subject: [PATCH] chore: restructure project directory and update Dockerfile paths --- Dockerfile | 2 +- README.md | 2 +- {src => app}/__init__.py | 0 {src/proxy => app/api}/__init__.py | 0 {src/utils => app/api}/proxy/__init__.py | 0 {src => app/api}/proxy/router.py | 0 {src => app}/core/config.py | 0 {src => app}/core/mongodb.py | 2 ++ {src => app}/core/redis.py | 1 + {src => app}/main.py | 2 +- {src => app}/models/proxy.py | 2 ++ {src => app}/models/service.py | 0 app/utils/proxy/__init__.py | 0 {src => app}/utils/proxy/manager.py | 4 +--- {src => app}/utils/proxy/types.py | 0 15 files changed, 9 insertions(+), 6 deletions(-) rename {src => app}/__init__.py (100%) rename {src/proxy => app/api}/__init__.py (100%) rename {src/utils => app/api}/proxy/__init__.py (100%) rename {src => app/api}/proxy/router.py (100%) rename {src => app}/core/config.py (100%) rename {src => app}/core/mongodb.py (99%) rename {src => app}/core/redis.py (99%) rename {src => app}/main.py (76%) rename {src => app}/models/proxy.py (99%) rename {src => app}/models/service.py (100%) create mode 100644 app/utils/proxy/__init__.py rename {src => app}/utils/proxy/manager.py (67%) rename {src => app}/utils/proxy/types.py (100%) diff --git a/Dockerfile b/Dockerfile index 7f7feaa..0c8168d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ COPY pyproject.toml ./ RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir fastapi uvicorn -COPY src ./src +COPY app ./src EXPOSE 3671 diff --git a/README.md b/README.md index 5388c6f..f015e15 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ avvia i servizi e il server locale docker compose up -d mongodb redis ``` ```bash -fastapi dev src/main.py +fastapi dev app/main.py ``` accedi a FastAPI su: [FastAPI docs](http://localhost:3671/docs) diff --git a/src/__init__.py b/app/__init__.py similarity index 100% rename from src/__init__.py rename to app/__init__.py diff --git a/src/proxy/__init__.py b/app/api/__init__.py similarity index 100% rename from src/proxy/__init__.py rename to app/api/__init__.py diff --git a/src/utils/proxy/__init__.py b/app/api/proxy/__init__.py similarity index 100% rename from src/utils/proxy/__init__.py rename to app/api/proxy/__init__.py diff --git a/src/proxy/router.py b/app/api/proxy/router.py similarity index 100% rename from src/proxy/router.py rename to app/api/proxy/router.py diff --git a/src/core/config.py b/app/core/config.py similarity index 100% rename from src/core/config.py rename to app/core/config.py diff --git a/src/core/mongodb.py b/app/core/mongodb.py similarity index 99% rename from src/core/mongodb.py rename to app/core/mongodb.py index 5d1bba7..7b0d65f 100644 --- a/src/core/mongodb.py +++ b/app/core/mongodb.py @@ -1,6 +1,8 @@ from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorDatabase + from core.config import settings + class _MongoDB: client: AsyncIOMotorClient | None = None diff --git a/src/core/redis.py b/app/core/redis.py similarity index 99% rename from src/core/redis.py rename to app/core/redis.py index 3dff882..4a09956 100644 --- a/src/core/redis.py +++ b/app/core/redis.py @@ -1,4 +1,5 @@ import redis.asyncio as aioredis + from core.config import settings _redis_pool: aioredis.Redis | None = None diff --git a/src/main.py b/app/main.py similarity index 76% rename from src/main.py rename to app/main.py index 5399e74..5fdb9da 100644 --- a/src/main.py +++ b/app/main.py @@ -1,6 +1,6 @@ from fastapi import FastAPI -from src.proxy.router import router as proxy_router +from api.proxy import router as proxy_router app = FastAPI( title="thePlugAPI" diff --git a/src/models/proxy.py b/app/models/proxy.py similarity index 99% rename from src/models/proxy.py rename to app/models/proxy.py index 6c423f3..4864a63 100644 --- a/src/models/proxy.py +++ b/app/models/proxy.py @@ -1,6 +1,8 @@ from pydantic import BaseModel, Field + from models.service import ServiceDocument + class ProxyDocument(BaseModel): port: int = Field(..., description="Port number of the proxy") service: ServiceDocument = Field(..., description="Associated service details") \ No newline at end of file diff --git a/src/models/service.py b/app/models/service.py similarity index 100% rename from src/models/service.py rename to app/models/service.py diff --git a/app/utils/proxy/__init__.py b/app/utils/proxy/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/proxy/manager.py b/app/utils/proxy/manager.py similarity index 67% rename from src/utils/proxy/manager.py rename to app/utils/proxy/manager.py index 21039e7..6434ac6 100644 --- a/src/utils/proxy/manager.py +++ b/app/utils/proxy/manager.py @@ -1,5 +1,3 @@ -from typing import Literal - from utils.proxy.types import ServiceConfig @@ -7,6 +5,6 @@ async def create_proxy( port: int, name: str, service: ServiceConfig, - proxy_type: Literal["easy", "manual"] + code: str ): return diff --git a/src/utils/proxy/types.py b/app/utils/proxy/types.py similarity index 100% rename from src/utils/proxy/types.py rename to app/utils/proxy/types.py