An AI-Powered Open-Source Mock API Server that enables users to self-host, manage, and run mock APIs with ease.
mocknica.demo.mp4
Try it out at https://mocknica.dev
Stop waiting for backend APIs. Mocknica empowers frontend developers and teams to build and test applications without backend dependencies.
- β‘ Instant REST Endpoints - Instantly generate REST endpoints you can call from any client
- π Schema-Based Design - Define reusable data schemas and auto-generate complete CRUD endpoints
- π€ AI-Powered Generation - Generate schemas and endpoints using LLM like GPT, Gemini, or local Ollama models
- π¦ Response Wrappers - Customize response structure with reusable wrapper templates
- π Multi-Project Support - Organize mock APIs by project with isolated endpoints and configurations
- π Token Authentication - Secure your mock APIs with Bearer token authentication
- π CORS Configuration - Configure allowed origins for browser requests
| Use Case | Description |
|---|---|
| Frontend Development | Build UIs before backend APIs are ready |
| Rapid Prototyping | Validate ideas quickly with realistic data |
| Demo Applications | Create compelling demos with realistic scenarios |
| QA Testing | Test edge cases with controlled mock data |
| API Design | Design and iterate on API contracts before implementation |
Mocknica is built with modern and reliable technologies:
| Category | Technologies |
|---|---|
| Framework | Next.js, React, TypeScript |
| Styling | Tailwind CSS, Shadcn |
| Data Fetching | TanStack Query |
| Database | PostgreSQL, Prisma ORM |
| Authentication | Better Auth, Google OAuth |
| AI Providers | OpenAI, Google Gemini, Ollama |
| Rate Limiting | Redis, Upstash |
| Monorepo | Turborepo, pnpm Workspaces |
| Testing | Vitest |
| Containerization | Docker |
| CI/CD | GitHub Actions |
| Deployment | Vercel |
Mocknica uses a Turborepo-powered monorepo architecture for better code organization, shared configurations, and efficient builds with caching.
mocknica/
βββ apps/
β βββ dashboard/ # Main Next.js application
β β βββ app/ # App router pages & API routes
β β βββ components/ # React components
β β βββ lib/ # Utilities, services, repositories, auth
β β βββ prisma/ # Database schema & migrations
β βββ www/ # Landing page / Marketing website
βββ packages/
β βββ ui/ # Shared UI component library
β βββ eslint-config/ # Shared ESLint configurations
β βββ tsconfig/ # Shared TypeScript configurations
βββ docker-compose.yml # Docker orchestration
βββ turbo.json # Turborepo configuration
βββ pnpm-workspace.yaml # pnpm workspace config
-
Clone and install
git clone https://github.com/eren1106/mocknica.git cd mocknica pnpm install -
Configure environment
cp apps/dashboard/.env.example apps/dashboard/.env
Add your database, AI provider, and Redis credentials:
# Database (required) DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mocknica" # AI Providers (at least one recommended) GEMINI_API_KEY="your-gemini-key" # Free tier available OPENAI_API_KEY="sk-..." # Optional OLLAMA_BASE_URL="http://localhost:11434" # Optional # Optional: Rate Limiting (recommended for production) REDIS_URL="http://localhost:8079" # Local via proxy, or Upstash URL REDIS_TOKEN="example_token"
-
Better Auth Setup
Generate a secure secret for authentication:
openssl rand -hex 32
Add the generated secret to your
.envfile:BETTER_AUTH_SECRET=your_generated_secret_here BETTER_AUTH_URL="http://localhost:3000"
-
Google OAuth Setup (Optional - for Google sign-in)
-
Go to Google Cloud Console
-
Create a new project (or select an existing one)
-
Navigate to APIs & Services > OAuth consent screen
- Configure the consent screen (External or Internal based on your needs)
- Add your email as a test user during development
-
Navigate to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Select Web application as the application type
- Add authorized redirect URIs:
- Development:
http://localhost:3000/api/auth/callback/google - Production:
https://your-domain.com/api/auth/callback/google
- Development:
-
Add the credentials to your
.envfile:GOOGLE_CLIENT_ID=your_client_id GOOGLE_CLIENT_SECRET=your_client_secret
Note: During development, add yourself as a test user in the OAuth consent screen under Test users.
-
-
Setup database
pnpm docker:db pnpm db:sync
For rate limiting, also start Redis and proxy:
docker-compose up redis serverless-redis-http -d
-
Start developing
pnpm dev
Open http://localhost:3000 to get started.
Deploy the complete stack with a single command:
# Start all services (app, database, Redis)
pnpm docker:up
# Sync database
pnpm db:sync| Service | Description | Port |
|---|---|---|
app |
Mocknica application | 3000 |
db |
PostgreSQL database | 5432 |
redis |
Redis for rate limiting | 6379 |
serverless-redis-http |
Upstash-compatible proxy | 8079 |
Once created, your mock APIs are instantly available:
# Get all items
curl http://localhost:3000/api/mock/{project-id}/users
# Get single item
curl http://localhost:3000/api/mock/{project-id}/users/123
# Create item
curl -X POST http://localhost:3000/api/mock/{project-id}/users \
-H "Content-Type: application/json" \
-d '{"name": "John Doe", "email": "[email protected]"}'
# With authentication
curl http://localhost:3000/api/mock/{project-id}/users \
-H "Authorization: Bearer your-project-token"We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Run tests:
pnpm test - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Use GitHub Issues for bug reports
- Include reproduction steps and environment details
- Check existing issues before creating new ones