Skip to content

Commit f35f84f

Browse files
committed
moved backend and frontend to apps/*, fixed dockerfile, migrated supabase auth to JWT and supabase db to selfhosted posgresql, enhanced UI
1 parent 8b47478 commit f35f84f

File tree

137 files changed

+1511
-1531
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+1511
-1531
lines changed

app/backend/Dockerfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

apps/backend/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
# Copy requirements file
6+
COPY requirements.txt .
7+
8+
# Install dependencies
9+
RUN pip install --no-cache-dir -r requirements.txt
10+
11+
# Copy the application code
12+
COPY . .
13+
14+
EXPOSE 8005
15+
16+
# Run with uvicorn
17+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8005"]
18+
19+
# ─── DISABLED: AWS Lambda (migrated to EC2) ─────────────────────────────────────
20+
# FROM public.ecr.aws/lambda/python:3.11
21+
# COPY requirements.txt .
22+
# RUN pip install --no-cache-dir -r requirements.txt
23+
# COPY . .
24+
# CMD ["handler.handler"]

apps/backend/FIX_DEPENDENCIES.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
echo "🔧 Fixing Python dependencies..."
4+
5+
# Clear pip cache
6+
python3 -m pip cache purge
7+
8+
# Upgrade pip
9+
python3 -m pip install --upgrade pip
10+
11+
# Install requirements
12+
python3 -m pip install -r requirements.txt
13+
14+
echo "✅ Dependencies installed successfully!"
File renamed without changes.

apps/backend/alembic.ini

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# path to migration scripts.
5+
# this is typically a path given in POSIX (e.g. forward slashes)
6+
# format, relative to the token %(here)s which refers to the location of this
7+
# ini file
8+
script_location = %(here)s/alembic
9+
10+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
11+
# Uncomment the line below if you want the files to be prepended with date and time
12+
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
13+
# for all available tokens
14+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
15+
# Or organize into date-based subdirectories (requires recursive_version_locations = true)
16+
# file_template = %%(year)d/%%(month).2d/%%(day).2d_%%(hour).2d%%(minute).2d_%%(second).2d_%%(rev)s_%%(slug)s
17+
18+
# sys.path path, will be prepended to sys.path if present.
19+
# defaults to the current working directory. for multiple paths, the path separator
20+
# is defined by "path_separator" below.
21+
prepend_sys_path = .
22+
23+
24+
# timezone to use when rendering the date within the migration file
25+
# as well as the filename.
26+
# If specified, requires the tzdata library which can be installed by adding
27+
# `alembic[tz]` to the pip requirements.
28+
# string value is passed to ZoneInfo()
29+
# leave blank for localtime
30+
# timezone =
31+
32+
# max length of characters to apply to the "slug" field
33+
# truncate_slug_length = 40
34+
35+
# set to 'true' to run the environment during
36+
# the 'revision' command, regardless of autogenerate
37+
# revision_environment = false
38+
39+
# set to 'true' to allow .pyc and .pyo files without
40+
# a source .py file to be detected as revisions in the
41+
# versions/ directory
42+
# sourceless = false
43+
44+
# version location specification; This defaults
45+
# to <script_location>/versions. When using multiple version
46+
# directories, initial revisions must be specified with --version-path.
47+
# The path separator used here should be the separator specified by "path_separator"
48+
# below.
49+
# version_locations = %(here)s/bar:%(here)s/bat:%(here)s/alembic/versions
50+
51+
# path_separator; This indicates what character is used to split lists of file
52+
# paths, including version_locations and prepend_sys_path within configparser
53+
# files such as alembic.ini.
54+
# The default rendered in new alembic.ini files is "os", which uses os.pathsep
55+
# to provide os-dependent path splitting.
56+
#
57+
# Note that in order to support legacy alembic.ini files, this default does NOT
58+
# take place if path_separator is not present in alembic.ini. If this
59+
# option is omitted entirely, fallback logic is as follows:
60+
#
61+
# 1. Parsing of the version_locations option falls back to using the legacy
62+
# "version_path_separator" key, which if absent then falls back to the legacy
63+
# behavior of splitting on spaces and/or commas.
64+
# 2. Parsing of the prepend_sys_path option falls back to the legacy
65+
# behavior of splitting on spaces, commas, or colons.
66+
#
67+
# Valid values for path_separator are:
68+
#
69+
# path_separator = :
70+
# path_separator = ;
71+
# path_separator = space
72+
# path_separator = newline
73+
#
74+
# Use os.pathsep. Default configuration used for new projects.
75+
path_separator = os
76+
77+
# set to 'true' to search source files recursively
78+
# in each "version_locations" directory
79+
# new in Alembic version 1.10
80+
# recursive_version_locations = false
81+
82+
# the output encoding used when revision files
83+
# are written from script.py.mako
84+
# output_encoding = utf-8
85+
86+
# database URL. This is consumed by the user-maintained env.py script only.
87+
# other means of configuring database URLs may be customized within the env.py
88+
# file.
89+
sqlalchemy.url = postgresql+asyncpg://postgres:postgres@localhost:5432/collegefinder
90+
91+
92+
[post_write_hooks]
93+
# post_write_hooks defines scripts or Python functions that are run
94+
# on newly generated revision scripts. See the documentation for further
95+
# detail and examples
96+
97+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
98+
# hooks = black
99+
# black.type = console_scripts
100+
# black.entrypoint = black
101+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
102+
103+
# lint with attempts to fix using "ruff" - use the module runner, against the "ruff" module
104+
# hooks = ruff
105+
# ruff.type = module
106+
# ruff.module = ruff
107+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
108+
109+
# Alternatively, use the exec runner to execute a binary found on your PATH
110+
# hooks = ruff
111+
# ruff.type = exec
112+
# ruff.executable = ruff
113+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
114+
115+
# Logging configuration. This is also consumed by the user-maintained
116+
# env.py script only.
117+
[loggers]
118+
keys = root,sqlalchemy,alembic
119+
120+
[handlers]
121+
keys = console
122+
123+
[formatters]
124+
keys = generic
125+
126+
[logger_root]
127+
level = WARNING
128+
handlers = console
129+
qualname =
130+
131+
[logger_sqlalchemy]
132+
level = WARNING
133+
handlers =
134+
qualname = sqlalchemy.engine
135+
136+
[logger_alembic]
137+
level = INFO
138+
handlers =
139+
qualname = alembic
140+
141+
[handler_console]
142+
class = StreamHandler
143+
args = (sys.stderr,)
144+
level = NOTSET
145+
formatter = generic
146+
147+
[formatter_generic]
148+
format = %(levelname)-5.5s [%(name)s] %(message)s
149+
datefmt = %H:%M:%S

apps/backend/alembic/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Generic single-database configuration.

apps/backend/alembic/env.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import asyncio
2+
import os
3+
from logging.config import fileConfig
4+
5+
from dotenv import load_dotenv
6+
from sqlalchemy import pool
7+
from sqlalchemy.ext.asyncio import async_engine_from_config
8+
9+
from alembic import context
10+
11+
load_dotenv()
12+
13+
config = context.config
14+
15+
# Override sqlalchemy.url from environment
16+
config.set_main_option(
17+
"sqlalchemy.url",
18+
os.getenv(
19+
"POSTGRES_URL",
20+
"postgresql+asyncpg://postgres:postgres@localhost:5432/collegefinder",
21+
),
22+
)
23+
24+
if config.config_file_name is not None:
25+
fileConfig(config.config_file_name)
26+
27+
from app.models import Base
28+
29+
target_metadata = Base.metadata
30+
31+
32+
def run_migrations_offline() -> None:
33+
url = config.get_main_option("sqlalchemy.url")
34+
context.configure(
35+
url=url,
36+
target_metadata=target_metadata,
37+
literal_binds=True,
38+
dialect_opts={"paramstyle": "named"},
39+
)
40+
41+
with context.begin_transaction():
42+
context.run_migrations()
43+
44+
45+
def do_run_migrations(connection):
46+
context.configure(connection=connection, target_metadata=target_metadata)
47+
with context.begin_transaction():
48+
context.run_migrations()
49+
50+
51+
async def run_async_migrations():
52+
connectable = async_engine_from_config(
53+
config.get_section(config.config_ini_section, {}),
54+
prefix="sqlalchemy.",
55+
poolclass=pool.NullPool,
56+
)
57+
58+
async with connectable.connect() as connection:
59+
await connection.run_sync(do_run_migrations)
60+
61+
await connectable.dispose()
62+
63+
64+
def run_migrations_online() -> None:
65+
asyncio.run(run_async_migrations())
66+
67+
68+
if context.is_offline_mode():
69+
run_migrations_offline()
70+
else:
71+
run_migrations_online()

0 commit comments

Comments
 (0)