A modern AI-powered text summarization service built with FastAPI and Next.js App Router.
This project has been completely refactored from the legacy structure to a modern, scalable architecture:
- FastAPI 0.104.1 with async/await support
- SQLAlchemy 2.0 with async engine and sessions
- PostgreSQL with asyncpg driver
- Alembic for database migrations
- JWT Authentication with secure password hashing
- Pydantic v2 for data validation
- Modern ML Stack: PyTorch, Transformers, spaCy
- Next.js 14 with App Router
- TypeScript for type safety
- Tailwind CSS with shadcn/ui components
- React Hook Form with Zod validation
- Axios for API communication
- Responsive design with modern UI/UX
/
├── backend/ # FastAPI Application
│ ├── app/
│ │ ├── api/v1/ # API Routes
│ │ │ ├── endpoints/ # Individual endpoint modules
│ │ │ └── api.py # Main API router
│ │ ├── core/ # Core configuration
│ │ │ ├── config.py # Settings management
│ │ │ └── security.py # Authentication & security
│ │ ├── crud/ # Database operations (async)
│ │ ├── db/ # Database setup
│ │ │ ├── session.py # Async session management
│ │ │ └── base_class.py # Base model class
│ │ ├── models/ # SQLAlchemy models
│ │ ├── schemas/ # Pydantic schemas
│ │ ├── services/ # Business logic
│ │ └── main.py # FastAPI app entrypoint
│ ├── alembic/ # Database migrations
│ ├── tests/ # Backend tests (pytest-asyncio)
│ ├── requirements.txt # Python dependencies
│ └── Dockerfile # Backend container
│
├── frontend/ # Next.js Application
│ ├── src/
│ │ ├── app/ # App Router structure
│ │ │ ├── layout.tsx # Root layout
│ │ │ ├── page.tsx # Home page
│ │ │ └── globals.css # Global styles
│ │ ├── components/ # React components
│ │ │ ├── ui/ # Basic UI components
│ │ │ └── shared/ # Complex shared components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── lib/ # Utility libraries
│ │ │ ├── api.ts # API client
│ │ │ └── utils.ts # Utility functions
│ │ ├── store/ # State management
│ │ └── types/ # TypeScript definitions
│ ├── public/ # Static assets
│ ├── package.json # Node.js dependencies
│ └── Dockerfile # Frontend container
│
└── docker-compose.yml # Multi-service orchestration
- Text Summarization: Paste text directly for instant summarization
- URL Summarization: Extract and summarize content from web articles
- Summary History: Browse and manage previously generated summaries
- Real-time Processing: Background task processing for URL content extraction
- Async Architecture: Full async/await implementation for optimal performance
- Type Safety: Complete TypeScript coverage on frontend
- Modern UI: Responsive design with Tailwind CSS and shadcn/ui
- Database Migrations: Alembic for schema version control
- Comprehensive Testing: pytest-asyncio test suite
- Docker Support: Multi-service containerization
- Security: JWT authentication with secure password hashing
- Python 3.11+
- Node.js 18+
- PostgreSQL 15+
- Docker & Docker Compose (optional)
- Clone and setup backend:
cd backend
pip install -r requirements.txt
python -m spacy download en_core_web_sm
# Setup database
cp .env.example .env # Configure your database URL
alembic upgrade head
# Run backend
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
- Setup frontend:
cd frontend
npm install
# Run frontend
npm run dev
- Using Docker (recommended):
docker-compose up --build
- Frontend: http://localhost:12000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
POST /api/v1/summaries/
- Create new summaryGET /api/v1/summaries/
- List all summariesGET /api/v1/summaries/{id}
- Get specific summaryDELETE /api/v1/summaries/{id}
- Delete summary
GET /api/v1/health
- Health check endpoint
DATABASE_URL=postgresql+asyncpg://user:pass@localhost:5432/summarizerdb
SECRET_KEY=your-secret-key-here
ENVIRONMENT=development
HF_TOKEN=your-huggingface-token # Optional for advanced models
NEXT_PUBLIC_API_URL=http://localhost:8000
cd backend
pytest -v
cd frontend
npm run type-check
This refactoring includes:
- ✅ Migrated from Tortoise ORM to SQLAlchemy 2.0 async
- ✅ Updated to FastAPI 0.104.1 with modern patterns
- ✅ Implemented proper async database sessions
- ✅ Added Alembic for database migrations
- ✅ Modernized ML dependencies (PyTorch 2.1.1, Transformers 4.35.2)
- ✅ Added comprehensive test suite with pytest-asyncio
- ✅ Implemented JWT authentication system
- ✅ Migrated from Pages Router to App Router (Next.js 14)
- ✅ Updated to modern React patterns with hooks
- ✅ Implemented TypeScript throughout
- ✅ Added modern UI with Tailwind CSS and shadcn/ui
- ✅ Integrated React Hook Form with Zod validation
- ✅ Added proper state management patterns
- ✅ Updated Docker configuration for multi-service setup
- ✅ Added proper environment configuration
- ✅ Implemented proper CORS settings for development
- ✅ Added health check endpoints
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License.