18 KiB
Oudelaa — Backend response to Flutter integration review
Date: 2026-11-14. API contract: /api/v1.
Target of this report: the updated local backend working tree based on commit d936446, including uncommitted changes. This is not a claim that a particular commit/image is already running on the supplied hosts. Follow-up public GET checks observed health/catalog responses on host A and a 404 for /api/v1/reports/options; deployed revision, authenticated flows and hosts B/C remain unverified. See ../docs/performance/LIVE-API-READONLY-2026-11-14.md. Flutter source files were not available in this workspace; references to existing Flutter behavior are from Yara's report.
Hi Yara,
We reviewed your eight questions against the backend implementation and updated missing compatibility endpoints and documentation. Please preserve the existing three-stage signup, REST message sending, direct Multipart uploads and target-based profile-share calls. The following contract is implemented locally; deployment verification remains a separate release step.
1. Service manifest and public boundary
| Component | Mobile-facing contract | Responsibility | Status |
|---|---|---|---|
| API Gateway | REST base <gateway-origin>/api/v1 |
Auth, users, social/posts/feed, reports, chat REST, notification inbox/read/count, devices, Marketplace and other mobile APIs | Implemented; public health/catalog paths observed on A, deployed revision/authenticated flows unverified |
| API Gateway | Same origin, Socket.IO Engine.IO path /socket.io, namespaces /chat and /notifications |
Mobile realtime connections, authentication and outbound events | Implemented; reverse-proxy WebSocket/polling behavior not verified |
| RabbitMQ | No direct mobile endpoint | Internal AMQP messaging between backend components | Internal architectural dependency; never configure Flutter to use broker URLs or credentials |
| Notification service | No direct mobile REST/device/socket endpoint; HTTP /health, /health/live, /health/ready are operational health routes |
Internal RMQ consumer/RPC worker; gateway remains the public facade | Implemented; worker health is not proof of mobile FCM delivery |
Supplied candidates: A https://oudelaa-api1-web-35ee485c.hosted.cumin.dev, B https://oudelaa-rabbit-new-web-53d85769.hosted.cumin.dev, C https://oudelaa-notification-service1-web-4375adb9.hosted.cumin.dev. The intended topology would put the gateway on A, broker on B and worker on C, subject to deployment-owner verification. Hostnames alone do not establish this mapping. If A is confirmed as gateway, the mobile REST base is https://oudelaa-api1-web-35ee485c.hosted.cumin.dev/api/v1; its socket origin is A without /api/v1.
The default prefix is api/v1 and can be configured by deployment. Do not change mobile URLs until the deployed image, prefix, proxy settings and service roles are confirmed. Keep inbox and device requests behind the gateway; do not send them to C.
2. Three-stage email signup
All three operations already existed and remain supported; they are now explicitly included in both Mobile and Auth Postman collections.
| Operation | Request | Success |
|---|---|---|
POST /auth/signup/start |
JSON {email,password,confirmPassword} |
201, {message,email,signupId}; no session or created user yet |
POST /auth/signup/verify |
JSON {signupId,email,code}; six-digit emailed code |
200, {message,signupToken}; temporary completion token, no access/refresh pair |
POST /auth/signup/complete |
Multipart; no Bearer token required | 200, {message,accessToken,refreshToken,user} |
Completion requires signupToken and name. Optional: stageName, username, bio, location, latitude, longitude, isPrivate, experienceLevel, musicRoles, musicGenres, favoriteInstruments, favoriteMaqamat, avatarFile. Existing repeated bracket fields (musicRoles[], etc.) are accepted. JSON-encoded arrays are also normalized. Avatar is optional, one JPEG/PNG/WebP file up to 5 MiB. Username, when provided: 3–30 letters/numbers/underscore/dot. Name: 2–80 characters; stageName up to 80; bio up to 160; location up to 120. Invalid fields/enums return validation errors; optional fields should be omitted rather than sent as empty numeric/enum strings.
Defaults: initial signup draft/code lifetime 20 minutes (service clamp 15–30); completion token lifetime 15 minutes (clamp 5–30), also bounded by the original draft expiry. Verification attempts default to 5. Completion consumes the draft/token. Representative failures: start mismatch 400, duplicate email 409; incorrect verification code 400, exhausted attempts 429, expired draft 410; invalid/expired completion token 401. Production must not expose debugCode; test/development may return it for isolated testing.
/auth/register-basic and /auth/register are parallel existing APIs, not replacements for /auth/signup/*. The email music step can continue submitting its collected values with completion. Google remains separate: POST /auth/google/token, then authenticated music/profile setup as needed.
3. Authentication and session continuity
Existing mobile routes remain: POST /auth/login, /auth/google/token, /auth/refresh, /auth/logout, /auth/forgot-password, /auth/verify-reset-code, /auth/reset-password; GET /auth/sessions is authenticated. Login, Google token exchange and Refresh return {accessToken,refreshToken,user}. Logout and Refresh accept JSON {refreshToken}.
Default access expiry is 15 minutes; refresh expiry 30 days, deployment-configurable. Refresh rotates the pair and consumes the previous refresh record. Persist the newest pair atomically and serialize concurrent refresh attempts. Reuse/revoked/unknown refresh records can revoke other sessions. Invalid, malformed, expired and incorrectly signed refresh JWTs that pass request validation now return 401, rather than leaking an unhandled JWT error as 500. Missing/non-string/tokens shorter than 20 characters return validation 400. Disabled accounts can return 403.
Recovery remains email → code verification → resetToken → new password. No real tokens or credentials are included in this handoff.
Existing installed-build sessions are not yet certified for the new hosts. Continuity requires compatible JWT signing configuration, user IDs/database, refresh-session records and refresh hashing configuration. Google also requires the correct configured client ID/audience. If these are not preserved, expect re-login. We cannot promise token reuse across deployments from source inspection.
4. Previously undocumented operations
| Operation | Local disposition | Contract |
|---|---|---|
POST /posts/drafts |
Newly implemented; deployment pending | Bearer + Multipart, HTTP 201. Same text fields as CreatePostDto, all optional, and optional imageFiles, videoFile, audioFile, coverImageFile. Returns draft object with _id, id, draftId, authorId, isDraft:true, status:"draft", timestamps and supplied fields/media URLs. Empty drafts accepted. |
GET /reports/options |
Newly implemented; deployment pending | Bearer, HTTP 200. {reasons:[{id,value,label}],targetTypes:[...]}. Submit reason=value to existing POST /reports. Labels are English; clients may localize by stable value. |
DELETE /users/{followerId}/followers |
Already supported; now documented | Removes the identified follower from the authenticated user's followers. Path ID is the follower to remove. |
POST /posts/{id}/share with target:"profile" and optional caption |
Already supported; retained | Response includes message,shareId,postId,shareCount,isSharedByMe,shareUrl. Existing share-record behavior retained. |
POST /posts/{id}/share/profile |
Separate existing operation | Creates a repost; it is not an alias of target-based sharing. Do not swap the calls. |
Drafts live in postdrafts, separate from published posts. Saving does not change post counts, invalidate the feed or notify tagged/mentioned users. It does not publish the draft. Uploaded image/audio/video types and size limits follow section 8; one media family per save, and a cover file requires audio/video. File and URL sources for the same media must not be combined. Drafts do not accept the asynchronous videoStorageKey mode. Invalid input returns 400; missing authentication 401; non-Multipart content 415; upload-size rejection may be 413. Newly uploaded assets are cleaned up if saving fails. This addition implements the existing save action; it does not introduce a draft list/edit/publish feature.
Report reason values: spam, harassment, hate_speech, nudity, violence, scam, intellectual_property, self_harm, other. Target types: user, post, comment, listing, repair_shop.
Because Flutter models were not provided here, the new draft/options response parsing should be checked against the actual Dart models before declaring full end-to-end mobile compatibility. The explicit shapes above and saved examples are authoritative for this local update.
5. Socket.IO and message identity
Connection settings for the confirmed gateway origin:
{
"origin": "<confirmed-gateway-origin>",
"path": "/socket.io",
"namespaces": ["/chat", "/notifications"],
"auth": {"token": "<access-token>"},
"transports": ["websocket", "polling"]
}
/api/v1 is a REST prefix, not part of the namespace or Engine.IO path. Authentication accepts the access token through auth.token; the user must exist and be enabled. REST message sending remains valid and emits new_message using the same persisted message. Deduplicate by message _id/normalized ID; do not create a second local identity for the socket copy. The client must join the conversation with join_conversation {conversationId} to receive its room events. Existing events include joined_conversation, typing {conversationId,userId,isTyping} and message_seen {conversationId,messageId,userId,seenAt}. No event migration is introduced by this change.
Notification events remain notification_created and notifications_unread_count {unreadCount}; existing aliases notification:new and notification:unread_counts are also emitted. Subscribe deliberately/deduplicate if listening to both aliases. Reverse-proxy upgrade/polling/CORS and multi-instance delivery require target checks; a successful local test does not certify the public proxy.
6. Devices, notification identity and FCM limitations
POST /devices/register: required fcmToken (nonempty string, max 4096), platform (android, ios, web); optional deviceId (max 160), appVersion (max 60), locale (max 20). Existing mobile registration with just fcmToken/platform/locale remains valid. POST /devices/unregister accepts fcmToken or deviceId and requires at least one nonempty identifier. Both return {message,device} and use the authenticated user.
On logout/account switch, unregister the old token while still authenticated as the old account, then log out; register for the new account after login. Registration currently scopes records by user. Registering under a different account alone does not guarantee deactivation of the previous account's record. /auth/logout does not itself unregister the device.
Inbox/socket notification documents use _id as the persisted notification identity and contain type, referenceId, resourceType, deepLink, title, previewText, metadata, read and readAt; optional eventId identifies a backend event and is not a substitute for the notification ID. Illustrative field subset (synthetic values, not a captured FCM payload):
{"_id":"507f191e810c19729de860e1","type":"like","referenceId":"507f191e810c19729de860e2","resourceType":"post","deepLink":"/posts/507f191e810c19729de860e2","title":"New like","previewText":"","metadata":{},"read":false,"readAt":null}
FCM delivery status: not implemented in the inspected source. Device registration/inbox/Socket.IO exist, but no Firebase sender/project configuration or notification-vs-data-only push producer was found. Therefore we cannot provide a verified FCM payload family or certify reuse of old Firebase tokens. If a separate deployed sender exists outside this repository, its owner must provide its Firebase project and sanitized payload contract; otherwise adding a sender requires a separately configured integration. No broker/Google/Firebase credentials are requested from Flutter.
7. Marketplace canonical contract and purchasing scope
The shop ID used by /marketplace/shops/{adminId} and /marketplace/shops/{shopId}/listings is the owning admin user's ID. For this contract shopId, shop id and adminId refer to that identity; do not substitute the listing ID or a repair-shop record ID. Listing id identifies the product. Listing ownerAdminId can be populated; prefer the stable string shopId for routing.
Canonical listing images remain imageUrls; canonical shop cover remains coverUrl. Added compatibility aliases:
- Listing:
adminUserIdandownerIdequalshopId;imagesequalsimageUrls. - Shop and nested listing shop:
adminUserIdandownerIdequal shopid;imagesequalsimageUrls;coverImageUrlequalscoverUrl.
Existing canonical fields remain available. These aliases reduce the identity/image mismatch described in your report. Confirm actual Flutter parsers with the response examples before changing models. Public list responses are objects with items,count,page,limit,total,totalPages,nextCursor,pagination; there is no new raw-array response. Stock and delivery information come from server fields, not local display calculations.
Catalog, server cart, checkout preview, create/list/detail/cancel order routes are implemented. Public catalog home/list reads were observed on A but returned empty lists; detail/purchasing deployment and behavior remain unverified. Cart POST sets absolute quantity; subsequent cart mutation uses the returned cart item ID. POST /marketplace/checkout/preview can return HTTP 201 with isValid:false; inspect the body before proceeding. Purchasing currently documents cash on delivery and single-shop/single-currency constraints, not online payment integration.
Existing purchasing APIs do not mean Flutter's local cart/mock store screens are connected. This update preserves backend support and does not add Flutter Shop navigation, Cart/Checkout/Orders UI or select that product scope. The Marketplace collection contains the concrete requests and isolated-test response captures; these are not production captures.
8. Multipart upload support
Direct Multipart remains supported for posts, newly added draft saves, chat media, signup/profile images and Marketplace media. There is no mandatory presign migration introduced here. Keep the existing field names. Posts/drafts use imageFiles (up to 10), videoFile, audioFile, coverImageFile; signup uses avatarFile. JPEG/PNG/WebP images, supported audio formats and MP4/MOV/WebM video are validated by the existing media validator.
Per-file application limits: post/draft image 10 MiB, audio 20 MiB, video 100 MiB; user avatar 5 MiB; Marketplace image 8 MiB. Infrastructure/proxy limits must also permit these sizes; target proxy configuration is unverified. Presign/PUT and asynchronous video processing are additional configured capabilities. When async video processing is enabled for published posts, poll processingStatus; do not assume every video is ready synchronously. Draft saves store uploaded originals separately and do not schedule publication/video jobs.
Responses, examples and files to import
RESPONSE_ENVELOPE_ENABLED defaults to false: responses above are plain JSON objects. If enabled in a deployment, success is wrapped as {data:<body>,meta:{statusCode,timestamp}}. Preserve the agreed setting; changing it during migration changes the mobile contract. Typical validation/auth errors follow Nest {statusCode,message,error}; message can be a string or a list. Do not mistake a transport-success code for business validity.
Import the updated Oudelaa-Mobile.postman_collection.json and select folder Mobile compatibility and three-stage signup. The full Auth collection contains the same additions. Set baseUrl yourself after deployment confirmation; defaults intentionally remain local. Tokens remain in your local Postman environment. mobile-compatibility-response-examples.json contains sanitized synthetic examples; marketplace-response-examples.json and the Marketplace collection contain isolated integration-test captures.
Validation and release gate
The local Marketplace performance update preserves response field names and pagination while combining repeated counts/reads and coalescing identical in-flight home requests per process. onlyActive=false now includes active and inactive rows consistently; search q is limited to 120 characters and page/home limits must be integers. A private benchmark with 6,000 listings reduced home service/database average from 1,445.15 ms to 51.32 ms, with 16 → 3 read commands. These are synthetic local measurements, not a claim about the public host after deployment. See ../docs/performance/MARKETPLACE-OPTIMIZATION-2026-11-14.md.
Local validation results are recorded in MOBILE-COMPATIBILITY-VALIDATION.md. Local tests are not public-host verification. Before changing Flutter's configured host, release owners still need to record the deployed commit/image, verify A/B/C ownership and the effective prefix/envelope, decide whether old sessions can be retained, and exercise signup/login/refresh, social/chat/socket and notification routing with dedicated staging accounts. FCM cannot be certified until the sender/project issue above is resolved. No production deployment was performed by this change.