Medusa is a set of commerce tools and modules that can be used to build unique commerce experiences.
Medusa provides the essential building blocks that developers can put together to create a powerful commerce store. Developers have full control over their tech stack and the logic behind the commerce features.
This project is structured as follows:
src/
: Contains the source code of the project.admin/
: Admin UI, including widgets, views, componentsapi/
: API split intoadmin
andstore
jobs/
: Scheduling jobsloaders/
: A loader is a script that runs when the Medusa backend starts.migrations/
: Database migrationsmodels/
: New entity database models or extending database modelsrepositories/
: Repositories provide generic helper methods for your models/entities.services/
: Represent bundled helper methods that you want to use across your commerce applicationsubscribers/
: Register handlers for an events and allows you to perform an action when that event occurstypes/
: Typescript types for database entities.
data/
: Contains seed data for the database..github/
: Contains GitHub configuration files like workflows and dependabot configuration.
Node.JS 18.x.x or higher npm, yarn, or pnpm PostgreSQL Redis Algolia Stripe Segment
.env
setup
- JWT_SECRET
- Secret for JWT encoding/decoding
- default:
supersecret
- default:
- Secret for JWT encoding/decoding
- COOKIE_SECRET
- Secret for Cookie validation
- default:
supersecret
- default:
- Secret for Cookie validation
- DATABASE_TYPE
- Type of database (only supports
postgres
for now)- default:
postgres
- default:
- Type of database (only supports
- DATABASE_URL
- PostgreSQL Database URL
- defaults:
postgresql://postgres:postgres@localhost/medusa
- defaults:
- PostgreSQL Database URL
- MEDUSA_ADMIN_ONBOARDING_TYPE
- Stack your admin frontend application runs on. Ours is
nextjs
- default:
nextjs
- default:
- Stack your admin frontend application runs on. Ours is
- STORE_CORS
- CORS regex patterns for Storefront API
- default:
http://localhost:8000,http://localhost:7001,http://localhost:3000,http:\/\/localhost:3000
- default:
- CORS regex patterns for Storefront API
- ADMIN_CORS
- CORS regex patters for Admin API
- default:
http:\/\/localhost:3000,http://localhost:3000,http:\/\/localhost:7001,http://localhost:7001
- default:
- CORS regex patters for Admin API
- MEDUSA_ADMIN_ONBOARDING_NEXTJS_DIRECTORY
- Directory of admin onboarding
- default:
threshold-store-storefront
- default:
- Directory of admin onboarding
- DB_USERNAME
- Database username
- default:
postgres
- default:
- Database username
- DB_PASSWORD
- Database password
- default:
postgres
- default:
- Database password
- DB_HOST
- Datbase host
- default:
localhost
- default:
- Datbase host
- DB_PORT
- Database port
- default:
5432
- default:
- Database port
- DB_DATABASE
- Database name
- default:
medusa
- default:
- Database name
- REDIS_URL
- Redis URL
- default:
redis://localhost:6379
- default:
- Redis URL
- STRIPE_API_KEY
- Stripe API key
- Contact the project manager to get one
- Stripe API key
- ALGOLIA_APP_ID
- Algolia Application ID
- Contact the project manager to get one
- Algolia Application ID
- ALGOLIA_ADMIN_API_KEY
- Algolia Application Admin API Key
- Contact the project manager to get one
- Algolia Application Admin API Key
- SEGMENT_WRITE_KEY
- Segment write key for analytics
- Contact the project manager to get one
- Segment write key for analytics
Make sure you have a local PostgreSQL and Redis instance and configure your .env
accordingly.
If it's your first time running the projects, make sure you meet all the requirements.
- Install dependencies
npm install
- Run database migrations
npm run migrate
- Run the project
npm run dev
Admin UI normally runs on http://localhost:7001
.
The admin UI allows you to manage your storefront, including products, images, orders, customers, shipping, etc.
The API nomally runs on http://localhost:9000
.
The API allows you to connect your storefront data using REST JSON.
Always submit pull requests to the development
branch. Make sure to prefix your branches accordingly.
- Features
If you're working on a features you should prefix your branch as features/some-feature
.
- Fixes
If you're working on fixes for something, you should prefix your branch fix/some-fix
- Hot-Fixes
If you're working on a hot fix, you should prefix your branch hotfix/some-hotfix
and let your product manager or lead engineer about the fix so it can be pushed to development/production right away.