A modular FastAPI project built to practice and demonstrate core LangChain concepts through multiple real-world APIs.
This project follows a clean architecture where each task is organized into its own module while sharing a common configuration and LLM setup.
- FastAPI
- LangChain Expression Language (LCEL)
- PromptTemplate
- RunnableBranch
- RunnableLambda
- RunnableParallel
- RunnablePassthrough
- Structured Output
- Pydantic Models
- Google Gemini Integration
- Environment Configuration
- Modular API Design
Simple API to verify the application is running.
Endpoint
GET /health
Transforms text using RunnableBranch.
Supported actions:
- Summarize
- Translate
- Tone Shift
Endpoint
POST /transform
- PromptTemplate
- RunnableBranch
- StrOutputParser
Extracts structured information from resume text.
Returns
- Name
- Skills
- Years of Experience
- Last Role
Endpoint
POST /parse-resume
- Structured Output
- Pydantic Models
- PromptTemplate
Classifies user questions into
- Coding
- Math
- General
Routes them to domain-specific prompts.
Endpoint
POST /ask
- RunnableLambda
- RunnableBranch
- LCEL
Generates multiple social media contents simultaneously.
Returns
- Tweet
- LinkedIn Caption
- Hashtags
Endpoint
POST /generate-post
- RunnableParallel
- RunnablePassthrough
Creates an answer, reviews it, and improves it if required.
**Endpoint**
POST /answer
### Concepts
- Multi-step Chains
- Prompt Chaining
- Self-Correcting Workflow
---
# 🏗 Architecture
Every module follows the same architecture.
Request │ ▼ Router │ ▼ Workflow │ ▼ Prompt │ ▼ Gemini │ ▼ Response
This separation keeps the project clean, reusable, and easy to maintain.
---
# 🛠 Installation
Clone the repository
```bash
git clone <repository-url>
Navigate to the project
cd langchain-practiceCreate virtual environment
uv venvActivate environment
Windows
.venv\Scripts\activateInstall dependencies
uv syncCreate a .env file.
GOOGLE_API_KEY=YOUR_API_KEY
MODEL_NAME=gemini-2.5-flashuv run uvicorn main:app --reloadSwagger UI
http://127.0.0.1:8000/docs
- PromptTemplate
- RunnableBranch
- RunnableLambda
- RunnableParallel
- RunnablePassthrough
- StrOutputParser
- Structured Output
- LCEL Pipelines
| Method | Endpoint | Description |
|---|---|---|
| GET | /health | Health Check |
| POST | /transform | Smart Text Toolkit |
| POST | /parse-resume | Resume Parser |
| POST | /ask | Query Router |
| POST | /generate-post | Parallel Content Generator |
| POST | /answer | Self Correcting Answer |
This project demonstrates practical implementation of:
- Modular FastAPI Architecture
- LangChain LCEL
- Prompt Engineering
- Structured Output
- Branching Workflows
- Parallel Execution
- Self-Correcting LLM Pipelines
- Reusable Prompt Management
- Environment-based Configuration
- Clean Project Organization
Rishu Raj
Built as a LangChain Practice Assessment to gain hands-on experience with modern LLM application development using FastAPI and LangChain.