From 1ab109b1d426152e0b1cc658fbc001918d2f179b Mon Sep 17 00:00:00 2001 From: Marius Mutu Date: Fri, 13 Mar 2026 17:17:22 +0200 Subject: [PATCH] chore: project structure + API contract --- .env.example | 6 +++ backend/data/.gitkeep | 0 docs/api-contract.json | 87 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 .env.example create mode 100644 backend/data/.gitkeep create mode 100644 docs/api-contract.json diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..f9a365d --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +SECRET_KEY=change-me-in-production +DATABASE_URL=sqlite+aiosqlite:///./data/roaauto.db +ACCESS_TOKEN_EXPIRE_DAYS=30 +TRIAL_DAYS=30 +SMSAPI_TOKEN= +CORS_ORIGINS=http://localhost:5173 diff --git a/backend/data/.gitkeep b/backend/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/api-contract.json b/docs/api-contract.json new file mode 100644 index 0000000..aab5c2f --- /dev/null +++ b/docs/api-contract.json @@ -0,0 +1,87 @@ +{ + "version": "1.0", + "note": "Contract shared intre backend-agent si frontend-agent. Nu modificati fara notificarea ambilor agenti.", + "base_url": "/api", + "auth": { + "POST /auth/register": { + "body": {"email": "str", "password": "str", "tenant_name": "str", "telefon": "str"}, + "response": {"access_token": "str", "token_type": "bearer", "tenant_id": "str", "plan": "str"} + }, + "POST /auth/login": { + "body": {"email": "str", "password": "str"}, + "response": {"access_token": "str", "token_type": "bearer", "tenant_id": "str", "plan": "str"} + }, + "GET /auth/me": { + "headers": {"Authorization": "Bearer "}, + "response": {"id": "str", "email": "str", "tenant_id": "str", "plan": "str", "rol": "str"} + } + }, + "sync": { + "GET /sync/full": { + "headers": {"Authorization": "Bearer "}, + "response": { + "tables": { + "vehicles": [], "orders": [], "order_lines": [], + "invoices": [], "appointments": [], + "catalog_marci": [], "catalog_modele": [], + "catalog_ansamble": [], "catalog_norme": [], + "catalog_preturi": [], "catalog_tipuri_deviz": [], + "catalog_tipuri_motoare": [], "mecanici": [] + }, + "synced_at": "ISO8601" + } + }, + "GET /sync/changes": { + "params": {"since": "ISO8601"}, + "response": {"tables": {}, "synced_at": "str"} + }, + "POST /sync/push": { + "body": {"operations": [{"table": "str", "id": "uuid", "operation": "INSERT|UPDATE|DELETE", "data": {}, "timestamp": "str"}]}, + "response": {"applied": 0, "conflicts": []} + } + }, + "orders": { + "GET /orders": {"response": [{"id": "str", "status": "str", "nr_auto": "str", "total_general": 0}]}, + "POST /orders": {"body": {"vehicle_id": "str", "tip_deviz_id": "str", "km_intrare": 0, "observatii": "str"}, "response": {"id": "str"}}, + "GET /orders/{id}": {"response": {"id": "str", "status": "str", "lines": []}}, + "POST /orders/{id}/lines": {"body": {"tip": "manopera|material", "descriere": "str", "ore": 0, "pret_ora": 0, "cantitate": 0, "pret_unitar": 0, "um": "str"}}, + "POST /orders/{id}/validate": {"response": {"status": "VALIDAT"}}, + "GET /orders/{id}/pdf/deviz": {"response": "application/pdf"} + }, + "vehicles": { + "GET /vehicles": {"response": [{"id": "str", "nr_auto": "str", "marca": "str", "model": "str", "an": 0}]}, + "POST /vehicles": {"body": {"nr_auto": "str", "marca_id": "str", "model_id": "str", "an_fabricatie": 0, "vin": "str", "proprietar_nume": "str", "proprietar_telefon": "str"}}, + "GET /vehicles/{id}": {"response": {"id": "str", "nr_auto": "str", "orders": []}}, + "PUT /vehicles/{id}": {"body": {}} + }, + "client_portal": { + "GET /p/{token}": {"response": {"order": {}, "tenant": {}, "lines": []}}, + "POST /p/{token}/accept": {"response": {"ok": true}}, + "POST /p/{token}/reject": {"response": {"ok": true}} + }, + "invoices": { + "POST /invoices": {"body": {"order_id": "str"}, "response": {"id": "str", "nr_factura": "str"}}, + "GET /invoices/{id}/pdf": {"response": "application/pdf"} + }, + "users": { + "GET /users": {"response": [{"id": "str", "email": "str", "rol": "str"}]}, + "POST /users/invite": {"body": {"email": "str", "rol": "admin|mecanic"}}, + "DELETE /users/{id}": {"response": {"ok": true}}, + "POST /auth/accept-invite": {"body": {"token": "str", "password": "str"}} + }, + "appointments": { + "GET /appointments": {"response": [{"id": "str", "data": "str", "vehicle_id": "str", "descriere": "str"}]}, + "POST /appointments": {"body": {"vehicle_id": "str", "data": "ISO8601", "descriere": "str"}}, + "PUT /appointments/{id}": {"body": {}}, + "DELETE /appointments/{id}": {"response": {"ok": true}} + }, + "catalog": { + "GET /catalog/marci": {"response": [{"id": "str", "nume": "str"}]}, + "GET /catalog/modele": {"params": {"marca_id": "str"}, "response": [{"id": "str", "nume": "str"}]}, + "GET /catalog/norme": {"params": {"ansamblu_id": "str"}, "response": [{"id": "str", "descriere": "str", "ore": 0}]}, + "GET /catalog/preturi": {"response": [{"id": "str", "tip": "str", "valoare": 0}]} + }, + "health": { + "GET /health": {"response": {"status": "ok", "version": "str"}} + } +}