Dev Interview Notes is split into a browser client, a REST API, and a PostgreSQL database.
React/Vite browser client
|
| JSON over HTTP; cookies included
v
FastAPI application
|
| SQLAlchemy 2 async sessions
v
PostgreSQL
Docker Compose runs the database, migration job, API, and frontend as separate services connected to a private bridge network. The API and migration job use the internal database address db:5432; the host-facing database port is 5454.
Files under app/routers/ define HTTP paths, status codes, dependencies, response models, and access checks. Routers should stay thin and delegate business operations to services.
Files under app/services/ coordinate use cases such as authentication, question management, favorites, progress tracking, companies, roadmaps, and email delivery. Services are the preferred place for validation that involves more than one repository or entity.
Files under app/repositories/ encapsulate SQLAlchemy queries and persistence operations. This keeps database access separate from HTTP concerns and makes service logic easier to reason about.
Files under app/schemas/ contain Pydantic models for request validation, filtering, pagination, and API responses. The API uses UUID identifiers and structured JSON content for questions.
SQLAlchemy models live under app/db/models/. The async engine and request-scoped session dependency are defined in app/db/database.py. The session commits successful requests and rolls back failed requests.
| Entity | Responsibility |
|---|---|
| User | Account identity, role, active state, login protection, and profile data |
| Category | Groups questions by subject or technology |
| Question | Main study unit with structured content, difficulty, publication state, and optional company/user links |
| Answer | Explanation associated with a question |
| Company | Company profile and company-specific question collection |
| Roadmap | Profession-oriented study plan composed of ordered roadmap items |
| QuestionFavorite | User-to-question saved-item relationship |
| QuestionCompletion | User-to-question progress relationship |
| Feedback | User feedback delivered through the email service |
- The frontend sends a request to the
/api/v1API prefix. - CORS middleware validates the browser origin and cookie middleware extracts authentication data.
- FastAPI dependencies resolve the database session and, for protected routes, the current active user.
check_permissionenforces role-based access requirements.- The router delegates to a service.
- The service calls one or more repositories.
- The session dependency commits the transaction on success or rolls it back on error.
- Pydantic response models serialize the result into JSON.
Authentication uses two JWTs:
- An access token for short-lived API access.
- A refresh token for issuing a new access token.
Both are stored as HTTP-only cookies. Cookies use secure=True in production and SameSite=Lax in the current implementation.
The authorization layer supports the user and admin roles. Admin access bypasses resource-level permission checks, while regular users receive read access to learning content and can manage their own study state.
Alembic owns schema evolution. The application does not create tables automatically in the lifespan handler. A fresh environment must run:
poetry run alembic upgrade headThe Compose migration service waits for PostgreSQL and applies the same command before the stack is used.
- Use environment-provided secrets; the defaults in the settings classes are for development only.
- Restrict
CORS_ORIGINSto trusted frontend origins in production. - Set
DEBUG=Falseoutside local development. - Run the API behind HTTPS so production cookies are marked secure.
- Configure a real SMTP provider before enabling password recovery or email-based feedback delivery.
- Add health monitoring around
/healthand PostgreSQL connectivity.