Skip to content

Tổng quan API và dữ liệu ​

Nhóm tài liệu này mô tả phần frontend của việc gọi API: hook nào gọi endpoint nào, frontend gửi tham số gì, kiểu dữ liệu ra sao và cache được làm mới khi nào. Hợp đồng API đầy đủ (phản hồi chi tiết, mã lỗi, schema) thuộc về backend và được dẫn link sang đó, không chép lại.

Vì sao chia như vậy ​

Backend là nguồn đúng cho hình dạng dữ liệu và quy tắc nghiệp vụ. Nếu frontend chép lại request/response đầy đủ thì sẽ có hai bản mô tả và chúng sẽ dần lệch nhau. Vì thế mỗi trang ở đây chỉ ghi những gì chỉ frontend biết: tham số mà code thực sự gửi, hook bọc endpoint, cache tag, nơi dùng và cách UI xử lý kết quả.

Câu hỏiTrả lời ở
Frontend gọi endpoint nào, bằng hook nàoTrang endpoints/* của nhóm này
Một đối tượng dữ liệu có những field gì ở frontendTrang models/* của nhóm này
Backend trả gì, báo lỗi gì, lưu ở collection nàoTài liệu của backend, xem Tham chiếu dữ liệu backend

Hai đường gọi API ​

Hai đường độc lập: request từ trình duyệt đi qua RTK Query và Axios, còn trang công khai render trên server dùng fetch riêng. Chi tiết xem Giao tiếp API.

Streaming chat là đường thứ ba, dùng fetch riêng trong hook use-stream-chat; xem trang endpoint chat.

Bản đồ file API ​

Mỗi file *.api.ts trong src/features/ khai báo một nhóm endpoint. Tổng cộng có 78 endpoint trong 12 file.

File APISố endpointTrang endpoint
auth/redux/auth.api.ts15endpoints/auth
job/redux/job.api.ts9endpoints/jobs và endpoints/job-search
resume/redux/resume.api.ts8endpoints/resumes
cv-profile/redux/cv-profile.api.ts2endpoints/cv-profiles
chatbot/redux/chat-bot.api.ts5endpoints/chat
company/redux/company.api.ts7endpoints/companies
user/redux/user.api.ts14endpoints/users
notification/redux/notification.api.ts5endpoints/notifications
subscriber/redux/subscriber.api.ts7endpoints/subscribers
skill/redux/skill.api.ts2endpoints/skills
statistics/redux/statistics.api.ts2endpoints/statistics
file/redux/file.api.ts2endpoints/files

Trang endpoint: Auth, Jobs, Job Search, Resumes, CV Profiles, Chat, Companies, Users, Notifications, Subscribers, Skills, Statistics, Files. Trang model: User, Job, JobSearchItem, Resume, CV Profile, Chat Message, Company. Thông báo, đăng ký nhận việc và kỹ năng chưa có trang model riêng; định nghĩa nằm ở schemas/ của từng module.

Đọc tiếp ​

Source code liên quan ​

Đọc tiếp: Giao tiếp API, Quản lý state.

Tài liệu kỹ thuật xây dựng theo chuẩn Documentation as Code