Skip to content
Closed

Nouman #1330

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
# Python
__pycache__
app.egg-info
*.pyc
.mypy_cache
.coverage
htmlcov
.venv
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.DS_Store
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose.y*ml
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
5 changes: 5 additions & 0 deletions backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### 1.0.1 (2024-06-21)
6 changes: 3 additions & 3 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python
poetry config virtualenvs.create false

# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./pyproject.toml ./poetry.lock* /app/

COPY ./pyproject.toml /app/
RUN poetry lock
# Allow installing dev dependencies to run tests
ARG INSTALL_DEV=false
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi"
Expand All @@ -25,4 +25,4 @@ COPY ./prestart.sh /app/

COPY ./tests-start.sh /app/

COPY ./app /app/app
COPY ./app /app/app
22 changes: 22 additions & 0 deletions backend/README.Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### Building and running your application

When you're ready, start your application by running:
`docker compose up --build`.

Your application will be available at http://localhost:8000.

### Deploying your application to the cloud

First, build your image, e.g.: `docker build -t myapp .`.
If your cloud uses a different CPU architecture than your development
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
you'll want to build the image for that platform, e.g.:
`docker build --platform=linux/amd64 -t myapp .`.

Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.

Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
docs for more detail on building and pushing.

### References
* [Docker's Python guide](https://docs.docker.com/language/python/)
18 changes: 10 additions & 8 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ Make sure your editor is using the correct Python virtual environment.

Modify or add SQLModel models for data and SQL tables in `./backend/app/models.py`, API endpoints in `./backend/app/api/`, CRUD (Create, Read, Update, Delete) utils in `./backend/app/crud.py`.

### Enabling Open User Registration

By default the backend has user registration disabled, but there's already a route to register users. If you want to allow users to register themselves, you can set the environment variable `USERS_OPEN_REGISTRATION` to `True` in the `.env` file.

After modifying the environment variables, restart the Docker containers to apply the changes. You can do this by running:

```console
$ docker compose up -d
```

### VS Code

There are already configurations in place to run the backend through the VS Code debugger, so that you can use breakpoints, pause and explore variables, etc.
Expand Down Expand Up @@ -196,11 +206,3 @@ $ alembic upgrade head
```

If you don't want to start with the default models and want to remove them / modify them, from the beginning, without having any previous revision, you can remove the revision files (`.py` Python files) under `./backend/app/alembic/versions/`. And then create a first migration as described above.

## Email Templates

The email templates are in `./backend/app/email-templates/`. Here, there are two directories: `build` and `src`. The `src` directory contains the source files that are used to build the final email templates. The `build` directory contains the final email templates that are used by the application.

Before continuing, ensure you have the [MJML extension](https://marketplace.visualstudio.com/items?itemName=attilabuti.vscode-mjml) installed in your VS Code.

Once you have the MJML extension installed, you can create a new email template in the `src` directory. After creating the new email template and with the `.mjml` file open in your editor, open the command palette with `Ctrl+Shift+P` and search for `MJML: Export to HTML`. This will convert the `.mjml` file to a `.html` file and now you can save it in the build directory.
8 changes: 6 additions & 2 deletions backend/app/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# target_metadata = None

from app.models import SQLModel # noqa
from app.core.config import settings # noqa

target_metadata = SQLModel.metadata

Expand All @@ -30,7 +29,12 @@


def get_url():
return str(settings.SQLALCHEMY_DATABASE_URI)
user = os.getenv("POSTGRES_USER", "postgres")
password = os.getenv("POSTGRES_PASSWORD", "")
server = os.getenv("POSTGRES_SERVER", "db")
port = os.getenv("POSTGRES_PORT", "5432")
db = os.getenv("POSTGRES_DB", "app")
return f"postgresql+psycopg://{user}:{password}@{server}:{port}/{db}"


def run_migrations_offline():
Expand Down

This file was deleted.

35 changes: 35 additions & 0 deletions backend/app/alembic/versions/22df893e8157_migration_added.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""migration added

Revision ID: 22df893e8157
Revises: d5641c6b627b
Create Date: 2024-08-26 19:31:09.654597

"""
from alembic import op
import sqlalchemy as sa
import sqlmodel.sql.sqltypes
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '22df893e8157'
down_revision = 'd5641c6b627b'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('user_resume_json',
sa.Column('id', sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column('user_id', sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column('resume_json_data', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('user_resume_json')
# ### end Alembic commands ###
29 changes: 29 additions & 0 deletions backend/app/alembic/versions/29071ce2deb5_migration_added.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""migration added

Revision ID: 29071ce2deb5
Revises: aaf93a98064a
Create Date: 2024-08-02 22:28:27.099538

"""
from alembic import op
import sqlalchemy as sa
import sqlmodel.sql.sqltypes


# revision identifiers, used by Alembic.
revision = '29071ce2deb5'
down_revision = 'aaf93a98064a'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
42 changes: 42 additions & 0 deletions backend/app/alembic/versions/36d7ec60e107_migration_added.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""migration added

Revision ID: 36d7ec60e107
Revises: bf1a1316a660
Create Date: 2024-08-03 23:24:23.243748

"""
from alembic import op
import sqlalchemy as sa
import sqlmodel.sql.sqltypes


# revision identifiers, used by Alembic.
revision = '36d7ec60e107'
down_revision = 'bf1a1316a660'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('otp_auth',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column('token', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.add_column('user', sa.Column('email_verified_primary', sa.Boolean(), nullable=False))
op.add_column('user', sa.Column('email_verified_secondary', sa.Boolean(), nullable=False))
op.drop_column('user', 'email_verified')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('user', sa.Column('email_verified', sa.BOOLEAN(), autoincrement=False, nullable=False))
op.drop_column('user', 'email_verified_secondary')
op.drop_column('user', 'email_verified_primary')
op.drop_table('otp_auth')
# ### end Alembic commands ###
29 changes: 29 additions & 0 deletions backend/app/alembic/versions/5eef61d10886_migration_added.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""migration added

Revision ID: 5eef61d10886
Revises: 29071ce2deb5
Create Date: 2024-08-02 23:06:35.497448

"""
from alembic import op
import sqlalchemy as sa
import sqlmodel.sql.sqltypes


# revision identifiers, used by Alembic.
revision = '5eef61d10886'
down_revision = '29071ce2deb5'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
29 changes: 29 additions & 0 deletions backend/app/alembic/versions/8b9a5a7a5fe3_migration_added.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""migration added

Revision ID: 8b9a5a7a5fe3
Revises: 5eef61d10886
Create Date: 2024-08-02 23:14:05.552810

"""
from alembic import op
import sqlalchemy as sa
import sqlmodel.sql.sqltypes


# revision identifiers, used by Alembic.
revision = '8b9a5a7a5fe3'
down_revision = '5eef61d10886'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
29 changes: 29 additions & 0 deletions backend/app/alembic/versions/9be5e7723d66_migration_added.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""migration added

Revision ID: 9be5e7723d66
Revises: 8b9a5a7a5fe3
Create Date: 2024-08-02 23:23:15.078526

"""
from alembic import op
import sqlalchemy as sa
import sqlmodel.sql.sqltypes


# revision identifiers, used by Alembic.
revision = '9be5e7723d66'
down_revision = '8b9a5a7a5fe3'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
Loading
Loading