Skip to content

frckbrice/cocoa-farming-api_spec

Repository files navigation

CocoaFlow API Specification

OpenAPI 3.1.0 License: Apache 2.0 Node.js Redocly CI/CD Docker TypeScript

CocoaFlow API Specification

Professional OpenAPI 3.1.0 specification for CocoaFlow, a cocoa industry management platform. The repository provides the API contract, interactive documentation, and generated artifacts (TypeScript client and Postman collection) with CI/CD and containerized deployment.

Overview

CocoaFlow API defines a production-ready contract for cocoa industry operations: farmer and farm management, GPS and inspection data, Rainforest Alliance certification, campaigns, markets, transactions, training, and subscriptions. The spec is the single source of truth for frontend and backend integration.

Technical Highlights

  • OpenAPI 3.1.0 with modular paths and reusable components
  • 50+ endpoints across auth, users, companies, farms, projects, campaigns, markets, transactions, training, inspections, audits, and subscriptions
  • Standardized request/response examples and error schemas (4xx/5xx)
  • JWT Bearer and API key security; rate limiting and validation
  • Generated TypeScript client (OpenAPI Generator) and Postman collection for testing
  • CI/CD (GitHub Actions), Docker image for docs, and deployment to GitHub Pages / Vercel

Quick Start

Prerequisites

  • Node.js 22+
  • npm 8+
  • Docker (optional)

Installation

git clone git@github.com:frckbrice/project-api_spec.git
cd project-api_spec
npm install
npm run docs:serve

Documentation is served at http://localhost:8080.

Scripts

Command Description
npm run docs:serve Serve interactive docs (port 8080)
npm run docs:build Build static documentation
npm run bundle Bundle spec to dist/cocoaflow-api.yaml
npm run lint Lint OpenAPI spec
npm run validate Validate against OpenAPI 3.1.0
npm run test Lint, validate, format check
npm run generate:client Generate TypeScript client to generated/typescript/
npm run generate:postman Generate Postman collection to generated/postman/

Docker

docker build -t cocoaflow-api-docs .
docker run -p 8080:8080 cocoaflow-api-docs

Documentation and Deployment

Environment URL Notes
GitHub Pages project-api_spec Published docs
Raw spec cocoaflow-api.yaml Bundled OpenAPI YAML
Local http://localhost:8080 After npm run docs:serve

Project Structure

project-api_spec/
├── swt_api_spec/                 # OpenAPI source
│   ├── components/
│   │   ├── schemas/              # Data models
│   │   ├── responses/            # Reusable response definitions
│   │   └── parameters/           # Shared parameters
│   ├── paths/                    # Endpoints by domain (auth, user, companies, farm, project, etc.)
│   └── cocoaflow-api.yaml       # Root spec
├── dist/                         # Bundled spec (output of bundle)
├── generated/                    # Generated artifacts (gitignored; run generate scripts to create)
│   ├── typescript/               # Generated TypeScript client (npm run generate:client)
│   └── postman/                  # Generated Postman collection (npm run generate:postman)
├── postman/                      # Legacy/unused; Postman output lives in generated/postman/
├── public/                       # Built documentation assets
├── .github/workflows/            # CI/CD
├── redocly.yaml                  # Redocly and lint config
├── Dockerfile                    # Docs server image
└── package.json

Adding or Changing Endpoints

  1. Add or edit YAML under swt_api_spec/paths/ (and components/schemas/ if needed).
  2. Reference new paths in swt_api_spec/cocoaflow-api.yaml under paths:.
  3. Include request body examples for POST/PUT/PATCH and response examples for success and errors.
  4. Run npm run lint && npm run validate, then npm run docs:serve to verify.

Security and Compliance

  • Auth: JWT Bearer (primary), API key for service-to-service, OAuth2 optional.
  • Practices: HTTPS, rate limiting, input validation, CORS, security headers.
  • Compliance: Rainforest Alliance-related flows, audit considerations, data privacy.

Generated Artifacts

License

Apache License 2.0. See LICENSE.

Contact


OpenAPI 3.1.0, Redocly, Docker, GitHub Actions, TypeScript.

About

The openApi specification for a project based on collecting data from multiple farms across the Cameroon country.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages