Skip to content

Commit

Permalink
Merge pull request #119 from ryanchua00/staging
Browse files Browse the repository at this point in the history
Fix question number bug
  • Loading branch information
ryanchua00 authored Nov 15, 2023
2 parents 930bd71 + c7291fb commit 9102efe
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@

2. Start docker

3. Run `docker-compose up --build` to build and run images and containers
3. For `frontend`, `ai-service`, `email-service`, `mongodb-database`, `user-service`, there is an `.env` file that is required.
Follow the respective `README.md` located in those folders.

4. Note: this does not start the api-gateway. Follow the relevant `./gateway/README.md`
4. Run `docker-compose up --build` to build and run images and containers

## Developer guide

As of the last update of this README, only the user-service and question-service have been dockerized. A respective `Dockerfile` has been created within each of their folders. This `Dockerfile` specifies the instructions in order to build the container, install the necessary node modules etc.
As of the last update of this README, all backend services, frontend and gateway have been dockerized. A respective `Dockerfile` has been created within each of folders. This `Dockerfile` specifies the instructions in order to build the container, install the necessary node modules etc.

To simplify the container building, a `docker-compose.yml` has been created in order to start both containers at once. This is achieved through running `docker compose build` and `docker compose up` to call both dockerfiles.
To simplify the container building, a `docker-compose.yml` has been created in order to start both containers at once. This is achieved through running `docker-compose up --build` to call all the dockerfiles.

The api-gateway requires more work, see https://dev.to/naseef012/create-a-microservices-app-with-dockerized-express-api-gateway-1kf9 for more information.
Note that user-service requires a Supabase database and question-service requires a MongoDB database. The respective `README.md` should aid you in creating your own databases.

Also, the ai-service requires your own OpenAI key and email-service requires an SMTP_PASSWORD to run locally. For ease of testing, do so on peerprep.ryanchuahj.com

## Finishing Development

Expand Down
10 changes: 10 additions & 0 deletions backend/ai-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Getting Started with Ai-service

1. Run `npm install` to install all the dependencies

2. Duplicate `.env.example` and rename the new file to `.env`. Add your own OpenAI API key.

3. To run development server, do `npm run dev`

4. Do `npm run build` to compile for production before running `npm start`

4 changes: 3 additions & 1 deletion backend/email-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

2. Duplicate `.env.example` and rename the new file `.env`

3. Retrieve secrets from group chat. Search `EMAILSECRETS`.
3. IMPORTANT: the SMTP_PASSWORD uses a secret key only available to developers.
For testing, please contact the developers.
Optionally, you can also test the email functionality on peerprep.ryanchuahj.com.

4. Run `npm start` to start the service.

Expand Down
10 changes: 5 additions & 5 deletions frontend/components/ProfilePage/HistoryTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface HistoryTableProps {

const HistoryTable = ({ username }: HistoryTableProps) => {
const [open, setOpen] = useState(false);
const [questionNumber, setQuestionNumber] = useState(1);
const [questionNumber, setQuestionNumber] = useState(0);
const [tableData, setTableData] = useState<HistoryData[]>([]);
const [questionPanelProps, setQuestionProps] = useState({
question_number: questionNumber,
Expand All @@ -66,9 +66,9 @@ const HistoryTable = ({ username }: HistoryTableProps) => {
};

const handleChange = (event: ChangeEvent<unknown>, value: number) => {
setQuestionNumber(value);
setQuestionNumber(value - 1);
setQuestionProps({
question_number: value,
question_number: value - 1,
question: historyStore.getQuestionById(
displayedResponses[value - 1].questionId
)!,
Expand Down Expand Up @@ -96,7 +96,7 @@ const HistoryTable = ({ username }: HistoryTableProps) => {
setDisplayedResponses(responses!);
if (responses == undefined) return;
setQuestionProps({
question_number: 1,
question_number: 0,
question: historyStore.getQuestionById(responses[0].questionId),
});
setModalLanguage(session.language.toLowerCase());
Expand Down Expand Up @@ -288,7 +288,7 @@ const HistoryTable = ({ username }: HistoryTableProps) => {
<Box>
<Pagination
count={displayedResponses.length}
page={questionNumber}
page={questionNumber + 1}
color="primary"
onChange={handleChange}
sx={{
Expand Down
3 changes: 3 additions & 0 deletions gateway/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
USER_SERVICE_URL="http://localhost:3001"
QUESTION_SERVICE_URL="http://localhost:3002"
RABBITMQ_URL="amqp://user:password@localhost:5672"
2 changes: 1 addition & 1 deletion gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

1. Use command `npm install -g express-gateway` to install express gateway on your system.

2. For deployment, edit the `serviceEndpoints` in `./config/gateway.config.yml` to accept env vars.
2. Duplicate `.env.example` and rename the new file to `.env`.

3. Enter the gateway directory and run `npm start` to start the api gateway server.

0 comments on commit 9102efe

Please sign in to comment.