diff --git a/backend/Dockerfile.api b/backend/Dockerfile.api index 1f870b8..3ec23d4 100644 --- a/backend/Dockerfile.api +++ b/backend/Dockerfile.api @@ -9,7 +9,7 @@ ENV POETRY_NO_INTERACTION=1 \ WORKDIR /app -COPY ./pyproject.toml /app +COPY pyproject.toml /app RUN poetry install --only=main --no-root && \ rm -rf ${POETRY_CACHE_DIR} @@ -29,10 +29,6 @@ env VIRTUAL_ENV=/app/.venv \ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} -COPY backend /app/backend -COPY dependencies.py /app -COPY config.sample.yaml /app -COPY routers/ /app/routers -COPY main.py /app +COPY api /app/api -CMD ["python", "./main.py"] +CMD ["python", "./api/main.py"] diff --git a/backend/Dockerfile.db_updater b/backend/Dockerfile.db_updater index d5b2d09..3dcfbf1 100644 --- a/backend/Dockerfile.db_updater +++ b/backend/Dockerfile.db_updater @@ -34,10 +34,7 @@ env VIRTUAL_ENV=/app/.venv \ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} -COPY backend /app/backend -COPY dependencies.py /app -COPY config.sample.yaml /app -COPY config.local.yaml /app +COPY api /app/api COPY db_updater /app/db_updater CMD ["python", "-m", "db_updater.fill_db"] diff --git a/backend/backend/__init__.py b/backend/api/__init__.py similarity index 100% rename from backend/backend/__init__.py rename to backend/api/__init__.py diff --git a/backend/config.local.yaml b/backend/api/config.local.yaml similarity index 100% rename from backend/config.local.yaml rename to backend/api/config.local.yaml diff --git a/backend/config.sample.yaml b/backend/api/config.sample.yaml similarity index 100% rename from backend/config.sample.yaml rename to backend/api/config.sample.yaml diff --git a/backend/backend/db/__init__.py b/backend/api/db/__init__.py similarity index 100% rename from backend/backend/db/__init__.py rename to backend/api/db/__init__.py diff --git a/backend/backend/db/base_class.py b/backend/api/db/base_class.py similarity index 100% rename from backend/backend/db/base_class.py rename to backend/api/db/base_class.py diff --git a/backend/backend/db/db.py b/backend/api/db/db.py similarity index 98% rename from backend/backend/db/db.py rename to backend/api/db/db.py index 0dac1b1..bd4f840 100644 --- a/backend/backend/db/db.py +++ b/backend/api/db/db.py @@ -14,7 +14,7 @@ from sqlalchemy.ext.asyncio import ( ) from .base_class import Base -from ..settings import DatabaseSettings +from settings import DatabaseSettings logger = getLogger(__name__) diff --git a/backend/dependencies.py b/backend/api/dependencies.py similarity index 86% rename from backend/dependencies.py rename to backend/api/dependencies.py index 272a0c8..ecf6c11 100644 --- a/backend/dependencies.py +++ b/backend/api/dependencies.py @@ -4,9 +4,9 @@ from fastapi_cache.backends.redis import RedisBackend from redis import asyncio as aioredis from yaml import safe_load -from backend.db import db -from backend.idfm_interface.idfm_interface import IdfmInterface -from backend.settings import CacheSettings, Settings +from db import db +from idfm_interface.idfm_interface import IdfmInterface +from settings import CacheSettings, Settings CONFIG_PATH = environ.get("CONFIG_PATH", "./config.sample.yaml") diff --git a/backend/backend/idfm_interface/__init__.py b/backend/api/idfm_interface/__init__.py similarity index 100% rename from backend/backend/idfm_interface/__init__.py rename to backend/api/idfm_interface/__init__.py diff --git a/backend/backend/idfm_interface/idfm_interface.py b/backend/api/idfm_interface/idfm_interface.py similarity index 98% rename from backend/backend/idfm_interface/idfm_interface.py rename to backend/api/idfm_interface/idfm_interface.py index 7bcc734..23de96b 100644 --- a/backend/backend/idfm_interface/idfm_interface.py +++ b/backend/api/idfm_interface/idfm_interface.py @@ -7,9 +7,9 @@ from aiohttp import ClientSession from msgspec import ValidationError from msgspec.json import Decoder -from ..db import Database -from ..models import Line, Stop, StopArea from .idfm_types import Destinations as IdfmDestinations, IdfmResponse, IdfmState +from db import Database +from models import Line, Stop, StopArea class IdfmInterface: diff --git a/backend/backend/idfm_interface/idfm_types.py b/backend/api/idfm_interface/idfm_types.py similarity index 100% rename from backend/backend/idfm_interface/idfm_types.py rename to backend/api/idfm_interface/idfm_types.py diff --git a/backend/backend/idfm_interface/ratp_types.py b/backend/api/idfm_interface/ratp_types.py similarity index 100% rename from backend/backend/idfm_interface/ratp_types.py rename to backend/api/idfm_interface/ratp_types.py diff --git a/backend/main.py b/backend/api/main.py similarity index 99% rename from backend/main.py rename to backend/api/main.py index 1eae69a..bcbaaaa 100755 --- a/backend/main.py +++ b/backend/api/main.py @@ -12,7 +12,7 @@ from opentelemetry.sdk.resources import Resource, SERVICE_NAME from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor -from backend.db import db +from db import db from dependencies import idfm_interface, redis_backend, settings from routers import line, stop diff --git a/backend/backend/models/__init__.py b/backend/api/models/__init__.py similarity index 100% rename from backend/backend/models/__init__.py rename to backend/api/models/__init__.py diff --git a/backend/backend/models/line.py b/backend/api/models/line.py similarity index 98% rename from backend/backend/models/line.py rename to backend/api/models/line.py index 786c585..ce0f2a5 100644 --- a/backend/backend/models/line.py +++ b/backend/api/models/line.py @@ -14,8 +14,8 @@ from sqlalchemy import ( from sqlalchemy.orm import Mapped, mapped_column, relationship, selectinload from sqlalchemy.sql.expression import tuple_ -from ..db import Base, db -from ..idfm_interface.idfm_types import ( +from db import Base, db +from idfm_interface.idfm_types import ( IdfmState, IdfmLineState, TransportMode, diff --git a/backend/backend/models/stop.py b/backend/api/models/stop.py similarity index 98% rename from backend/backend/models/stop.py rename to backend/api/models/stop.py index 05e05e2..02087cc 100644 --- a/backend/backend/models/stop.py +++ b/backend/api/models/stop.py @@ -26,8 +26,8 @@ from sqlalchemy.orm import ( from sqlalchemy.schema import Index from sqlalchemy_utils.types.ts_vector import TSVectorType -from ..db import Base, db -from ..idfm_interface.idfm_types import TransportMode, IdfmState, StopAreaType +from db import Base, db +from idfm_interface.idfm_types import TransportMode, IdfmState, StopAreaType if TYPE_CHECKING: from .line import Line diff --git a/backend/backend/models/user.py b/backend/api/models/user.py similarity index 96% rename from backend/backend/models/user.py rename to backend/api/models/user.py index 24a152c..62bbc28 100644 --- a/backend/backend/models/user.py +++ b/backend/api/models/user.py @@ -1,7 +1,7 @@ from sqlalchemy import BigInteger, ForeignKey, String from sqlalchemy.orm import Mapped, mapped_column, relationship -from ..db import Base, db +from db import Base, db from .stop import _Stop diff --git a/backend/backend/py.typed b/backend/api/py.typed similarity index 100% rename from backend/backend/py.typed rename to backend/api/py.typed diff --git a/backend/routers/__init__.py b/backend/api/routers/__init__.py similarity index 100% rename from backend/routers/__init__.py rename to backend/api/routers/__init__.py diff --git a/backend/routers/line.py b/backend/api/routers/line.py similarity index 91% rename from backend/routers/line.py rename to backend/api/routers/line.py index 917881f..5325d15 100644 --- a/backend/routers/line.py +++ b/backend/api/routers/line.py @@ -1,8 +1,8 @@ from fastapi import APIRouter, HTTPException from fastapi_cache.decorator import cache -from backend.models import Line -from backend.schemas import Line as LineSchema, TransportMode +from models import Line +from schemas import Line as LineSchema, TransportMode router = APIRouter(prefix="/line", tags=["line"]) diff --git a/backend/routers/stop.py b/backend/api/routers/stop.py similarity index 97% rename from backend/routers/stop.py rename to backend/api/routers/stop.py index 1e59f8d..caafb99 100644 --- a/backend/routers/stop.py +++ b/backend/api/routers/stop.py @@ -5,9 +5,9 @@ from typing import Sequence from fastapi import APIRouter, HTTPException from fastapi_cache.decorator import cache -from backend.idfm_interface import Destinations as IdfmDestinations, TrainStatus -from backend.models import Stop, StopArea, StopShape -from backend.schemas import ( +from idfm_interface import Destinations as IdfmDestinations, TrainStatus +from models import Stop, StopArea, StopShape +from schemas import ( NextPassage as NextPassageSchema, NextPassages as NextPassagesSchema, Stop as StopSchema, diff --git a/backend/backend/schemas/__init__.py b/backend/api/schemas/__init__.py similarity index 100% rename from backend/backend/schemas/__init__.py rename to backend/api/schemas/__init__.py diff --git a/backend/backend/schemas/line.py b/backend/api/schemas/line.py similarity index 98% rename from backend/backend/schemas/line.py rename to backend/api/schemas/line.py index 69f29bc..1182bcd 100644 --- a/backend/backend/schemas/line.py +++ b/backend/api/schemas/line.py @@ -2,7 +2,7 @@ from enum import StrEnum from pydantic import BaseModel -from ..idfm_interface import ( +from idfm_interface import ( IdfmLineState, IdfmState, TransportMode as IdfmTransportMode, diff --git a/backend/backend/schemas/next_passage.py b/backend/api/schemas/next_passage.py similarity index 89% rename from backend/backend/schemas/next_passage.py rename to backend/api/schemas/next_passage.py index e895190..1035393 100644 --- a/backend/backend/schemas/next_passage.py +++ b/backend/api/schemas/next_passage.py @@ -1,6 +1,6 @@ from pydantic import BaseModel -from ..idfm_interface.idfm_types import TrainStatus +from idfm_interface.idfm_types import TrainStatus class NextPassage(BaseModel): diff --git a/backend/backend/schemas/stop.py b/backend/api/schemas/stop.py similarity index 92% rename from backend/backend/schemas/stop.py rename to backend/api/schemas/stop.py index 78581ac..e323d8d 100644 --- a/backend/backend/schemas/stop.py +++ b/backend/api/schemas/stop.py @@ -1,6 +1,6 @@ from pydantic import BaseModel -from ..idfm_interface import StopAreaType +from idfm_interface import StopAreaType class Stop(BaseModel): diff --git a/backend/backend/settings.py b/backend/api/settings.py similarity index 100% rename from backend/backend/settings.py rename to backend/api/settings.py diff --git a/backend/db_updater/fill_db.py b/backend/db_updater/fill_db.py index 5bc740d..0995005 100755 --- a/backend/db_updater/fill_db.py +++ b/backend/db_updater/fill_db.py @@ -16,9 +16,9 @@ from shapefile import Reader as ShapeFileReader, ShapeRecord # type: ignore from tqdm import tqdm from yaml import safe_load -from backend.db import Base, db, Database -from backend.models import ConnectionArea, Line, LinePicto, Stop, StopArea, StopShape -from backend.idfm_interface.idfm_types import ( +from api.db import Base, db, Database +from api.models import ConnectionArea, Line, LinePicto, Stop, StopArea, StopShape +from api.idfm_interface.idfm_types import ( ConnectionArea as IdfmConnectionArea, IdfmLineState, Line as IdfmLine, @@ -31,8 +31,8 @@ from backend.idfm_interface.idfm_types import ( StopLineAsso as IdfmStopLineAsso, TransportMode, ) -from backend.idfm_interface.ratp_types import Picto as RatpPicto -from backend.settings import Settings +from api.idfm_interface.ratp_types import Picto as RatpPicto +from api.settings import Settings CONFIG_PATH = environ.get("CONFIG_PATH", "./config.sample.yaml")