Skip to content

Repository files navigation

CityPharma Backend Setup Guide

A complete guide to set up and run the CityPharma Pharmacy Management System backend on a fresh Windows PC.

Prerequisites

Before starting, download and install:


Step 1: Clone & Setup

  1. Clone this repository to your PC.
  2. The default settings in the code work with XAMPP's default configuration.

Step 1: Install & Setup XAMPP

  1. Download XAMPP from https://www.apachefriends.org/ and run the installer.
  2. During installation, select MySQL as the module to install.
  3. After installation, open XAMPP Control Panel.
  4. Click Start next to MySQL (wait for it to turn green).
  5. Click Start next to Apache (wait for it to turn green).

MySQL is now running on port 3306


Step 2: Setup MySQL Database

  1. Open your browser and go to: http://localhost/phpmyadmin
  2. Click New to create a new database.
  3. Database name: citypharma_db
  4. Collation: utf8mb4_general_ci
  5. Click Create.

Database created!


Step 3: Import Database Schema

  1. In phpMyAdmin, click on citypharma_db in the left sidebar.
  2. Click the Import tab at the top.
  3. Click Choose File and select schema.sql from this project folder.
  4. Scroll down and click Import.

This will create all tables and add 2 default users for testing:

  • Username: admin, Password: password123 (Pharmacy Manager)
  • Username: staff, Password: password123 (Pharmacy Staff)

Step 4: Setup Python

  1. Download Python from https://www.python.org/downloads/ (version 3.10 or higher).
  2. Important: During installation, check "Add Python to PATH".
  3. Open Command Prompt (cmd) and verify Python is installed:
    python --version
    

Step 5: Install Backend Dependencies

  1. Open Command Prompt and navigate to this project folder:
    cd <path-to-project-folder>
    
  2. Install all required packages:
    pip install -r requirements.txt
    

Step 6: Configure Environment Variables

  1. Open the .env file in this project folder.
  2. The default settings work with XAMPP's default configuration:
    DB_HOST=localhost
    DB_PORT=3306
    DB_NAME=citypharma_db
    DB_USER=root
    DB_PASSWORD=
    SECRET_KEY=your-secret-key-change-in-production
    
  3. Save and close.

Note: Default XAMPP MySQL username is root with no password (leave DB_PASSWORD empty).


Step 7: Run the Backend Server

In Command Prompt, from this project folder:

python -m uvicorn app.main:app --reload --port 8000

The server will start at: http://localhost:8000


Step 8: Test the API

  1. Open your browser and go to: http://localhost:8000/docs

  2. This is the Swagger UI - interactive API documentation.

  3. Click Authorize and login with default credentials:

    Role Username Password
    Manager admin password123
    Staff staff password123

Quick Reference

Command Description
Start XAMPP MySQL Open XAMPP Control Panel → Start MySQL
Navigate to project cd <path-to-project-folder>
Run server python -m uvicorn app.main:app --reload
Stop server Press Ctrl + C in terminal

Troubleshooting

"Module not found" error

Run: pip install -r requirements.txt

"Can't connect to MySQL" error

  • Make sure XAMPP MySQL is running (green in XAMPP Control Panel)
  • Check .env file has correct DB_PASSWORD (leave empty for default XAMPP)

"Database doesn't exist" error

Create citypharma_db in phpMyAdmin (Step 2)

Port 8000 already in use

Change port: python -m uvicorn app.main:app --reload --port 8001


API Documentation

Once the server is running, visit:

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages