openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: SusuClub ROSCA Platform API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication - name: groups description: Susu group management - name: members description: Group membership - name: cycles description: Cycle tracking - name: contributions description: Contribution management - name: payouts description: Payout management - name: dashboard description: Dashboard data - name: notifications description: Notifications paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" # AUTH /auth/login: post: operationId: loginUser tags: [auth] summary: Login with phone and password requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginInput" responses: "200": description: Login successful content: application/json: schema: $ref: "#/components/schemas/AuthResponse" "401": description: Invalid credentials /auth/register: post: operationId: registerUser tags: [auth] summary: Register new user requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RegisterInput" responses: "201": description: Registered successfully content: application/json: schema: $ref: "#/components/schemas/AuthResponse" /auth/me: get: operationId: getMe tags: [auth] summary: Get current user profile responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/User" # GROUPS /groups: get: operationId: listGroups tags: [groups] summary: List groups (filtered by role) responses: "200": description: List of groups content: application/json: schema: type: array items: $ref: "#/components/schemas/GroupSummary" post: operationId: createGroup tags: [groups] summary: Create a new group requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/GroupInput" responses: "201": description: Created group content: application/json: schema: $ref: "#/components/schemas/Group" /groups/{id}: get: operationId: getGroup tags: [groups] summary: Get group details with current cycle parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Group with cycle details content: application/json: schema: $ref: "#/components/schemas/GroupDetail" put: operationId: updateGroup tags: [groups] summary: Update group parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/GroupUpdate" responses: "200": description: Updated group content: application/json: schema: $ref: "#/components/schemas/Group" /groups/{id}/activate: post: operationId: activateGroup tags: [groups] summary: Activate group and start cycle 1 parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Group activated content: application/json: schema: $ref: "#/components/schemas/Group" /groups/join/{inviteCode}: post: operationId: joinGroup tags: [groups] summary: Join a group via invite code parameters: - name: inviteCode in: path required: true schema: type: string responses: "200": description: Joined group content: application/json: schema: $ref: "#/components/schemas/Membership" # MEMBERS /groups/{id}/members: get: operationId: listGroupMembers tags: [members] summary: List members in a group with payment status parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Group members content: application/json: schema: type: array items: $ref: "#/components/schemas/MemberWithStatus" /groups/{id}/members/invite: post: operationId: inviteMember tags: [members] summary: Invite a member by phone parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/InviteMemberInput" responses: "200": description: Member invited content: application/json: schema: $ref: "#/components/schemas/Membership" # CYCLES /groups/{id}/cycles/current: get: operationId: getCurrentCycle tags: [cycles] summary: Get current active cycle with countdown and member statuses parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Current cycle detail content: application/json: schema: $ref: "#/components/schemas/CycleDetail" /groups/{id}/cycles/next: post: operationId: advanceCycle tags: [cycles] summary: Advance to the next cycle parameters: - name: id in: path required: true schema: type: integer responses: "200": description: New cycle content: application/json: schema: $ref: "#/components/schemas/CycleDetail" /groups/{id}/cycles: get: operationId: listGroupCycles tags: [cycles] summary: List all cycles for a group parameters: - name: id in: path required: true schema: type: integer responses: "200": description: All cycles content: application/json: schema: type: array items: $ref: "#/components/schemas/Cycle" # CONTRIBUTIONS /cycles/{id}/contributions: get: operationId: listCycleContributions tags: [contributions] summary: List contributions for a cycle parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Contributions list content: application/json: schema: type: array items: $ref: "#/components/schemas/Contribution" /contributions: post: operationId: createContribution tags: [contributions] summary: Record a contribution requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ContributionInput" responses: "201": description: Contribution created content: application/json: schema: $ref: "#/components/schemas/Contribution" /contributions/{id}/confirm: put: operationId: confirmContribution tags: [contributions] summary: Admin confirms a cash contribution parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Confirmed contribution content: application/json: schema: $ref: "#/components/schemas/Contribution" /members/{uid}/contributions: get: operationId: getMemberContributions tags: [contributions] summary: Get contribution history for a member parameters: - name: uid in: path required: true schema: type: integer responses: "200": description: Member contribution history content: application/json: schema: type: array items: $ref: "#/components/schemas/Contribution" # PAYOUTS /groups/{id}/payouts: get: operationId: listGroupPayouts tags: [payouts] summary: List all payouts for a group parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Payout list content: application/json: schema: type: array items: $ref: "#/components/schemas/Payout" /payouts: post: operationId: createPayout tags: [payouts] summary: Create a payout record requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PayoutInput" responses: "201": description: Payout created content: application/json: schema: $ref: "#/components/schemas/Payout" /payouts/{id}/confirm: put: operationId: confirmPayout tags: [payouts] summary: Confirm payout sent parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Payout confirmed content: application/json: schema: $ref: "#/components/schemas/Payout" # DASHBOARD /dashboard/admin: get: operationId: getAdminDashboard tags: [dashboard] summary: Super admin platform metrics responses: "200": description: Admin dashboard data content: application/json: schema: $ref: "#/components/schemas/AdminDashboard" /dashboard/member: get: operationId: getMemberDashboard tags: [dashboard] summary: Member personal dashboard responses: "200": description: Member dashboard data content: application/json: schema: $ref: "#/components/schemas/MemberDashboard" /dashboard/group/{id}/live: get: operationId: getLiveCycleData tags: [dashboard] summary: Lightweight polling endpoint for live cycle data parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Live cycle status content: application/json: schema: $ref: "#/components/schemas/LiveCycleStatus" # NOTIFICATIONS /notifications: get: operationId: listNotifications tags: [notifications] summary: Get my notifications responses: "200": description: Notifications content: application/json: schema: $ref: "#/components/schemas/NotificationsResponse" /notifications/{id}/read: put: operationId: markNotificationRead tags: [notifications] summary: Mark notification as read parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Notification marked as read content: application/json: schema: $ref: "#/components/schemas/Notification" components: schemas: HealthStatus: type: object properties: status: type: string required: - status # AUTH LoginInput: type: object required: [phone, password] properties: phone: type: string password: type: string RegisterInput: type: object required: [name, phone, password] properties: name: type: string phone: type: string password: type: string email: type: ["string", "null"] AuthResponse: type: object required: [token, user] properties: token: type: string user: $ref: "#/components/schemas/User" User: type: object required: [id, name, phone, role, isActive, createdAt] properties: id: type: integer name: type: string phone: type: string email: type: ["string", "null"] role: type: string enum: [super_admin, group_admin, treasurer, member] kycStatus: type: string enum: [pending, verified, rejected] momoNumber: type: ["string", "null"] momoProvider: type: ["string", "null"] isActive: type: boolean createdAt: type: string # GROUPS GroupInput: type: object required: [name, contributionAmount, frequency, maxMembers, startDate] properties: name: type: string description: type: ["string", "null"] contributionAmount: type: number frequency: type: string enum: [weekly, biweekly, monthly] maxMembers: type: integer startDate: type: string GroupUpdate: type: object properties: name: type: string description: type: ["string", "null"] contributionAmount: type: number frequency: type: string maxMembers: type: integer startDate: type: string status: type: string Group: type: object required: [id, name, contributionAmount, frequency, maxMembers, currentMembers, startDate, status, inviteCode, adminId, createdAt] properties: id: type: integer name: type: string description: type: ["string", "null"] adminId: type: integer contributionAmount: type: number frequency: type: string maxMembers: type: integer currentMembers: type: integer startDate: type: string status: type: string inviteCode: type: string createdAt: type: string GroupSummary: type: object required: [id, name, contributionAmount, frequency, status, currentMembers, maxMembers, adminId] properties: id: type: integer name: type: string contributionAmount: type: number frequency: type: string status: type: string currentMembers: type: integer maxMembers: type: integer adminId: type: integer inviteCode: type: string currentCycleNumber: type: ["integer", "null"] cycleEndDate: type: ["string", "null"] actualPool: type: ["number", "null"] expectedPool: type: ["number", "null"] GroupDetail: type: object required: [id, name, contributionAmount, frequency, status, currentMembers, maxMembers, adminId] properties: id: type: integer name: type: string description: type: ["string", "null"] contributionAmount: type: number frequency: type: string status: type: string currentMembers: type: integer maxMembers: type: integer adminId: type: integer inviteCode: type: string startDate: type: string currentCycle: $ref: "#/components/schemas/CycleDetail" members: type: array items: $ref: "#/components/schemas/MemberWithStatus" # MEMBERS Membership: type: object required: [id, groupId, userId, slotNumber, role, status] properties: id: type: integer groupId: type: integer userId: type: integer slotNumber: type: integer role: type: string status: type: string joinedAt: type: string MemberWithStatus: type: object required: [id, userId, name, phone, slotNumber, role, status] properties: id: type: integer userId: type: integer name: type: string phone: type: string slotNumber: type: integer role: type: string status: type: string contributionStatus: type: ["string", "null"] contributionMethod: type: ["string", "null"] totalPaidCycles: type: integer isReceiver: type: boolean InviteMemberInput: type: object required: [phone] properties: phone: type: string # CYCLES Cycle: type: object required: [id, groupId, cycleNumber, slotNumber, receiverId, startDate, endDate, expectedPool, actualPool, status] properties: id: type: integer groupId: type: integer cycleNumber: type: integer slotNumber: type: integer receiverId: type: integer startDate: type: string endDate: type: string expectedPool: type: number actualPool: type: number status: type: string payoutConfirmedAt: type: ["string", "null"] createdAt: type: string CycleDetail: type: object required: [id, groupId, cycleNumber, slotNumber, startDate, endDate, expectedPool, actualPool, status, daysRemaining, hoursRemaining, minutesRemaining, progressPercent, paidCount, unpaidCount] properties: id: type: integer groupId: type: integer cycleNumber: type: integer slotNumber: type: integer startDate: type: string endDate: type: string expectedPool: type: number actualPool: type: number status: type: string daysRemaining: type: integer hoursRemaining: type: integer minutesRemaining: type: integer secondsRemaining: type: integer progressPercent: type: number paidCount: type: integer unpaidCount: type: integer receiver: $ref: "#/components/schemas/ReceiverInfo" paidMembers: type: array items: $ref: "#/components/schemas/MemberWithStatus" unpaidMembers: type: array items: $ref: "#/components/schemas/MemberWithStatus" ReceiverInfo: type: object required: [id, name, phone, slotNumber] properties: id: type: integer name: type: string phone: type: string slotNumber: type: integer # CONTRIBUTIONS ContributionInput: type: object required: [groupId, cycleId, amount, paymentMethod] properties: groupId: type: integer cycleId: type: integer amount: type: number paymentMethod: type: string enum: [momo_mtn, momo_telecel, momo_airteltigo, bank_transfer, cash] phone: type: ["string", "null"] Contribution: type: object required: [id, cycleId, groupId, memberId, amount, paymentMethod, paymentStatus, createdAt] properties: id: type: integer cycleId: type: integer groupId: type: integer memberId: type: integer memberName: type: ["string", "null"] amount: type: number paymentMethod: type: string paymentReference: type: ["string", "null"] paymentStatus: type: string paidAt: type: ["string", "null"] createdAt: type: string # PAYOUTS PayoutInput: type: object required: [cycleId, groupId, recipientId, amount] properties: cycleId: type: integer groupId: type: integer recipientId: type: integer amount: type: number paymentMethod: type: ["string", "null"] notes: type: ["string", "null"] Payout: type: object required: [id, cycleId, groupId, recipientId, amount, status, createdAt] properties: id: type: integer cycleId: type: integer groupId: type: integer recipientId: type: integer recipientName: type: ["string", "null"] amount: type: number paymentMethod: type: ["string", "null"] paymentReference: type: ["string", "null"] status: type: string completedAt: type: ["string", "null"] notes: type: ["string", "null"] createdAt: type: string # DASHBOARD AdminDashboard: type: object required: [totalGroups, totalUsers, totalActiveGroups, totalActiveCycles, totalPoolVolume] properties: totalGroups: type: integer totalUsers: type: integer totalActiveGroups: type: integer totalActiveCycles: type: integer totalPoolVolume: type: number recentActivity: type: array items: $ref: "#/components/schemas/ActivityItem" MemberDashboard: type: object required: [activeGroupsCount, totalContributed] properties: activeGroupsCount: type: integer totalContributed: type: number nextContributionAmount: type: ["number", "null"] nextContributionDue: type: ["string", "null"] nextPayoutCycle: type: ["integer", "null"] nextPayoutDate: type: ["string", "null"] groups: type: array items: $ref: "#/components/schemas/GroupSummary" recentActivity: type: array items: $ref: "#/components/schemas/ActivityItem" LiveCycleStatus: type: object required: [actualPool, paidCount, unpaidCount, daysRemaining, hoursRemaining, minutesRemaining, secondsRemaining] properties: actualPool: type: number paidCount: type: integer unpaidCount: type: integer daysRemaining: type: integer hoursRemaining: type: integer minutesRemaining: type: integer secondsRemaining: type: integer ActivityItem: type: object required: [id, type, message, createdAt] properties: id: type: integer type: type: string message: type: string groupName: type: ["string", "null"] createdAt: type: string # NOTIFICATIONS Notification: type: object required: [id, userId, title, message, isRead, sentAt] properties: id: type: integer userId: type: integer groupId: type: ["integer", "null"] type: type: ["string", "null"] title: type: string message: type: string channel: type: ["string", "null"] isRead: type: boolean sentAt: type: string NotificationsResponse: type: object required: [notifications, unreadCount] properties: notifications: type: array items: $ref: "#/components/schemas/Notification" unreadCount: type: integer