This repository is the main backend for the startup template. For reference implementations, check out our other templates:
A NestJS-based backend API template designed to power AI learning and conversation applications. This project serves as the backend infrastructure for an interactive platform that demonstrates advanced AI conversation features and Ionic mobile development.
🎯 Key Features:
- AI conversation management
- Google Cloud Services integration
- Scalable architecture for learning applications
- Ready-to-use authentication system
💡 Note: While the project is tightly integrated with Google Cloud services, these modules can be easily removed if not needed.
Clone the Project
git clone https://github.com/dataclouder-dev/startup-template-node [your-project-name]
or use the button on github right top corner CREATE TEMPLATE
- node >= 22.0.0
- Make >= 3.0.0 (Optional but highly recommended)
- Docker (Optional)
- Env File, rename .env.example to .env and add your environment variables
- Google Cloud credentials and environment variables- Service account credentials go to:
- If you created a firebase project you already have the Google Cloud, got to the link https://console.cloud.google.com/iam-admin/serviceaccounts?project=[your-project-id] and create a service account
- Give Editor Permissions (Unless you know what you are doing then give minimal privileges) and download the json file
- Copy in .cred/keys.json
- MongoDB credentials
- Get the mongo variables, will be easy if you extract from conection string and copy in .env
- example mongodb+srv://admin:[email protected]/my_db_name
- MONGO_USER=admin
- MONGO_PASS=MyPass1234
- MONGO_HOST=cluster0.5q5kdhg.mongodb.net
- MONGO_DB=my_db_name
- Clone the repository
- Configure your environment:
- Copy
.env.example
to.env
- Add your environment variables
- Create
.cred
folder and add Google Cloud credentials
- Copy
- Customize the user model for your needs
npm install
# Development mode
npm run start
# Watch mode (recommended for development)
npm run start:dev
# Production mode
npm run start:prod
# Unit tests
npm run test
# End-to-end tests
npm run test:e2d
# Test coverage
npm run test:cov
You can handle users easialy, create google credentials, for Gcp service, firebase included, and save in .cred/keys.json, check .env.example for variables you may need.
GOOGLE_APPLICATION_CREDENTIALS=./.cred/keys.json
You can remove unnecessary modules by:
- Deleting the module folder
- Removing the import from
app.module.ts
Before deploying, test locally with Docker:
docker build -t dc-template-node .
docker run -p 8080:8080 --env-file ./.env dc-template-node
-
Authenticate with Google Cloud:
gcloud auth login
-
Submit the build: i recommend use the make commands i created to automate, but you can use manual gcloud commands if you have the knowledge.
-
First set environments in makefile or .env, you can leave IMAGE_NAME, REGION, SERVICE_NAME, but PROJECT_ID is uniqui to your project
make gcp-enable-services # will ask to enable bill on GCP this is required to deploy make build-push # make deploy-service
-
Next time you can just run:
make deploy
Note: before try to automate the deployment, i highly recommend do one manual deployment to check if everything is working. specially becouse for every cloud run service, variables need to be set first time, consicutive times no need.
- Fork the repository
- Go to cloud build and create a new trigger
- Grant github access, select the repository and accept conditions
- Add seetings for the trigger to your needs
- Optional: Add permissions to the service account, Logs Writer, Cloud Run Admin or log only default logs
- Add the repository in artifact registry (recommended add policies to remove old versions)
gcloud builds submit --tag gcr.io/ai-learning-dev/node-app-image .
gcloud run deploy ai-learning-service \
--image gcr.io/ai-learning-dev/node-app-image \
--platform managed \
--region us-central1 \
--allow-unauthenticated
git clone https://github.com/adamofig/dataclouder-template-node [new-project-name]
cd [new-project-name]
npm install
npm uninstall @dataclouder/conversation-card-nestjs @dataclouder/lessons-nestjs @dataclouder/storage-uploader
remove module from app module. you are ready to go.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License