AI-powered routine generator that transforms natural language into calendar files
Backend API for Routinary - an intelligent routine planning assistant that converts conversational prompts into structured calendar events.
- 🔐 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
- 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)
- Node.js 18 or higher
- PostgreSQL database
- npm or yarn
- Clone the repository
git clone https://github.com/JunLovin/Routinary-Backend.git
cd Routinary-Backend- Install dependencies
npm install- 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- Run database migrations
npx prisma migrate dev- Start the development server
npm run devThe API will be available at http://localhost:3000
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register a new user |
| POST | /api/auth/login |
Login and get JWT token |
| 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 | ✅ |
| 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 | ✅ |
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"
}'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
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| 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) |
Contributions are welcome! Please read the CONTRIBUTORS.md file for guidelines on how to contribute to this project.
This project is licensed under the MIT License - see the LICENSE file for details.
- Frontend Repository: Routinary
- Author: @JunLovin
- Issues: Report a bug or request a feature
- 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