Skip to content

W1seGit/Syllabye-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Syllabye Backend

FastAPI backend that powers the Syllabye app. It exposes:

  • JWT-based auth (/auth/register, /auth/login)
  • A LangChain-powered, streaming calendar/chat agent
    • HTTP streaming endpoint: POST /chat
    • WebSocket streaming endpoint: GET /chat/ws
  • CRUD endpoints for events (/events)
  • Class/syllabus management endpoints used by the mobile app

The agent uses OpenAI via langchain-openai and a MongoDB database.

Requirements

  • Python 3.11 (recommended)
  • An OpenAI API key

Setup

  1. Clone / open this folder

    cd syllabye-backend
  2. Create and activate a virtual environment

    python -m venv venv
    # Windows PowerShell
    .\venv\Scripts\Activate.ps1
  3. Install dependencies

    pip install -r requirements.txt
  4. Configure environment variables

    Create a .env file (not committed to git) in this folder:

    OPENAI_API_KEY=your-openai-key-here
    MONGODB_URI=mongodb://user:password@host:port
    MONGODB_DB_NAME=syllabye
    SECRET_KEY=your-strong-random-secret-key

    The app uses python-dotenv to load .env on startup.

Running the API

Run the FastAPI app with Uvicorn:

uvicorn app.main:app --reload

The API will be available at http://127.0.0.1:8000.

  • Interactive docs: http://127.0.0.1:8000/docs
  • Health check: GET /health

Auth, Chat & Events

  • POST /auth/register – create a new user
  • POST /auth/login – obtain a JWT access token
  • All /events and /chat requests require Authorization: Bearer <token>

Event endpoints:

  • POST /events – create event
  • GET /events – list events (optionally by date)
  • GET /events/{id} – get single event
  • PATCH /events/{id} – update event -- DELETE /events/{id} – delete event

Chat endpoints:

  • POST /chat – streaming response over HTTP (used as a fallback by clients)
  • GET /chat/ws – WebSocket chat with token streaming and live tool-call events

Technologies

  • FastAPI – web framework and dependency injection
  • Uvicorn – ASGI server for running the API
  • MongoDB – persistence for users, classes, events, tool logs, etc.
  • LangChain / langchain-openai – LLM orchestration and tools for the calendar agent
  • python-dotenv – loads environment variables from .env
  • python-jose – JWT creation and verification for auth

Chat UI (local helper)

This repo includes a simple browser-based helper page chat.html for local development. It is ignored by git and not meant for production deployment.

Usage:

  1. Start the backend (uvicorn app.main:app --reload).
  2. Open chat.html in a browser (double-click or start .\chat.html).
  3. Enter http://127.0.0.1:8000 as the API base URL.
  4. Log in with a valid username/password.
  5. Chat with the calendar agent.

The agent:

  • Uses OpenAI via ChatOpenAI.
  • Has short-term per-user memory (recent conversation turns).
  • Manages events only for the authenticated user.

Notes

  • .env and other secrets are ignored by git via .gitignore.
  • chat.html is a local artifact and is also ignored.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors