Skip to content

A production-ready AI engineering project template with modern full-stack architecture, authentication, monitoring, and containerized services.

License

Notifications You must be signed in to change notification settings

kchia/ai-engineering-starter

Repository files navigation

πŸ€– AI Engineering Starter Template

πŸš€ Template Usage: This is a GitHub template repository. Click "Use this template" to create your own project based on this starter.

Use this template

A production-ready AI engineering project template with modern full-stack architecture, authentication, monitoring, and containerized services.

Next.js FastAPI TypeScript Docker License: MIT

✨ Features

  • πŸ” Authentication: Next.js with Auth.js v5 (next-auth)
  • ⚑ Modern Stack: Next.js 15.5.4, FastAPI, TypeScript, Tailwind CSS v4
  • πŸ“Š Monitoring: Prometheus metrics, health checks
  • πŸ—„οΈ Database: PostgreSQL with async support
  • 🧠 Vector Search: Qdrant for AI/ML applications
  • ⚑ Cache: Redis for high-performance caching
  • 🐳 Containerized: Docker Compose for easy deployment
  • πŸ§ͺ Testing: Playwright for E2E, pytest for backend
  • πŸ”§ Developer Tools: Hot reloading, type safety, linting

πŸš€ Quick Start

For Template Users

If you're using this template, see TEMPLATE_SETUP.md for detailed setup instructions.

Prerequisites

  • Node.js 18+
  • Python 3.11+
  • Docker Desktop (for services)

1. Install Dependencies

make install

This will:

  • Install npm packages and Playwright browsers
  • Create Python virtual environment
  • Install Python dependencies
  • Copy environment templates

2. Start Development Environment

make dev

Or manually in separate terminals:

# Terminal 1: Start Docker services
docker-compose up -d

# Terminal 2: Start backend
cd backend && source venv/bin/activate && uvicorn src.main:app --reload

# Terminal 3: Start frontend
cd app && npm run dev

3. Access Your Application

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      β”‚    β”‚   Backend       β”‚    β”‚   Services      β”‚
β”‚   (Next.js)     │◄──►│   (FastAPI)     │◄──►│   (Docker)      β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚ β€’ Next.js 15    β”‚    β”‚ β€’ FastAPI       β”‚    β”‚ β€’ PostgreSQL    β”‚
β”‚ β€’ Auth.js v5    β”‚    β”‚ β€’ LangChain     β”‚    β”‚ β€’ Qdrant        β”‚
β”‚ β€’ Tailwind v4   β”‚    β”‚ β€’ Prometheus    β”‚    β”‚ β€’ Redis         β”‚
β”‚ β€’ TypeScript    β”‚    β”‚ β€’ Pydantic      β”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

Frontend (/app)

  • Next.js 15.5.4 with App Router
  • TypeScript for type safety
  • Tailwind CSS v4 for styling
  • Auth.js v5 for authentication
  • Playwright for E2E testing

Backend (/backend)

  • FastAPI for high-performance API
  • LangChain & LangGraph for AI workflows
  • SQLAlchemy with async PostgreSQL
  • Prometheus for metrics collection
  • Pydantic for data validation

Services (docker-compose.yml)

  • PostgreSQL 16 - Primary database (Port 5432)
  • Qdrant - Vector database for AI (Ports 6333/6334)
  • Redis 7 - Cache and sessions (Port 6379)

πŸ› οΈ Development Commands

# Install all dependencies
make install

# Start development environment
make dev

# Run all tests
make test

# Prepare demo environment
make demo

# Clean up containers and dependencies
make clean

# Show help
make help

πŸ“ Project Structure

ai-engineering-starter/
β”œβ”€β”€ app/                     # Next.js frontend
β”‚   β”œβ”€β”€ src/app/            # App Router pages
β”‚   β”œβ”€β”€ auth.config.ts      # Auth.js configuration
β”‚   β”œβ”€β”€ middleware.ts       # Auth middleware
β”‚   └── package.json
β”œβ”€β”€ backend/                # FastAPI backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── main.py        # FastAPI application
β”‚   β”œβ”€β”€ requirements.txt   # Python dependencies
β”‚   └── venv/             # Virtual environment
β”œβ”€β”€ docker-compose.yml     # Service containers
β”œβ”€β”€ Makefile              # Development commands
└── README.md            # This file

πŸ”§ Configuration

Environment Variables

Frontend (.env.local)

# Authentication
AUTH_SECRET=your-secret-key
AUTH_URL=http://localhost:3000

# API Connection
NEXT_PUBLIC_API_URL=http://localhost:8000

Backend (.env)

# Database
DATABASE_URL=postgresql+asyncpg://demo_user:demo_pass@localhost:5432/demo_db

# Vector Database
QDRANT_URL=http://localhost:6333

# Cache
REDIS_URL=redis://localhost:6379

# AI Services (add your keys)
OPENAI_API_KEY=your-openai-key
LANGCHAIN_API_KEY=your-langchain-key

πŸ§ͺ Testing

# Backend tests
cd backend && source venv/bin/activate && pytest tests/ -v

# Frontend unit tests
cd app && npm test

# E2E tests with Playwright
cd app && npm run test:e2e

πŸ“Š Monitoring & Health Checks

🐳 Docker Services

The project includes three essential services:

# PostgreSQL Database
postgres:5432
  - User: demo_user
  - Password: demo_pass
  - Database: demo_db

# Qdrant Vector Database
qdrant:6333/6334
  - Dashboard: :6333/dashboard
  - API: :6333

# Redis Cache
redis:6379
  - Memory limit: 256MB
  - Policy: allkeys-lru

🚨 Troubleshooting

Common Issues

Docker not starting:

# Ensure Docker Desktop is running
open -a Docker

# Check Docker status
docker --version
docker-compose ps

Python environment issues:

# Recreate virtual environment
rm -rf backend/venv
cd backend && python -m venv venv
source venv/bin/activate && pip install -r requirements.txt

Node.js dependency issues:

# Clean install
cd app && rm -rf node_modules package-lock.json
npm install

Port conflicts:

  • Frontend (3000), Backend (8000), PostgreSQL (5432), Qdrant (6333), Redis (6379)
  • Check for other services using these ports: lsof -i :3000

πŸ“ Notes

  • Authentication: Demo credentials configured in auth.config.ts
  • Hot Reloading: Both frontend and backend support hot reloading
  • Type Safety: Full TypeScript support with strict mode
  • Code Quality: Pre-commit hooks with linting and formatting
  • Scalability: Designed for easy deployment to cloud platforms

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Happy coding! πŸš€

About

A production-ready AI engineering project template with modern full-stack architecture, authentication, monitoring, and containerized services.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published