A comprehensive Node.js backend service for the ChikRice fitness application, built with Express.js, MongoDB, and TypeScript.
- Authentication & Authorization: JWT-based auth with Google OAuth support
- User Management: Complete user CRUD operations with role-based access
- Meal Planning: Meal generation and planning system
- Roadmap System: Fitness goal tracking and milestone management
- Email Notifications: Password reset, email verification, and notifications
- API Documentation: Auto-generated Swagger/OpenAPI documentation
- Testing: Comprehensive test suite with Jest
- Docker Support: Containerized deployment with Docker Compose
- Node.js (>= 12.0.0)
- Docker & Docker Compose
- Git
The easiest way to get started:
# 1. Clone the repository
git clone https://github.com/chikrice/chikrice-backend.git
cd chikrice-backend
# 2. Copy environment file
cp env.example .env
# 3. Start the application with Docker
yarn docker:devThat's it! Your application will be running at http://localhost:3000 with:
- β Node.js application with hot reload
- β MongoDB database
- β All dependencies installed
- β Development environment configured
π‘ Recommended: Use MongoDB Compass for Database Management
For a better development experience, we recommend using MongoDB Compass - a GUI for MongoDB:
- Download MongoDB Compass from the official website
- Connect using:
mongodb://localhost:27017 - Browse your databases, collections, and documents visually
- Build queries using the visual query builder
- Analyze your data structure and performance
If you prefer to set up everything manually:
git clone https://github.com/your-username/chikrice-backend.git
cd chikrice-backend
yarn install# Copy the example environment file
cp env.example .env
# Edit with your configuration
nano .envOption A: Local MongoDB
Using Docker:
docker run -d -p 27017:27017 --name mongodb mongo:latestUsing Manual Installation:
- macOS: Follow the official MongoDB installation guide
- Ubuntu/Debian: Follow the official MongoDB installation guide
- Windows: Follow the official MongoDB installation guide
Option B: MongoDB Atlas (Cloud - Recommended for production)
- Create a free account at MongoDB Atlas
- Create a new cluster
- Get your connection string
- Update
MONGODB_URL_DEVin your.envfile
yarn devThe server will start at http://localhost:3000
| Variable | Description | Example |
|---|---|---|
NODE_ENV |
Environment mode | development |
PORT |
Server port | 3000 |
MONGODB_URL_DEV |
Development database URL | mongodb://localhost:27017/chikrice |
JWT_SECRET |
JWT signing secret | Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" |
| Variable | Description | Setup Guide |
|---|---|---|
GOOGLE_CLIENT_ID |
Google OAuth Client ID | Google Cloud Console Setup |
GOOGLE_CLIENT_SECRET |
Google OAuth Client Secret | Google Cloud Console Setup |
SMTP_HOST |
Email server host | Email Setup |
SMTP_USERNAME |
Email username | Email Setup |
SMTP_PASSWORD |
Email password | Email Setup |
OPENAI_API_KEY |
OpenAI API key | OpenAI Setup |
yarn docker:devyarn docker:prodyarn docker:testFor Google authentication functionality:
- Go to Google Cloud Console
- Create a new project or select existing
- Enable the Google+ API
- Go to "Credentials" β "Create Credentials" β "OAuth 2.0 Client IDs"
- Set application type to "Web application"
- Add authorized redirect URIs:
http://localhost:3030/auth/callback(development)https://yourdomain.com/(production)
- Copy the Client ID and Client Secret to your
.envfile
For email functionality (password reset, verification):
Gmail (Recommended for development)
- Enable 2-factor authentication on your Gmail account
- Generate an App Password: Google Account β Security β App Passwords
- Use your Gmail address and the generated app password
For AI-powered meal generation:
- Sign up at OpenAI
- Go to API Keys section
- Create a new API key
- Add it to your
.envfile
Once the server is running, you can access:
- Swagger UI:
http://localhost:3000/v1/docs - API Health Check:
http://localhost:3000/v1/health
src/
βββ config/ # Configuration files
βββ controllers/ # Route controllers
βββ middlewares/ # Custom middlewares
βββ models/ # Database models
βββ routes/ # API routes
βββ services/ # Business logic
βββ types/ # TypeScript type definitions
βββ utils/ # Utility functions
βββ validations/ # Request validation schemas
If you are a frontend developer
This repository contains the backend API for the ChikRice fitness application. If you're interested in working on the frontend side, we have a separate repository dedicated to the user interface:
The frontend is built with modern technologies including:
- React 18 with TypeScript
- Material-UI (MUI) for professional UI components
- Zustand for state management
- Vite for fast development
- React Hook Form for form handling
# Clone the frontend repository
git clone https://github.com/chikrice/chikrice-user-frontend.git
cd chikrice-user-frontend
# Install dependencies
yarn install
# Start development server
yarn devThe frontend will run at http://localhost:3030 and will connect to this backend API at http://localhost:3000.
For a complete development experience, you can run both repositories simultaneously:
- Backend (this repo):
yarn docker:devβhttp://localhost:3000 - Frontend:
yarn devβhttp://localhost:3030
This setup allows you to work on both the API and the user interface in parallel!
The archive/ folder contains legacy features that are no longer actively used in the main project but are preserved for reference or potential future re-integration. These archived features include:
- Meal Management System: Legacy meal planning and generation logic
- Combo Management: Previous combo meal creation and management features
- Menu Management: Archived menu planning and organization system
- Subscription System: Legacy subscription handling and management
These features have been replaced by the current meal planning and roadmap systems but are maintained for historical reference and potential future use.
We welcome contributions! Please see our Contributing Guide for details on:
- Code style guidelines
- Testing requirements
- Pull request process
This project is licensed under the MIT License - see the LICENSE file for details.
- π Documentation
- π Report Issues
- π¬ Discussions
- @hagopj13/node-express-boilerplate - This project was built upon the excellent Node.js Express boilerplate by Hagop Jamkojian
- Express.js team for the amazing framework
- MongoDB team for the database
- All contributors who help improve this project
Note: This is an open-source project. Please ensure you never commit sensitive information like API keys or database credentials to the repository.