Loading repository data…
Loading repository data…
krishnakamalbaishnab / repository
A FastAPI starter template with JWT auth, MongoDB, and LLM integration
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A production-ready FastAPI template with MongoDB integration, JWT authentication, and LLM support. Perfect for building scalable APIs with modern Python practices.
/docs├── app/
│ ├── api/
│ │ ├── deps.py # Dependencies and authentication
│ │ └── v1/
│ │ ├── api.py # Main API router
│ │ └── routes/
│ │ ├── auth.py # Authentication endpoints
│ │ ├── user.py # User management endpoints
│ │ └── llm.py # LLM integration endpoints
│ ├── core/
│ │ ├── config.py # Settings and configuration
│ │ └── security.py # JWT and password utilities
│ ├── db/
│ │ ├── mongodb.py # Database connection
│ │ └── crud/
│ │ └── user.py # User CRUD operations
│ ├── models/
│ │ └── user.py # Pydantic models
│ ├── schemas/
│ │ └── auth.py # Request/response schemas
│ └── services/
│ ├── auth_service.py # Authentication business logic
│ └── llm_client.py # LLM integration service
├── tests/
│ ├── conftest.py # Pytest configuration
│ ├── test_auth.py # Authentication tests
│ └── test_users.py # User endpoint tests
├── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
├── Dockerfile # Production Docker image
├── docker-compose.yml # Local development setup
├── env.example # Environment variables template
└── README.md # This file
Clone the repository
git clone https://github.com/krishnakamalbaishnab/TemplatesFastAPI.git
cd TemplatesFastAPI
Set up environment variables
cp env.example .env
# Edit .env with your configuration
Install dependencies
pip install -r requirements.txt
Start MongoDB (if using local MongoDB)
# Using Docker
docker run -d -p 27017:27017 --name mongodb mongo:7.0
# Or install MongoDB locally
Run the application
uvicorn main:app --reload
Access the API
Start all services
docker-compose up -d
Access services
View logs
docker-compose logs -f app
Copy env.example to .env and configure:
# Security
SECRET_KEY=your-secret-key-here
ACCESS_TOKEN_EXPIRE_MINUTES=30
# MongoDB
MONGODB_URL=mongodb://localhost:27017
MONGODB_DB_NAME=fastapi_template
# LLM Settings
OPENAI_API_KEY=your-openai-api-key
GEMINI_API_KEY=your-gemini-api-key
LLM_PROVIDER=openai # or "gemini"
# CORS
BACKEND_CORS_ORIGINS=["http://localhost:3000"]
POST /api/v1/auth/register - Register new userPOST /api/v1/auth/login - Login with form dataPOST /api/v1/auth/login-json - Login with JSONGET /api/v1/users/me - Get current user (authenticated)PUT /api/v1/users/me - Update current user (authenticated)GET /api/v1/users/ - Get all users (superuser only)GET /api/v1/users/{user_id} - Get user by ID (superuser only)PUT /api/v1/users/{user_id} - Update user (superuser only)DELETE /api/v1/users/{user_id} - Delete user (superuser only)POST /api/v1/llm/generate - Generate text (authenticated)POST /api/v1/llm/chat - Chat completion (authenticated)GET /api/v1/llm/models - Get available models (authenticated)Run the test suite:
# Run all tests
pytest
# Run with coverage
pytest --cov=app
# Run specific test file
pytest tests/test_auth.py
# Run with verbose output
pytest -v
# Build the image
docker build -t fastapi-template .
# Run the container
docker run -p 8000:8000 --env-file .env fastapi-template
Build production image
docker build -t fastapi-template:prod .
Run with production settings
docker run -d \
--name fastapi-app \
-p 8000:8000 \
--env-file .env.prod \
fastapi-template:prod
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions or need help, please open an issue on GitHub.
Made with ❤️ for the FastAPI community