Skip to content

zhu0lin/letterbuddy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LetterBuddy - AI-Powered Handwriting Improvement Assistant

A full-stack application with a Next.js frontend and Python FastAPI backend, designed to help users improve their handwriting through AI-powered photo analysis and personalized practice exercises.

✨ Features

πŸ–‹οΈ Handwriting Analysis

  • AI-Powered Photo Analysis: Upload photos of your handwriting for instant feedback
  • Letter Detection: Identifies specific letters that need improvement
  • Quality Assessment: Provides scores and detailed feedback on spacing, consistency, and readability
  • Personalized Suggestions: AI-generated improvement tips tailored to your writing

πŸ“š AI Practice System

  • Smart Practice Sentences: OpenAI-generated sentences with frequent target letter occurrences
  • Difficulty Levels: Beginner, Intermediate, and Advanced practice content
  • Personalized Practice Plans: Focus on letters that need the most improvement
  • Practice Tips: AI-generated guidance for better handwriting

πŸ” User Management

  • Secure Authentication: JWT-based login system with Supabase
  • Progress Tracking: Monitor your handwriting improvement over time
  • Sample History: Keep track of all your uploaded handwriting samples

🎨 Modern UI/UX

  • Responsive Design: Works perfectly on desktop, tablet, and mobile
  • Beautiful Interface: Clean, modern design with smooth animations
  • Intuitive Navigation: Easy-to-use dashboard and practice interface

πŸ—οΈ Project Structure

letterbuddy/
β”œβ”€β”€ frontend/                 # Next.js 15 Frontend Application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/             # App Router pages
β”‚   β”‚   β”‚   β”œβ”€β”€ (auth)/      # Authentication pages
β”‚   β”‚   β”‚   β”œβ”€β”€ (dashboard)/ # Protected dashboard pages
β”‚   β”‚   β”‚   └── upload/      # Handwriting upload
β”‚   β”‚   β”œβ”€β”€ components/      # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ context/         # React context providers
β”‚   β”‚   β”œβ”€β”€ hooks/           # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ lib/             # Utility functions and API
β”‚   β”‚   └── styles/          # Global styles and Tailwind CSS
β”‚   β”œβ”€β”€ public/              # Static assets and favicon
β”‚   β”œβ”€β”€ package.json         # Node.js dependencies
β”‚   └── Dockerfile           # Frontend container
β”œβ”€β”€ backend/                  # Python FastAPI Backend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ routes/          # API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.py      # Authentication routes
β”‚   β”‚   β”‚   β”œβ”€β”€ handwriting.py # Handwriting analysis & practice
β”‚   β”‚   β”‚   β”œβ”€β”€ letters.py   # Letter management
β”‚   β”‚   β”‚   └── users.py     # User management
β”‚   β”‚   └── __init__.py
β”‚   β”œβ”€β”€ requirements.txt     # Python dependencies
β”‚   β”œβ”€β”€ main.py             # FastAPI application
β”‚   └── Dockerfile          # Backend container
β”œβ”€β”€ docker-compose.yml       # Multi-service orchestration
└── README.md               # This file

πŸš€ Quick Start with Docker

Prerequisites

  • Docker Desktop
  • Docker Compose

1. Clone and Navigate

git clone <repository-url>
cd letterbuddy

2. Set Environment Variables

Create a .env file in the root directory:

# OpenAI API Configuration
OPENAI_API_KEY=your_openai_api_key_here

# Database Configuration
DATABASE_URL=postgresql://letterbuddy:letterbuddy123@localhost:5432/letterbuddy

# Secret Key for JWT tokens
SECRET_KEY=your-secret-key-here-change-in-production

# Environment
ENVIRONMENT=development

3. Start All Services

# Load environment variables and start services
source .env && docker-compose up --build -d

This will start:

4. Access the Application

πŸ› οΈ Development Setup

Frontend Development

cd frontend
npm install
npm run dev

Backend Development

cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reload

πŸ”§ Configuration

