- Introduction
- Features
- Technologies Used
- Installation
- Configuration
- Usage
- API Documentation
- Deployment
This is the REST API used by the cultivitea application. This API allows users to manage user accounts, create discussions, comment on discussions, view and update profiles, and make predictions for tea diseases.
- Authentication: User registration, login, and authentication using Firebase Auth.
- Discussion: Create, read, update, and delete discussion posts.
- Comments: Add, read, and delete comments on discussion posts.
- Profile: View and update user profiles.
- Prediction: Make predictions using a model stored in Cloud Storage.
- Node.js and Express for building the REST API.
- Docker for containerizing the application.
- Swagger for API documentation.
- Firebase Authentication for user authentication.
- Firestore for storing user data such as profiles, discussions, comments, and predictions.
- Cloud Storage for storing static data (images) and models.
- Cloud Build for automating the build process.
- Artifact Registry for storing container images.
- Google Cloud Run for deploying the backend.
- Clone the repository:
git clone https://github.com/Cultivitea/Cultivitea-CC.git cd Cultivitea-CC
- Install Dependencies
npm install
- Create a
.env
file in the root of the project. - Copy the contents of
.env.example
file and paste it into the.env
file. - Set up your
port
,service account firebase
,Firebase configuration
, and yoururl model
that is saved on Cloud Storage.
-
Start the server
npm run start: dev
Or
npm run start
-
The server will be running on
http://localhost:8080
You can see the documentation in the Cultivitea APIs Docs or if you already have the server running, then you can go to the following URL: http://localhost:8080/api-docs
We deployed the backend using Google Cloud Platform (GCP) services, specifically Cloud Run. Here’s how to do it:
-
Enable Artifact Registry API:
gcloud services enable artifactregistry.googleapis.com cloudbuild.googleapis.com run.googleapis.com
-
Create an Artifact Registry repository:
gcloud artifacts repositories create cultivitea --repository-format=docker --location=asia-southeast2 --async
-
Build a new container image and make sure you are in the same directory as the Dockerfile:
docker build -t asia-southeast2-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/cultivitea/cultivitea:1.0.0 .
-
Push to Artifact Registry:
docker push asia-southeast2-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/cultivitea/cultivitea:1.0.0
-
Deploy to Cloud Run:
gcloud run deploy cultivitea --image asia-southeast2-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/cultivitea/cultivitea:1.0.0 --platform managed --region asia-southeast2 --set-env-vars PORT=8080,MODEL_URL=your_model_url_here
-
The backend is successfully deployed and ready to be used. You can access the API docs globally. For example: Cultivitea APIs Docs