Ocha API is the REST backend that powers Ocha, a fictitious matcha shop chain. It provides endpoints for managing users, products, stores, and orders, with role-based access control for both regular customers and administrators. The API is built with Node.js and Express.js, stores data in MongoDB via Mongoose, and uses JWT tokens for authentication.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/floriansalvi/HEIG-VD_Ocha-api/llms.txt
Use this file to discover all available pages before exploring further.
Tech stack
| Layer | Technology |
|---|---|
| Runtime | Node.js 18+ with Express.js |
| Database | MongoDB with Mongoose ODM |
| Authentication | JSON Web Tokens (JWT) |
| Password hashing | bcrypt |
| Image storage | Cloudinary |
| Real-time | WebSockets (ws library) |
| Documentation | OpenAPI (Swagger) |
Resources
The API exposes four main resource types:- Users — account registration, profile retrieval, and order history
- Products — full CRUD with image upload and real-time broadcast on creation
- Stores — full CRUD with geolocation filtering
- Orders — order creation, status updates, item retrieval, and aggregated stats
Roles
All new accounts are created with theuser role. The admin role unlocks additional write operations such as creating products and stores, deleting resources, and accessing order statistics. Role assignment is managed directly in the database.
Base URL
API documentation
Interactive Swagger UI is available athttp://localhost:5001/api/v1/api-docs once the server is running.
Where to go next
Quickstart
Clone the repo, configure environment variables, and make your first request in minutes.
Authentication
Understand JWT tokens, registration, login, and how to pass credentials to protected routes.
Register a user
Full reference for the POST /api/v1/auth endpoint with request and response schemas.
Filtering and pagination
Learn how to filter products by status, paginate results, and query stores by location.