A full-stack AI-powered starter template with Next.js frontend, Express backend, and a Python AI module.
Structured into app/, api/, and ai/ for clean development, rapid prototyping, and seamless integration.
- Frontend: Next.js (TypeScript, pnpm)
- Backend: Express.js (Node.js, pnpm)
- AI Service: Python (Flask)
- Containerization: Docker + Docker Compose
- CI/CD: GitHub Actions (ready for build + push caching)
.
├── app/ # Next.js frontend
│ └── Dockerfile
├── api/ # Express backend
│ └── Dockerfile
├── ai/ # Python Flask microservice
│ ├── main.py
│ ├── requirements.txt
│ └── Dockerfile
├── docker-compose.yml
└── pnpm-workspace.yaml
git clone https://github.com/upayanmazumder/next-api-ai-template.git
cd next-api-ai-templateBuild and start all services:
docker compose up --buildThen open:
- Frontend: http://localhost:3000
- API: http://localhost:4000
- AI: http://localhost:5000
- Next.js (
app/) → Handles UI + user interactions. - Express (
api/) → Acts as middleware and routes frontend requests to AI service. - Flask (
ai/) → Processes AI logic or ML inference and returns responses to the API.
Each layer is isolated, containerized, and easily swappable.
- Frontend sends text →
/api/analyze - Express forwards it to Flask at
/predict - Flask responds with mock or real AI prediction
- Response bubbles back to UI instantly
| Service | Port | Description |
|---|---|---|
app |
3000 | Next.js frontend |
api |
4000 | Express backend |
ai |
5000 | Flask AI service |
Each service includes caching, health checks, and restart policies. You can deploy them independently or as a full stack.
- Uses
pnpmfor efficient dependency management. - Python virtual env not needed — handled via Docker.
- Ready for GitHub Actions auto-build (with GHA cache).
# Run locally (no docker)
cd app && pnpm dev
cd api && pnpm run dev
cd ai && python main.py
# Run all with docker
docker compose up- Add real model inference (OpenAI / Ollama / HuggingFace)
- Add shared types via
common/ - Integrate PostgreSQL or Redis service
- Deploy to Fly.io, Railway, or Render
Licensed under the MIT License.