@@ -41,13 +41,13 @@ We love our contributors! Here’s how you can contribute:
4141
4242### Setting up locally
4343
44- Opensox AI’ s stack consists of the following elements:
44+ Opensox AI' s stack consists of the following elements:
4545
46- - A backend written in Express.js, exposing a REST API
46+ - A backend API built with tRPC and Express.js
4747- A frontend written in Next.js and TypeScript
4848- A PostgreSQL database
4949- A Redis database (in process)
50- - What’ s for AI? Coming very soon…
50+ - What' s for AI? Coming very soon…
5151
5252#### Prerequisites
5353
@@ -57,9 +57,9 @@ Opensox needs [TypeScript](https://www.typescriptlang.org/download/) and [Node.j
5757
5858Create environment files for both the backend and the frontend before running the apps.
5959
60- ### Backend (` apps/backend /.env ` )
60+ ### Backend (` apps/api /.env ` )
6161
62- Create a file at ` apps/backend /.env ` with:
62+ Create a file at ` apps/api /.env ` with:
6363
6464``` bash
6565# Required
@@ -114,7 +114,7 @@ After creating these files, restart your dev servers so changes take effect.
114114Run these steps once your ` DATABASE_URL ` is set:
115115
116116``` bash
117- cd apps/backend
117+ cd apps/api
118118
119119# Generate Prisma client (optional if already generated)
120120npx prisma generate
@@ -165,7 +165,7 @@ pnpm run dev
165165
166166Congrats! Your frontend is running on ` localhost:3000 ` .
167167
168- 3 . ` cd ` into ` opensox/apps/backend ` and install dependencies
168+ 3 . ` cd ` into ` opensox/apps/api ` and install dependencies
169169
170170``` bash
171171npm install
@@ -174,13 +174,93 @@ npm install
174174Now run the server:
175175
176176``` bash
177- npm run server
177+ pnpm run dev
178178```
179179
180- Voila! Your server is running on ` localhost:8080 ` .
180+ Voila! Your API server is running on ` localhost:4000 ` .
181181
182182Now you can access your app at ` http://localhost:3000 ` .
183183
184+ ## Running the API with Docker
185+
186+ Alternatively, you can run the API server using Docker. A ` Dockerfile ` is provided in the root directory.
187+
188+ ### Prerequisites
189+
190+ - [ Docker] ( https://docs.docker.com/get-docker/ ) installed on your machine
191+
192+ ### Building and Running
193+
194+ 1 . Make sure you have your ` .env ` file set up in ` apps/api/.env ` (see [ Backend environment variables] ( #backend-appsapienv ) section above)
195+
196+ 2 . From the root directory, build the Docker image:
197+
198+ ``` bash
199+ docker build -t opensox-api .
200+ ```
201+
202+ 3 . Run the container with your environment variables:
203+
204+ ``` bash
205+ docker run -p 4000:4000 \
206+ --env-file apps/api/.env \
207+ opensox-api
208+ ```
209+
210+ Or if you prefer to pass environment variables individually:
211+
212+ ``` bash
213+ docker run -p 4000:4000 \
214+ -e DATABASE_URL=" postgresql://USER:PASSWORD@host.docker.internal:5432/opensox?schema=public" \
215+ -e JWT_SECRET=" your-secret" \
216+ -e PORT=4000 \
217+ opensox-api
218+ ```
219+
220+ ** Note:** When using Docker, if your database is running on your host machine (not in a container), use ` host.docker.internal ` instead of ` localhost ` in your ` DATABASE_URL ` .
221+
222+ Your API server will be available at ` http://localhost:4000 ` .
223+
224+ ### Using Docker Compose (Optional)
225+
226+ For a complete setup with PostgreSQL, you can create a ` docker-compose.yml ` file:
227+
228+ ``` yaml
229+ version : ' 3.8'
230+ services :
231+ postgres :
232+ image : postgres:15
233+ environment :
234+ POSTGRES_USER : opensox
235+ POSTGRES_PASSWORD : opensox
236+ POSTGRES_DB : opensox
237+ ports :
238+ - " 5432:5432"
239+ volumes :
240+ - postgres_data:/var/lib/postgresql/data
241+
242+ api :
243+ build : .
244+ ports :
245+ - " 4000:4000"
246+ environment :
247+ DATABASE_URL : postgresql://opensox:opensox@postgres:5432/opensox?schema=public
248+ JWT_SECRET : your-secret-key
249+ PORT : 4000
250+ NODE_ENV : production
251+ depends_on :
252+ - postgres
253+
254+ volumes :
255+ postgres_data :
256+ ` ` `
257+
258+ Then run:
259+
260+ ` ` ` bash
261+ docker-compose up -d
262+ ```
263+
184264## Our contributors
185265
186266<a href =" https://github.com/apsinghdev/opensox/graphs/contributors " >
0 commit comments