A backend platform built for AI-driven clinic workflows, with a strong focus on RAG based chatbot agent interaction, image generation/editing, and a robust production-ready API.
SeeMyBodyAI Backend powers the AI and ML experience for medical aesthetics clinics by combining:
- a chatbot/RAG agent for clinic assistant interaction and guided conversational workflows
- image generation using Google Gemini to simulate patient transformation results
- image editing workflows for refined simulated outputs
- secure admin and user authentication with JWT tokens
- lead capture and analytics through simulation details and consultation records
- payment orchestration using Stripe checkout
- Chatbot assistant: provides an authenticated
/user/agentendpoint for natural language, clinic-specific responses. - Generative image pipeline: supports uploading real patient photos, generating a simulation, and editing the output.
- Prompt-driven experience: integrates prompt logic that is ready for extension and experimentation.
- FastAPI-based API with clean routing and dependency injection
- SQLAlchemy ORM for relational database management
- Role-based access with admin and normal user separation
- AWS S3 storage for image upload management
- Stripe payment endpoints for checkout and purchase flows
- Python 3.11+
- A database connection via
DATABASE_URL(SQLite, PostgreSQL, etc.) - Google API key for Gemini image generation
- Stripe secret key and optional
PRICE_ID - AWS credentials and S3 bucket configuration for file uploads
python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txtCreate a .env file in the repository root with the required settings:
DATABASE_URL=sqlite:///./app.db
SECRET_KEY=your-secret-key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
OPEN_AI=your-openai-key
GOOGLE_API_KEY=your-google-api-key
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=your-aws-key
AWS_SECRET_ACCESS_KEY=your-aws-secret
S3_BUCKET_NAME=your-s3-bucket
SECRET_KEY_STRIPE=your-stripe-secret-key
PRICE_ID=your-stripe-price-id
WOMPI_PUBLIC_KEY=your-wompi-public-key
WOMPI_PRIVATE_KEY=your-wompi-private-keyNote: There is no
.env.examplefile included, so create.envmanually.
uvicorn app.main:app --reloadOpen the local API docs:
- Swagger UI:
http://127.0.0.1:8000/docs - ReDoc:
http://127.0.0.1:8000/redoc
A docker-compose.yml file is present for containerized startup. Configure environment values before running.
POST /user/agent— authenticated agent endpoint for clinic chatbot interactions
POST /ai-simulation/simulate/image— generate a simulation image from an uploaded photoPOST /ai-simulation/edit_simulated_image— edit an existing generated image using prompt inputPOST /ai-simulation/in_out_img_store— store generated simulation results for a user
POST /auth/login— admin loginPOST /auth/token— admin OAuth2 token endpointGET /admin/admin_dashboard— admin overview metricsGET /admin/search_leads— search leads and simulation records
POST /stripe/create-checkout-session— create a Stripe checkout sessionGET /stripe/success— payment success callbackGET /stripe/cancel— payment cancel callback
app/— main application packageapp/api/— FastAPI routers for auth, admin, agent, simulation, payments, and healthapp/core/— configuration, logging, and application bootstrapapp/db/— SQLAlchemy engine, session, and database dependenciesapp/models/— ORM model definitionsapp/schemas/— request and response schemasapp/services/— security, authentication, and application business logicapp/agents/— RAG and agent orchestration codeapp/storage/— S3 upload utilitiesapp/ml/notebooks/— AI experimentation and demo notebooksdocs/ARCHITECTURE.md— architecture notes and refactor roadmaptests/— test suites and integration tests
- Use
docs/ARCHITECTURE.mdfor architecture and migration guidance. - Inspect
app/api/for route behavior andapp/services/for core logic. - Run the app locally and use FastAPI documentation at
/docs.
- Fixes, enhancements, and AI pipeline improvements are welcome.
- Open issues for new features or backend changes.
- Reference
docs/ARCHITECTURE.mdbefore reorganizing major components. - Keep new API endpoints in
app/api/and business logic inapp/services/.
- Primary maintainer: Md Raisul Islam Rimon
app/main.pyis the preferred structured entrypoint.new_main.pyand legacy root modules are preserved for compatibility.- Production deployments should transition from
Base.metadata.create_all()to Alembic migrations.