Skip to content

JunLovin/Routinary-Backend

Repository files navigation

🗓️ Routinary Backend

AI-powered routine generator that transforms natural language into calendar files

License: MIT TypeScript Node.js

Backend API for Routinary - an intelligent routine planning assistant that converts conversational prompts into structured calendar events.


✨ Features

  • 🔐 JWT Authentication - Secure user registration and login
  • 👤 User Management - Complete CRUD operations for user profiles
  • 📋 Routine Management - Create, read, update, and delete routines
  • Zod Validation - Type-safe request validation
  • 🤖 AI Generation (coming soon) - Gemini-powered natural language to .ics conversion
  • 🗄️ PostgreSQL + Prisma - Type-safe database operations with migrations

🛠️ Tech Stack

  • Runtime: Node.js 18+
  • Language: TypeScript
  • Framework: Express.js
  • Database: PostgreSQL
  • ORM: Prisma
  • Validation: Zod
  • Authentication: JWT (jsonwebtoken)
  • Password Hashing: bcryptjs
  • AI: Google Gemini API (in progress)

🚀 Getting Started

Prerequisites

  • Node.js 18 or higher
  • PostgreSQL database
  • npm or yarn

Installation

  1. Clone the repository
git clone https://github.com/JunLovin/Routinary-Backend.git
cd Routinary-Backend
  1. Install dependencies
npm install
  1. Set up environment variables

Create a .env file in the root directory:

DATABASE_URL="postgresql://user:password@localhost:5432/routinary"
JWT_SECRET="your-super-secret-key-change-this"
PORT=3000
  1. Run database migrations
npx prisma migrate dev
  1. Start the development server
npm run dev

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


📚 API Documentation

Authentication

Method Endpoint Description
POST /api/auth/register Register a new user
POST /api/auth/login Login and get JWT token

Users

Method Endpoint Description Auth Required
GET /api/users Get all users
GET /api/users/me Get current user
GET /api/users/:id Get user by ID
PATCH /api/users/:id Update user
DELETE /api/users/:id Delete user

Routines

Method Endpoint Description Auth Required
GET /api/routines/me Get current user's routines
GET /api/routines/:id Get routine by ID
POST /api/routines/generate Generate routine from prompt
PUT /api/routines/:id Update routine
DELETE /api/routines/:id Delete routine

Example Request

Register a new user:

curl -X POST http://localhost:3000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "securepassword123",
    "name": "John Doe"
  }'

Generate a routine:

curl -X POST http://localhost:3000/api/routines/generate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "prompt": "Wake up at 6am, go to gym at 7am, breakfast at 8:30am",
    "title": "Morning Routine"
  }'

🗂️ Project Structure

prisma/                # Database schema and migrations
|
src/
├── controllers/       # Request handlers
├── services/          # Business logic
├── routers/            # API routers definitions
├── middlewares/       # Custom middleware (auth, validation, error handling)
├── schemas/           # Zod validation schemas
├── types/             # TypeScript type definitions
├── utils/             # Utility functions
└── handlers/          # Async error handler

🔧 Scripts

npm run dev          # Start development server with hot reload
npm run build        # Build for production
npm start            # Start production server
npx prisma studio    # Open Prisma Studio (DB GUI)
npx prisma migrate dev  # Run database migrations

🌍 Environment Variables

Variable Description Required
DATABASE_URL PostgreSQL connection string
JWT_SECRET Secret key for JWT signing
PORT Server port (default: 3000)
GEMINI_API_KEY Google Gemini API key ⏳ (coming soon)

🤝 Contributing

Contributions are welcome! Please read the CONTRIBUTORS.md file for guidelines on how to contribute to this project.


📝 License

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


🔗 Links


💡 Roadmap

  • User authentication and authorization
  • Routine CRUD operations
  • Zod validation
  • Gemini AI integration for .ics generation
  • Rate limiting
  • Unit and integration tests
  • API documentation with Swagger
  • Deploy to production

Made with ❤️ by JunLovin

About

The backend of Routinary

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors