An intelligent document management and chat system powered by AI. Upload your documents, organize them, and chat with an AI assistant that has access to your document context.
- π Document Management - Upload, organize, and manage your documents
- π¬ AI-Powered Chat - Chat with an AI assistant that understands your documents
- π Vector Search - Semantic search across your document collection using Pinecone
- π Authentication - Secure login with email/password or OAuth (Google, GitHub)
- π Storage Tracking - Monitor your storage usage and limits
- βοΈ Cloud-Native - Deployed on Google Cloud Run for scalability
- π CI/CD Pipeline - Automated testing and deployment with GitHub Actions
- Frontend: https://docu-mate-frontend-368729308066.us-central1.run.app
- API Documentation:
- Swagger UI - Interactive API explorer
- ReDoc - Alternative API documentation
βββββββββββββββββββ
β Next.js β
β Frontend β
β (Cloud Run) β
ββββββββββ¬βββββββββ
β
β
βββββββββββββββββββ ββββββββββββββββ
β FastAPI ββββββββ Cloud SQL β
β Backend β β PostgreSQL β
β (Cloud Run) β ββββββββββββββββ
ββββββββββ¬βββββββββ
β
ββββββββ Pinecone (Vector DB)
ββββββββ Google Gemini (AI)
Tech Stack:
- Frontend: Next.js 16, React, TailwindCSS, NextAuth v5
- Backend: FastAPI (Python), SQLAlchemy, Alembic
- Database: PostgreSQL (Cloud SQL)
- Vector Store: Pinecone
- AI Model: Google Gemini
- Deployment: Google Cloud Run
- CI/CD: GitHub Actions
- Node.js 20+
- Python 3.11+
- PostgreSQL 15+
- Docker (optional, for containerized development)
- Google Cloud account (for deployment)
- Pinecone account
- Google Gemini API key
git clone https://github.com/PetrovEvgeniy/docu-mate.git
cd docu-matecd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt # For testing
# Set up environment variables
cp .env.example .env
# Edit .env with your values (see Configuration section)
# Run database migrations
alembic upgrade head
# Start the backend server
uvicorn main:app --reload --port 8000Backend will be available at http://localhost:8000
cd frontend
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your values (see Configuration section)
# Start the development server
npm run devFrontend will be available at http://localhost:3000
Backend:
cd backend
pytest --cov=. --cov-report=term-missingFrontend:
cd frontend
npm testCreate backend/.env:
# Database
DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/documate
# JWT Secret (generate with: openssl rand -hex 32)
SECRET_KEY=your-secret-key-here
# Pinecone
PINECONE_API_KEY=your-pinecone-api-key
PINECONE_INDEX_NAME=docu-mate
# Google Gemini
GEMINI_API_KEY=your-gemini-api-keyCreate frontend/.env:
# Backend API URL
NEXT_PUBLIC_API_URL=http://localhost:8000
# NextAuth Configuration
AUTH_SECRET=your-auth-secret-here # generate with: openssl rand -hex 32
AUTH_URL=http://localhost:3000
NEXTAUTH_URL=http://localhost:3000
# Google OAuth (optional)
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
# GitHub OAuth (optional)
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secretPinecone:
- Sign up at pinecone.io
- Create a new index with:
- Name:
docu-mate - Dimensions:
768(for Gemini embeddings) - Metric:
cosine
- Name:
Google Gemini:
- Go to Google AI Studio
- Create an API key
Google OAuth (optional):
- Go to Google Cloud Console
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google
GitHub OAuth (optional):
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set authorization callback URL:
http://localhost:3000/api/auth/callback/github
- Google Cloud account with billing enabled
gcloudCLI installed and authenticated- Docker installed
# Set your project ID
export PROJECT_ID=your-project-id
gcloud config set project $PROJECT_ID
# Enable required APIs
gcloud services enable run.googleapis.com
gcloud services enable cloudbuild.googleapis.com
gcloud services enable sqladmin.googleapis.com
gcloud services enable secretmanager.googleapis.com# Create PostgreSQL instance
gcloud sql instances create docu-mate-db \
--database-version=POSTGRES_15 \
--tier=db-f1-micro \
--region=us-central1
# Create database
gcloud sql databases create documate --instance=docu-mate-db
# Create user
gcloud sql users create documate-user \
--instance=docu-mate-db \
--password=your-secure-password# Backend secrets
echo -n "postgresql+asyncpg://user:password@/documate?host=/cloudsql/PROJECT:REGION:INSTANCE" | \
gcloud secrets create DATABASE_URL --data-file=-
echo -n "your-jwt-secret" | gcloud secrets create JWT_SECRET_KEY --data-file=-
echo -n "your-pinecone-key" | gcloud secrets create PINECONE_API_KEY --data-file=-
echo -n "your-gemini-key" | gcloud secrets create GEMINI_API_KEY --data-file=-
echo -n "docu-mate" | gcloud secrets create PINECONE_INDEX_NAME --data-file=-
# Frontend secrets
echo -n "your-nextauth-secret" | gcloud secrets create NEXTAUTH_SECRET --data-file=-
echo -n "your-google-client-id" | gcloud secrets create GOOGLE_CLIENT_ID --data-file=-
echo -n "your-google-client-secret" | gcloud secrets create GOOGLE_CLIENT_SECRET --data-file=-
echo -n "your-github-client-id" | gcloud secrets create GITHUB_CLIENT_ID --data-file=-
echo -n "your-github-client-secret" | gcloud secrets create GITHUB_CLIENT_SECRET --data-file=-cd backend
gcloud builds submit --config cloudbuild.yaml .Update frontend/cloudbuild.yaml with your backend URL, then:
cd frontend
gcloud builds submit --config cloudbuild.yaml .The repository includes a GitHub Actions workflow for automated deployment on every push to main.
-
Set up Workload Identity Federation (secure, no service account keys):
- Already configured in your project!
-
Add GitHub Secrets:
- Go to:
https://github.com/YOUR_USERNAME/docu-mate/settings/secrets/actions - Add these secrets:
GCP_WORKLOAD_IDENTITY_PROVIDER:projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/github-pool/providers/github-providerGCP_SERVICE_ACCOUNT:github-actions-deployer@PROJECT_ID.iam.gserviceaccount.com
- Go to:
-
Push to main β Automatic deployment! π
Once the backend is running, visit:
- Interactive Docs:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
Authentication:
POST /auth/register- Register new userPOST /auth/login- Login with email/passwordPOST /auth/oauth- OAuth login (Google/GitHub)GET /auth/me- Get current user info
Documents:
POST /upload- Upload documentGET /documents- List user's documentsDELETE /documents/{id}- Delete documentGET /storage- Get storage usage
Chat:
POST /chat- Send chat messageGET /chat/sessions- List chat sessionsPOST /chat/sessions- Create new sessionGET /chat/sessions/{id}/messages- Get session messages
cd backend
pytest -v # Run all tests
pytest tests/test_auth.py -v # Run specific test file
pytest --cov=. --cov-report=html # Generate coverage reportcd frontend
npm test # Run all tests
npm test -- --watch # Watch mode
npm test -- --coverage # With coverageContributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
pytestfor backend,npm testfor frontend) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Backend (Python):
- Follow PEP 8
- Use type hints
- Write docstrings for functions
Frontend (TypeScript):
- Follow ESLint rules
- Use TypeScript strict mode
- Write component tests
This project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI - Backend framework
- Next.js - Frontend framework
- Pinecone - Vector database
- Google Gemini - AI model
- NextAuth - Authentication
Live Demo: https://docu-mate-frontend-368729308066.us-central1.run.app
Built with β€οΈ using Next.js, FastAPI, and Google Cloud