A chatgpt clone web application that leverages Google's Gemini AI 1.5 Flash model to provide intelligent conversational responses. Built with microservices architecture using Go, Next.js, and gRPC.
You can access the live demo of the application here.
The application is built using microservices architecture with the following services:
- Web Service: Next.js frontend application
- API Gateway: Go service that handles routing and communication between services
- Auth Service: Handles user authentication and authorization
- Chat Service: Manages chat functionality and Gemini AI integration
- User Service: Handles user management and profiles
Below is the diagram of the application architecture:
- Real-time chat functionality using Socket.IO
- Google OAuth authentication
- Conversational AI powered by Gemini 1.5 Flash
- Responsive web interface
- Chat history
- Docker and Docker Compose
- Go 1.23.2 or later
- Node.js 20 or later
- PostgreSQL
- Google Cloud Platform account for Gemini AI API
- Clone the repository:
git clone https://github.com/rizalord/chatgpt-clone.git
cd chatgpt-clone
- Configure environment variables:
- Copy
.env.example
to.env
in each service directory - Set up required environment variables, including:
- Database credentials
- Gemini API key
- Google OAuth credentials
- JWT secrets
Edit the database URL in the migrate
command to match your database configuration. You will need the migrate
package from golang-migrate to run this command.
migrate -database "postgres://postgres@localhost:5432/chatgpt_clone?sslmode=disable" -path ./migrations up
docker compose up -d
To run the application locally without Docker, follow these steps:
# Start the gRPC services
cd services/user-service && go run cmd/worker/main.go
cd services/auth-service && go run cmd/worker/main.go
cd services/chat-service && go run cmd/worker/main.go
# Start the API Gateway
cd services/api-gateway && go run cmd/web/main.go
# Start the web frontend
cd services/web-service && npm install && npm run dev
├── services/
│ ├── api-gateway/ # API Gateway service
│ ├── auth-service/ # Authentication service
│ ├── chat-service/ # Chat and Gemini AI service
│ ├── user-service/ # User management service
│ └── web-service/ # Next.js frontend
├── migrations/ # Database migrations
└── docker-compose.yml # Docker compose configuration
The API Gateway service exposes RESTful endpoints and WebSocket connections for:
- User authentication
- Chat management
- Message streaming
You can find the API Documentation here.
- Fork the repository
- Create a new branch (
git checkout -b feature/awesome-feature
) - Commit the changes (
git commit -am 'Add awesome feature'
) - Push to the branch (
git push origin feature/awesome-feature
) - Create a new Pull Request