Environment Variables

Root (.env)

# OpenAI API Configuration
OPENAI_API_KEY=your_openai_api_key_here

# Database Configuration
DATABASE_URL=postgresql://letterbuddy:letterbuddy123@localhost:5432/letterbuddy

# Secret Key for JWT tokens
SECRET_KEY=your-secret-key-here-change-in-production

# Environment
ENVIRONMENT=development

Frontend (Docker Environment)

NEXT_PUBLIC_API_URL=http://localhost:8000

πŸ“š API Documentation

Once the backend is running, visit:

Available Endpoints

Authentication

  • POST /auth/register - User registration
  • POST /auth/login - User authentication

Handwriting Analysis

  • POST /handwriting/analyze - Analyze handwriting from photo
  • POST /handwriting/practice-sentences - Generate AI practice sentences
  • GET /handwriting/demo - Get demo analysis response

User Management

  • GET /users/me - Get current user info
  • PUT /users/me - Update user profile

Letters

  • GET /letters - Get user letters
  • POST /letters - Create new letter

πŸ—„οΈ Database

The application uses PostgreSQL with the following main tables:

  • users - User accounts and authentication
  • user_uploads - Handwriting samples and analysis results
  • user_letters_to_improve - Letters that need practice
  • letters - User-created letters

Database migrations are handled automatically on startup.

🐳 Docker Commands

Development

# Start all services in background
docker-compose up -d

# Start with rebuild
docker-compose up --build -d

# View logs
docker-compose logs -f [service-name]

# Stop all services
docker-compose down

# Restart specific service
docker-compose restart [service-name]

Service Management

# Check status
docker-compose ps

# View logs for specific service
docker logs letterbuddy-backend-1 -f
docker logs letterbuddy-frontend-1 -f
docker logs letterbuddy-postgres-1 -f

πŸ§ͺ Testing

Backend Tests

cd backend
pytest

Frontend Tests

cd frontend
npm test

πŸ“¦ Deployment

Production Docker Compose

docker-compose -f docker-compose.prod.yml up -d

Individual Services

# Backend only
docker-compose up backend

# Frontend only
docker-compose up frontend

πŸ”’ Security Features

  • JWT-based authentication with Supabase
  • Password hashing with bcrypt
  • CORS configuration for production domains
  • Environment-based configuration
  • Input validation with Pydantic
  • Secure file upload handling

🌟 Key Technologies

Frontend

  • Next.js 15 - React framework with App Router
  • Tailwind CSS - Utility-first CSS framework
  • Supabase - Authentication and database
  • React Context - State management

Backend

  • FastAPI - Modern Python web framework
  • OpenAI GPT-4 - AI-powered content generation
  • PostgreSQL - Reliable database
  • Pillow - Image processing
  • Uvicorn - ASGI server

Infrastructure

  • Docker - Containerization
  • Docker Compose - Multi-service orchestration
  • PostgreSQL - Database service

🚧 Development Roadmap

  • AI-powered handwriting analysis βœ…
  • Personalized practice sentences βœ…
  • User authentication system βœ…
  • Progress tracking βœ…
  • Modern responsive UI βœ…
  • Letter templates
  • Export functionality
  • Mobile app
  • Advanced analytics
  • Social features

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests if applicable
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License.

πŸ†˜ Support

For support and questions:

  • Create an issue in the repository
  • Check the API documentation at http://localhost:8000/docs
  • Review the code examples in the source code

🎯 Getting Started with Handwriting Improvement

  1. Sign Up: Create your LetterBuddy account
  2. Upload Sample: Take a photo of your handwriting and upload it
  3. Get Analysis: Receive AI-powered feedback on your writing
  4. Practice: Use AI-generated sentences to improve specific letters
  5. Track Progress: Monitor your improvement over time
  6. Upload Again: Submit new samples to see your progress

Start your handwriting improvement journey today! πŸš€

About

AI powered handwriting improvement application built on Next.js, Python FastAPI, and Supabase

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors