Skip to content

Ansbach-0/AIProjects

Repository files navigation

🎯 Habit Tracker

Master Your Habits, Transform Your Life

FastAPI Next.js React Python TypeScript Tailwind CSS

A powerful, modern full-stack habit tracking application that helps you build consistency and track your daily progress with an elegant, responsive interface.

Features β€’ Tech Stack β€’ Installation β€’ API Reference β€’ Contributing


✨ Features

πŸ” Authentication

  • JWT-based secure authentication
  • User registration & login
  • Protected routes & API endpoints
  • Token-based authorization

πŸ“Š Dashboard

  • Real-time habit statistics
  • Completion percentage tracking
  • Visual progress indicators
  • Responsive card layouts

🎨 Modern UI

  • Dark/Light theme toggle
  • Smooth animations & transitions
  • Mobile-responsive design
  • Glassmorphism effects

⚑ Habit Management

  • Create, edit, delete habits
  • Mark daily completions
  • Habit descriptions & metadata
  • Persistent data storage

πŸ› οΈ Tech Stack

Backend

Frontend

Database

  • SQLite - Lightweight, serverless database

Testing

  • Playwright MCP - End-to-end testing framework

πŸ“ Project Structure

AIProjects/
β”œβ”€β”€ πŸ“‚ backend/
β”‚   β”œβ”€β”€ πŸ“‚ src/
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.py          # Authentication endpoints
β”‚   β”‚   β”‚   └── habits.py        # Habit CRUD endpoints
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ models/
β”‚   β”‚   β”‚   β”œβ”€β”€ usuario.py       # User model
β”‚   β”‚   β”‚   β”œβ”€β”€ habito.py        # Habit model
β”‚   β”‚   β”‚   └── tarefa.py        # Task model
β”‚   β”‚   β”œβ”€β”€ database.py          # Database configuration
β”‚   β”‚   └── main.py             # FastAPI application
β”‚   β”œβ”€β”€ πŸ“‚ alembic/              # Database migrations
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── alembic.ini
β”‚
β”œβ”€β”€ πŸ“‚ frontend/
β”‚   └── πŸ“‚ my-app/
β”‚       β”œβ”€β”€ πŸ“‚ app/
β”‚       β”‚   β”œβ”€β”€ πŸ“‚ dashboard/    # Dashboard page
β”‚       β”‚   β”œβ”€β”€ πŸ“‚ login/        # Login page
β”‚       β”‚   β”œβ”€β”€ layout.tsx
β”‚       β”‚   └── page.tsx
β”‚       β”œβ”€β”€ πŸ“‚ components/
β”‚       β”‚   β”œβ”€β”€ πŸ“‚ dashboard/    # Dashboard components
β”‚       β”‚   └── πŸ“‚ ui/           # shadcn/ui components
β”‚       β”œβ”€β”€ πŸ“‚ lib/
β”‚       β”‚   β”œβ”€β”€ api.ts           # API client with JWT auth
β”‚       β”‚   └── utils.ts
β”‚       β”œβ”€β”€ πŸ“‚ tests/            # Test files
β”‚       β”œβ”€β”€ package.json
β”‚       └── next.config.ts
β”‚
└── README.md

πŸš€ Installation

Prerequisites

  • Python 3.14+
  • Node.js 18+
  • npm or yarn

1️⃣ Clone the Repository

git clone https://github.com/Ansbach-0/AIProjects.git
cd AIProjects

2️⃣ Backend Setup

# Navigate to backend directory
cd backend

# Install Python dependencies
pip install -r requirements.txt

# Run database migrations
alembic upgrade head

# Start the FastAPI server
uvicorn src.main:app --reload --host 0.0.0.0 --port 8000

The backend API will be available at http://localhost:8000

FastAPI Docs: Visit http://localhost:8000/docs for interactive API documentation

3️⃣ Frontend Setup

# Navigate to frontend directory
cd frontend/my-app

# Install dependencies
npm install

# Start the development server
npm run dev

The frontend will be available at http://localhost:3000

4️⃣ Environment Variables

Create a .env file in the frontend directory:

NEXT_PUBLIC_API_URL=http://localhost:8000

πŸ“š API Reference

Authentication

Method Endpoint Description
POST /auth/register Register a new user
POST /auth/login Login and receive JWT token
GET /auth/me Get current user info (requires auth)

Request Body (Login):

{
  "email": "user@example.com",
  "password": "securepassword"
}

Response:

{
  "access_token": "eyJhbGciOiJIUzI1NiIs...",
  "token_type": "bearer"
}

Habits

Method Endpoint Description Auth Required
GET /habits/ List all user habits βœ…
POST /habits/ Create a new habit βœ…
GET /habits/{id} Get habit by ID βœ…
PUT /habits/{id} Update habit βœ…
DELETE /habits/{id} Delete habit βœ…

Request Body (Create Habit):

{
  "name": "Morning Exercise",
  "description": "30 minutes of cardio every morning"
}

Response:

{
  "id": 1,
  "name": "Morning Exercise",
  "description": "30 minutes of cardio every morning",
  "usuario_id": 1
}

🎯 Usage

  1. Register/Login - Create an account or login with existing credentials
  2. Dashboard - View your habits dashboard with completion stats
  3. Create Habits - Click "New Habit" to add habits you want to track
  4. Mark Complete - Click "Mark Complete" when you finish a habit for the day
  5. Track Progress - View stats: Total habits, Completed today, Remaining
  6. Delete Habits - Remove habits you no longer want to track

πŸ§ͺ Testing

End-to-End Tests

The project uses Playwright MCP for comprehensive E2E testing:

# Run tests
npm test

# Run tests in watch mode
npm test -- --watch

Test Coverage

  • βœ… Authentication flow (login/register)
  • βœ… Habit creation
  • βœ… Habit completion marking
  • βœ… Habit deletion
  • βœ… Dashboard stats updates

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Ansbach-0 & AndreRachid-rgb

πŸ™ Acknowledgments

  • FastAPI for the amazing Python web framework
  • Next.js for the powerful React framework
  • shadcn/ui for the beautiful component library
  • Tailwind CSS for the utility-first CSS framework

⭐ Star this repository if you find it helpful!

Made with ❀️ by Ansbach-0 & AndreRachid-rgb

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors